batch_msg.go 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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. field.Uint64("ctype").Default(1).Comment("内容类型:1-微信 2-whatsapp"),
  32. field.String("cc").Optional().Comment("国家区号"),
  33. field.String("phone").Optional().Comment("手机号"),
  34. field.String("template_name").Optional().Comment("模板名"),
  35. field.String("template_code").Optional().Comment("模板code"),
  36. field.String("lang").Optional().Comment("语言"),
  37. }
  38. }
  39. func (BatchMsg) Mixin() []ent.Mixin {
  40. return []ent.Mixin{
  41. mixins.IDMixin{},
  42. localmixin.SoftDeleteMixin{},
  43. }
  44. }
  45. func (BatchMsg) Edges() []ent.Edge {
  46. return nil
  47. }
  48. func (BatchMsg) Indexes() []ent.Index {
  49. return []ent.Index{
  50. index.Fields("batch_no").Unique(),
  51. index.Fields("type"),
  52. }
  53. }
  54. func (BatchMsg) Annotations() []schema.Annotation {
  55. return []schema.Annotation{
  56. entsql.WithComments(true),
  57. entsql.Annotation{Table: "batch_msg"},
  58. }
  59. }