/
comment.go
79 lines (57 loc) · 1.56 KB
/
comment.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
package gaia
import (
"fmt"
"time"
"github.com/mitchellh/copystructure"
"go.aporeto.io/elemental"
)
// Comment represents the model of a comment
type Comment struct {
// The claims of the author.
Claims []string `json:"claims" msgpack:"claims" bson:"claims" mapstructure:"claims,omitempty"`
// The content of the comment.
Content string `json:"content" msgpack:"content" bson:"content" mapstructure:"content,omitempty"`
// The date of the comment.
Date time.Time `json:"date" msgpack:"date" bson:"date" mapstructure:"date,omitempty"`
ModelVersion int `json:"-" msgpack:"-" bson:"_modelversion"`
}
// NewComment returns a new *Comment
func NewComment() *Comment {
return &Comment{
ModelVersion: 1,
Claims: []string{},
}
}
// BleveType implements the bleve.Classifier Interface.
func (o *Comment) BleveType() string {
return "comment"
}
// DeepCopy returns a deep copy if the Comment.
func (o *Comment) DeepCopy() *Comment {
if o == nil {
return nil
}
out := &Comment{}
o.DeepCopyInto(out)
return out
}
// DeepCopyInto copies the receiver into the given *Comment.
func (o *Comment) DeepCopyInto(out *Comment) {
target, err := copystructure.Copy(o)
if err != nil {
panic(fmt.Sprintf("Unable to deepcopy Comment: %s", err))
}
*out = *target.(*Comment)
}
// Validate valides the current information stored into the structure.
func (o *Comment) Validate() error {
errors := elemental.Errors{}
requiredErrors := elemental.Errors{}
if len(requiredErrors) > 0 {
return requiredErrors
}
if len(errors) > 0 {
return errors
}
return nil
}