2018-07-13 17:13:40 +03:00
|
|
|
package bug
|
2018-07-12 22:31:41 +03:00
|
|
|
|
2018-07-18 01:16:06 +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
|
2018-07-18 01:16:06 +03:00
|
|
|
Time() time.Time
|
2018-07-13 17:13:40 +03:00
|
|
|
Apply(snapshot Snapshot) Snapshot
|
2018-07-12 22:31:41 +03:00
|
|
|
}
|
2018-07-13 22:21:24 +03:00
|
|
|
|
|
|
|
type OpBase struct {
|
2018-07-14 23:17:37 +03:00
|
|
|
OperationType OperationType
|
2018-07-18 01:16:06 +03:00
|
|
|
Author Person
|
|
|
|
UnixTime int64
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewOpBase(opType OperationType, author Person) OpBase {
|
|
|
|
return OpBase{
|
|
|
|
OperationType: opType,
|
|
|
|
Author: author,
|
|
|
|
UnixTime: time.Now().Unix(),
|
|
|
|
}
|
2018-07-13 22:21:24 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
func (op OpBase) OpType() OperationType {
|
|
|
|
return op.OperationType
|
|
|
|
}
|
2018-07-18 01:16:06 +03:00
|
|
|
|
|
|
|
func (op OpBase) Time() time.Time {
|
|
|
|
return time.Unix(op.UnixTime, 0)
|
|
|
|
}
|