package schema import ( "wechat-api/ent/schema/localmixin" "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 SopTask struct { ent.Schema } func (SopTask) Fields() []ent.Field { return []ent.Field{ field.String("name").NotEmpty(). Annotations(entsql.WithComments(true)). Comment("SOP 任务名称"), field.JSON("bot_wxid_list", []string{}).Optional(). Annotations(entsql.WithComments(true)). Comment("机器人微信 id 列表"), field.Int("type").Default(1). Annotations(entsql.WithComments(true)). Comment("标签类型:1好友,2群组,3企业微信联系人"), field.Time("plan_start_time").Optional(). Annotations(entsql.WithComments(true)). Comment("任务计划开始时间"), field.Time("plan_end_time").Optional(). Annotations(entsql.WithComments(true)). Comment("任务计划结束时间"), field.String("creator_id").Optional(). Annotations(entsql.WithComments(true)). Comment("创建者 id"), field.Uint64("organization_id").Optional().Default(1). Comment("机构 ID"). Annotations(entsql.WithComments(true)), field.JSON("token", []string{}).Optional(). Comment("Token"). Annotations(entsql.WithComments(true)), } } func (SopTask) Mixin() []ent.Mixin { return []ent.Mixin{ mixins.IDMixin{}, mixins.StatusMixin{}, localmixin.SoftDeleteMixin{}, } } func (SopTask) Indexes() []ent.Index { return []ent.Index{ index.Fields("name"), index.Fields("token"), } } func (SopTask) Edges() []ent.Edge { return []ent.Edge{ edge.To("task_stages", SopStage.Type), } } func (SopTask) Annotations() []schema.Annotation { return []schema.Annotation{ entsql.WithComments(true), entsql.Annotation{Table: "sop_task"}, } }