sop_task.go 1.8 KB

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