sop_task.go 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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. }
  36. }
  37. func (SopTask) Mixin() []ent.Mixin {
  38. return []ent.Mixin{
  39. mixins.IDMixin{},
  40. mixins.StatusMixin{},
  41. localmixin.SoftDeleteMixin{},
  42. }
  43. }
  44. func (SopTask) Indexes() []ent.Index {
  45. return []ent.Index{
  46. index.Fields("name"),
  47. }
  48. }
  49. func (SopTask) Edges() []ent.Edge {
  50. return []ent.Edge{
  51. edge.To("task_stages", SopStage.Type),
  52. }
  53. }
  54. func (SopTask) Annotations() []schema.Annotation {
  55. return []schema.Annotation{
  56. entsql.WithComments(true),
  57. entsql.Annotation{Table: "sop_task"},
  58. }
  59. }