add_wechat_friend_log.go 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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. "time"
  9. )
  10. // AddWechatFriendLog holds the schema definition for the AddWechatFriendLog entity.
  11. type AddWechatFriendLog struct {
  12. ent.Schema
  13. }
  14. // Fields of the AddWechatFriendLog.
  15. func (AddWechatFriendLog) Fields() []ent.Field {
  16. return []ent.Field{
  17. field.Int64("id").
  18. Comment("主键id").
  19. Unique().
  20. Immutable(),
  21. field.String("owner_wx_id").
  22. Default("").
  23. NotEmpty().
  24. MaxLen(64).
  25. Comment("属主的wxid"),
  26. field.Int("owner_wx_type").
  27. Default(1).
  28. Comment("属主的微信类型(1个微,3企微)"),
  29. field.String("find_content").
  30. Default("").
  31. NotEmpty().
  32. MaxLen(64).
  33. Comment("手机号"),
  34. field.String("message").
  35. Default("").
  36. NotEmpty().
  37. MaxLen(255).
  38. Comment("添加好友时候填写的申请消息"),
  39. field.JSON("find_request", map[string]interface{}{}).
  40. Optional().
  41. Comment("发起查询数据的时候json"),
  42. field.JSON("find_result", map[string]interface{}{}).
  43. Optional().
  44. Comment("查询返回结果"),
  45. field.Int("is_can_add").
  46. Default(0).
  47. Comment("任务执行次数"),
  48. field.Int("task_count").
  49. Default(0).
  50. Comment("是否可以添加好友(与属主账号非好友且其数据查询正常时 0数据准备中,1 待执行 2成功添加申请 3timeout及其他错误 4用户不存在 5手动取消 6已经是好友)"),
  51. field.Int64("task_id").Default(0).Comment("添加时候的请求体"),
  52. field.JSON("add_request", map[string]interface{}{}).
  53. Optional().Comment("添加时候的请求体"),
  54. field.JSON("add_result", map[string]interface{}{}).
  55. Optional().Comment("添加请求的结果"),
  56. field.Int64("created_at").DefaultFunc(func() int64 {
  57. return time.Now().Unix()
  58. }).Comment("创建时间戳"),
  59. field.Int64("updated_at").
  60. DefaultFunc(func() int64 {
  61. return time.Now().Unix()
  62. }).UpdateDefault(func() int64 {
  63. return time.Now().Unix()
  64. }).Comment("修改时间戳"),
  65. field.Int("source").Default(1).Comment("1.api录入 2.人工导入"),
  66. field.String("nick_name").NotEmpty().Default("").MaxLen(255).Comment("用户名称"),
  67. field.String("avatar").NotEmpty().Default("").MaxLen(255).Comment("用户头像"),
  68. field.Int64("organization_id").Default(0).Comment("组织架构id"),
  69. }
  70. }
  71. // Indexes of the AddWechatFriendLog.
  72. func (AddWechatFriendLog) Indexes() []ent.Index {
  73. return []ent.Index{
  74. index.Fields("owner_wx_id", "is_can_add"),
  75. index.Fields("owner_wx_id", "find_content").Unique(),
  76. index.Fields("organization_id", "find_content").Unique(),
  77. }
  78. }
  79. func (AddWechatFriendLog) Annotations() []schema.Annotation {
  80. return []schema.Annotation{
  81. schema.Comment("微信添加好友记录"),
  82. entsql.Annotation{Table: "add_wechat_friend_log"},
  83. }
  84. }