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" "git.noahlan.cn/noahlan/ntool-biz/core/orm/nent/mixins" "git.noahlan.cn/noahlan/ntool/nrandom" ) type Dictionary struct { ent.Schema } func (Dictionary) Fields() []ent.Field { return []ent.Field{ field.String("title"). Comment("The title shown in the ui | 展示名称 (建议配合i18n)"), field.String("name").Unique(). Comment("The name of dictionary for search | 字典搜索名称"), field.String("description"). Comment("The description of dictionary | 字典的描述"). Optional(), } } func (Dictionary) Mixin() []ent.Mixin { return []ent.Mixin{ mixins.NewDistributedIDMixin(func() int64 { return nrandom.SnowflakeId() }), mixins.TimeMixin{}, mixins.StatusMixin{}, mixins.OptimisticLockMixin{}, } } func (Dictionary) Edges() []ent.Edge { return []ent.Edge{ edge.To("details", DictionaryDetail.Type), // one to many } } func (Dictionary) Annotations() []schema.Annotation { return []schema.Annotation{ entsql.WithComments(true), entsql.Annotation{Table: "sys_dictionary"}, schema.Comment("字典表"), } }