msg.go 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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 Msg struct {
  12. ent.Schema
  13. }
  14. func (Msg) Fields() []ent.Field {
  15. return []ent.Field{
  16. field.Uint8("status").Optional().Comment("Status 1: normal 2: ban | 状态 1 正常 2 禁用"),
  17. field.String("fromwxid").Optional().Comment("发送方微信ID"),
  18. field.String("toid").Optional().Comment("接收人微信ID/群ID"),
  19. field.Int32("msgtype").Optional().Comment("消息类型"),
  20. field.String("msg").Optional().Comment("消息"),
  21. field.String("batch_no").Optional().Comment("批次号"),
  22. field.Uint64("ctype").Default(1).Comment("内容类型:1-微信 2-whatsapp"),
  23. field.String("cc").Default("").Comment("国家区号"),
  24. field.String("phone").Default("").Comment("手机号"),
  25. }
  26. }
  27. func (Msg) Mixin() []ent.Mixin {
  28. return []ent.Mixin{
  29. mixins.IDMixin{},
  30. localmixin.SoftDeleteMixin{},
  31. }
  32. }
  33. func (Msg) Edges() []ent.Edge {
  34. return nil
  35. }
  36. func (Msg) Indexes() []ent.Index {
  37. return []ent.Index{
  38. index.Fields("batch_no"),
  39. index.Fields("id"),
  40. index.Fields("status")}
  41. }
  42. func (Msg) Annotations() []schema.Annotation {
  43. return []schema.Annotation{
  44. entsql.WithComments(true),
  45. entsql.Annotation{Table: "msg"},
  46. }
  47. }