-
-
Notifications
You must be signed in to change notification settings - Fork 281
/
dictionary.go
48 lines (42 loc) · 1.1 KB
/
dictionary.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
package schema
import (
"entgo.io/ent"
"entgo.io/ent/dialect/entsql"
"entgo.io/ent/schema"
"entgo.io/ent/schema/edge"
"entgo.io/ent/schema/field"
"github.com/suyuan32/simple-admin-common/orm/ent/mixins"
)
type Dictionary struct {
ent.Schema
}
func (Dictionary) Fields() []ent.Field {
return []ent.Field{
field.String("title").
Comment("The title shown in the ui | 展示名称 (建议配合i18n)").
Annotations(entsql.WithComments(true)),
field.String("name").Unique().
Comment("The name of dictionary for search | 字典搜索名称").
Annotations(entsql.WithComments(true)),
field.String("desc").
Comment("The description of dictionary | 字典的描述").
Optional().
Annotations(entsql.WithComments(true)),
}
}
func (Dictionary) Mixin() []ent.Mixin {
return []ent.Mixin{
mixins.IDMixin{},
mixins.StatusMixin{},
}
}
func (Dictionary) Edges() []ent.Edge {
return []ent.Edge{
edge.To("dictionary_details", DictionaryDetail.Type),
}
}
func (Dictionary) Annotations() []schema.Annotation {
return []schema.Annotation{
entsql.Annotation{Table: "sys_dictionaries"},
}
}