1package bug
2
3import "time"
4
5type OperationType int
6
7const (
8 _ OperationType = iota
9 CreateOp
10 SetTitleOp
11 AddCommentOp
12 SetStatusOp
13)
14
15type Operation interface {
16 OpType() OperationType
17 Time() time.Time
18 Apply(snapshot Snapshot) Snapshot
19}
20
21type OpBase struct {
22 OperationType OperationType
23 Author Person
24 UnixTime int64
25}
26
27func NewOpBase(opType OperationType, author Person) OpBase {
28 return OpBase{
29 OperationType: opType,
30 Author: author,
31 UnixTime: time.Now().Unix(),
32 }
33}
34
35func (op OpBase) OpType() OperationType {
36 return op.OperationType
37}
38
39func (op OpBase) Time() time.Time {
40 return time.Unix(op.UnixTime, 0)
41}