sop_task.go 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. package schema
  2. import (
  3. "entgo.io/ent"
  4. "entgo.io/ent/dialect/entsql"
  5. "entgo.io/ent/schema"
  6. "entgo.io/ent/schema/edge"
  7. "entgo.io/ent/schema/field"
  8. "entgo.io/ent/schema/index"
  9. "github.com/suyuan32/simple-admin-common/orm/ent/mixins"
  10. )
  11. type SopTask struct {
  12. ent.Schema
  13. }
  14. func (SopTask) Fields() []ent.Field {
  15. return []ent.Field{
  16. field.String("name").NotEmpty().
  17. Annotations(entsql.WithComments(true)).
  18. Comment("SOP 任务名称"),
  19. field.JSON("bot_wxid_list", []string{}).Optional().
  20. Annotations(entsql.WithComments(true)).
  21. Comment("机器人微信 id 列表"),
  22. field.Int("type").Default(1).
  23. Annotations(entsql.WithComments(true)).
  24. Comment("标签类型:1好友,2群组,3企业微信联系人"),
  25. field.Time("plan_start_time").Optional().
  26. Annotations(entsql.WithComments(true)).
  27. Comment("任务计划开始时间"),
  28. field.Time("plan_end_time").Optional().
  29. Annotations(entsql.WithComments(true)).
  30. Comment("任务计划结束时间"),
  31. field.String("creator_id").Optional().
  32. Annotations(entsql.WithComments(true)).
  33. Comment("创建者 id"),
  34. field.Time("deleted_at").
  35. Optional().
  36. Comment("Delete Time | 删除日期").
  37. Annotations(entsql.WithComments(true)),
  38. }
  39. }
  40. func (SopTask) Mixin() []ent.Mixin {
  41. return []ent.Mixin{
  42. mixins.IDMixin{},
  43. mixins.StatusMixin{},
  44. }
  45. }
  46. func (SopTask) Indexes() []ent.Index {
  47. return []ent.Index{
  48. index.Fields("name"),
  49. }
  50. }
  51. func (SopTask) Edges() []ent.Edge {
  52. return []ent.Edge{
  53. edge.To("task_stages", SopStage.Type),
  54. }
  55. }
  56. func (SopTask) Annotations() []schema.Annotation {
  57. return []schema.Annotation{entsql.Annotation{Table: "sop_task"}}
  58. }