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" "entgo.io/ent/schema/index" "github.com/suyuan32/simple-admin-common/orm/ent/mixins" ) type Label struct { ent.Schema } func (Label) Fields() []ent.Field { return []ent.Field{ field.Int("type").Default(1). Annotations(entsql.WithComments(true)). Comment("标签类型:1好友,2群组,3公众号,4企业微信联系人"), field.String("name").Default(""). Annotations(entsql.WithComments(true)). Comment("标签名称"), field.Int("from").Default(1). Annotations(entsql.WithComments(true)). Comment("标签来源:1后台创建 2个微同步"), field.Int("mode").Default(1). Annotations(entsql.WithComments(true)). Comment("标签模式:1动态 2静态"), field.String("conditions").Optional().Default(""). Annotations(entsql.WithComments(true)). Comment("标签的触达条件"), field.Uint64("organization_id").Optional().Default(1). Comment("机构 ID"). Annotations(entsql.WithComments(true)), } } func (Label) Mixin() []ent.Mixin { return []ent.Mixin{ mixins.IDMixin{}, mixins.StatusMixin{}, } } func (Label) Indexes() []ent.Index { return []ent.Index{ index.Fields("name", "from", "mode").Unique(), } } func (Label) Edges() []ent.Edge { return []ent.Edge{ edge.To("label_relationships", LabelRelationship.Type), } } func (Label) Annotations() []schema.Annotation { return []schema.Annotation{ entsql.WithComments(true), entsql.Annotation{Table: "label"}, } }