batch_msg.go 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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("fromwxid").Optional().Comment("发送方微信ID"),
  19. field.String("msg").Optional().Comment("内容"),
  20. field.String("tag").Optional().Comment("发送规则 all 全部 tag1,tag2 按tag发送"),
  21. field.Int32("total").Optional().Comment("总数"),
  22. field.Int32("success").Optional().Comment("成功数量"),
  23. field.Int32("fail").Optional().Comment("失败数量"),
  24. field.Time("start_time").Optional().Comment("开始时间"),
  25. field.Time("stop_time").Optional().Comment("结束时间")}
  26. }
  27. func (BatchMsg) Mixin() []ent.Mixin {
  28. return []ent.Mixin{
  29. mixins.IDMixin{},
  30. localmixin.SoftDeleteMixin{},
  31. }
  32. }
  33. func (BatchMsg) Edges() []ent.Edge {
  34. return nil
  35. }
  36. func (BatchMsg) Indexes() []ent.Index {
  37. return []ent.Index{
  38. index.Fields("batch_no").Unique()}
  39. }
  40. func (BatchMsg) Annotations() []schema.Annotation {
  41. return []schema.Annotation{
  42. entsql.WithComments(true),
  43. entsql.Annotation{Table: "batch_msg"},
  44. }
  45. }