git-bug/bug/operation.go

43 lines
665 B
Go
Raw Normal View History

2018-07-13 17:13:40 +03:00
package bug
2018-07-12 22:31:41 +03:00
import "time"
2018-07-12 22:31:41 +03:00
type OperationType int
const (
2018-07-17 20:28:37 +03:00
_ OperationType = iota
CreateOp
SetTitleOp
AddCommentOp
SetStatusOp
2018-07-18 17:41:09 +03:00
LabelChangeOp
2018-07-12 22:31:41 +03:00
)
type Operation interface {
OpType() OperationType
Time() time.Time
2018-07-13 17:13:40 +03:00
Apply(snapshot Snapshot) Snapshot
2018-07-12 22:31:41 +03:00
}
type OpBase struct {
OperationType OperationType
Author Person
UnixTime int64
}
func NewOpBase(opType OperationType, author Person) OpBase {
return OpBase{
OperationType: opType,
Author: author,
UnixTime: time.Now().Unix(),
}
}
func (op OpBase) OpType() OperationType {
return op.OperationType
}
func (op OpBase) Time() time.Time {
return time.Unix(op.UnixTime, 0)
}