msg.go 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. package schema
  2. import (
  3. "entgo.io/ent"
  4. "entgo.io/ent/dialect/entsql"
  5. "entgo.io/ent/schema"
  6. "entgo.io/ent/schema/field"
  7. "entgo.io/ent/schema/index"
  8. )
  9. type Msg struct {
  10. ent.Schema
  11. }
  12. func (Msg) Fields() []ent.Field {
  13. return []ent.Field{
  14. field.Int("id"),
  15. field.Time("created_at").Comment("Create Time | 创建日期"),
  16. field.Time("updated_at").Comment("Update Time | 修改日期"),
  17. field.Time("deleted_at").Optional().Comment("Delete Time | 删除日期"),
  18. field.Uint8("status").Optional().Comment("Status 1: normal 2: ban | 状态 1 正常 2 禁用"),
  19. field.String("fromwxid").Optional().Comment("发送方微信ID"),
  20. field.String("toid").Optional().Comment("接收人微信ID/群ID"),
  21. field.Int32("msgtype").Optional().Comment("消息类型"),
  22. field.String("msg").Optional().Comment("消息"),
  23. field.String("batch_no").Optional().Comment("批次号")}
  24. }
  25. func (Msg) Edges() []ent.Edge {
  26. return nil
  27. }
  28. func (Msg) Indexes() []ent.Index {
  29. return []ent.Index{
  30. index.Fields("batch_no"),
  31. index.Fields("id"),
  32. index.Fields("status")}
  33. }
  34. func (Msg) Annotations() []schema.Annotation {
  35. return []schema.Annotation{
  36. entsql.WithComments(true),
  37. entsql.Annotation{Table: "msg"},
  38. }
  39. }