batch_msg.go 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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/field"
  8. "entgo.io/ent/schema/index"
  9. "github.com/suyuan32/simple-admin-common/orm/ent/mixins"
  10. )
  11. type BatchMsg struct {
  12. ent.Schema
  13. }
  14. func (BatchMsg) Fields() []ent.Field {
  15. return []ent.Field{
  16. field.Uint8("status").Optional().Comment("状态 0 未开始 1 开始发送 2 发送完成 3 发送中止"),
  17. field.String("batch_no").Optional().Unique().Comment("批次号"),
  18. field.String("task_name").Optional().Default("").Comment("任务名称"),
  19. field.String("fromwxid").Optional().Comment("发送方微信ID"),
  20. field.String("msg").Optional().Comment("内容"),
  21. field.String("tag").Optional().Comment("发送规则 all 全部 tag1,tag2 按tag发送"),
  22. field.String("tagids").Optional().Comment("要发送的tagids"),
  23. field.Int32("total").Optional().Comment("总数"),
  24. field.Int32("success").Optional().Comment("成功数量"),
  25. field.Int32("fail").Optional().Comment("失败数量"),
  26. field.Time("start_time").Optional().Comment("开始时间"),
  27. field.Time("stop_time").Optional().Comment("结束时间"),
  28. field.Time("send_time").Optional().Comment("发送时间"),
  29. field.Int32("type").Optional().Comment("发送类型 1-群发消息 2-群发朋友圈"),
  30. field.Uint64("organization_id").Positive().Comment("organization_id | 租户ID"),
  31. }
  32. }
  33. func (BatchMsg) Mixin() []ent.Mixin {
  34. return []ent.Mixin{
  35. mixins.IDMixin{},
  36. localmixin.SoftDeleteMixin{},
  37. }
  38. }
  39. func (BatchMsg) Edges() []ent.Edge {
  40. return nil
  41. }
  42. func (BatchMsg) Indexes() []ent.Index {
  43. return []ent.Index{
  44. index.Fields("batch_no").Unique(),
  45. index.Fields("type"),
  46. }
  47. }
  48. func (BatchMsg) Annotations() []schema.Annotation {
  49. return []schema.Annotation{
  50. entsql.WithComments(true),
  51. entsql.Annotation{Table: "batch_msg"},
  52. }
  53. }