batch_msg.go 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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.Int32("total").Optional().Comment("总数"),
  23. field.Int32("success").Optional().Comment("成功数量"),
  24. field.Int32("fail").Optional().Comment("失败数量"),
  25. field.Time("start_time").Optional().Comment("开始时间"),
  26. field.Time("stop_time").Optional().Comment("结束时间"),
  27. field.Time("send_time").Optional().Comment("发送时间"),
  28. field.Int32("type").Optional().Comment("发送类型 1-群发消息 2-群发朋友圈"),
  29. }
  30. }
  31. func (BatchMsg) Mixin() []ent.Mixin {
  32. return []ent.Mixin{
  33. mixins.IDMixin{},
  34. localmixin.SoftDeleteMixin{},
  35. }
  36. }
  37. func (BatchMsg) Edges() []ent.Edge {
  38. return nil
  39. }
  40. func (BatchMsg) Indexes() []ent.Index {
  41. return []ent.Index{
  42. index.Fields("batch_no").Unique(),
  43. index.Fields("type"),
  44. }
  45. }
  46. func (BatchMsg) Annotations() []schema.Annotation {
  47. return []schema.Annotation{
  48. entsql.WithComments(true),
  49. entsql.Annotation{Table: "batch_msg"},
  50. }
  51. }