contact.go 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  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/edge"
  8. "entgo.io/ent/schema/field"
  9. "entgo.io/ent/schema/index"
  10. "github.com/suyuan32/simple-admin-common/orm/ent/mixins"
  11. )
  12. type Contact struct {
  13. ent.Schema
  14. }
  15. func (Contact) Fields() []ent.Field {
  16. return []ent.Field{
  17. field.String("wx_wxid").Default("").
  18. Annotations(entsql.WithComments(true)).
  19. Comment("属主微信id"),
  20. field.Int("type").Optional().Default(1).
  21. Annotations(entsql.WithComments(true)).
  22. Comment("联系人类型:1好友,2群组,3公众号,4企业微信联系人"),
  23. field.String("wxid").Default("").
  24. Annotations(entsql.WithComments(true)).
  25. Comment("微信id 公众号微信ID"),
  26. field.String("account").Default("").
  27. Annotations(entsql.WithComments(true)).
  28. Comment("微信账号"),
  29. field.String("nickname").Default("").
  30. Annotations(entsql.WithComments(true)).
  31. Comment("微信昵称 群备注名称"),
  32. field.String("markname").Default("").
  33. Annotations(entsql.WithComments(true)).
  34. Comment("备注名"),
  35. field.String("headimg").Default("").
  36. Annotations(entsql.WithComments(true)).
  37. Comment("头像"),
  38. field.Int("sex").Default(0).
  39. Annotations(entsql.WithComments(true)).
  40. Comment("性别 0未知 1男 2女"),
  41. field.String("starrole").Default("").
  42. Annotations(entsql.WithComments(true)).
  43. Comment("星标 65/67=星标 1/3=未星标"),
  44. field.Int("dontseeit").Default(0).
  45. Annotations(entsql.WithComments(true)).
  46. Comment("不让他看我的朋友圈 0可以看 1不让看"),
  47. field.Int("dontseeme").Default(0).
  48. Annotations(entsql.WithComments(true)).
  49. Comment("不看他的朋友圈 0可以看 1不看 1=开启了不看他 128/129=仅聊天"),
  50. field.String("lag").Default("").
  51. Annotations(entsql.WithComments(true)).
  52. Comment("所属标签id清单,多开会用逗号隔开"),
  53. field.String("gid").Default("").
  54. Annotations(entsql.WithComments(true)).
  55. Comment("群组id"),
  56. field.String("gname").Default("").
  57. Annotations(entsql.WithComments(true)).
  58. Comment("群组名称"),
  59. field.String("v3").Default("").
  60. Annotations(entsql.WithComments(true)).
  61. Comment("v3数据"),
  62. field.Uint64("organization_id").Optional().Default(1).
  63. Comment("机构 ID").
  64. Annotations(entsql.WithComments(true)),
  65. field.Uint64("ctype").Default(1).Comment("内容类型:1-微信 2-whatsapp"),
  66. field.Int("cage").Default(0).Comment("年龄"),
  67. field.String("cname").Default("").Comment("姓名"),
  68. field.String("carea").Default("").Comment("地区"),
  69. field.String("cbirthday").Default("").Comment("出生日期"),
  70. field.String("cbirtharea").Default("").Comment("出生地"),
  71. field.String("cidcard_no").Default("").Comment("身份证号"),
  72. field.String("ctitle").Default("").Comment("称呼"),
  73. field.String("cc").Default("").Comment("国家区号"),
  74. field.String("phone").Default("").Comment("手机号"),
  75. }
  76. }
  77. func (Contact) Mixin() []ent.Mixin {
  78. return []ent.Mixin{
  79. mixins.IDMixin{},
  80. mixins.StatusMixin{},
  81. localmixin.SoftDeleteMixin{},
  82. }
  83. }
  84. func (Contact) Indexes() []ent.Index {
  85. return []ent.Index{
  86. index.Fields("wx_wxid", "wxid").Unique(),
  87. index.Fields("wxid"),
  88. index.Fields("type"),
  89. index.Fields("gid"),
  90. }
  91. }
  92. func (Contact) Edges() []ent.Edge {
  93. return []ent.Edge{
  94. edge.To("contact_relationships", LabelRelationship.Type),
  95. edge.To("contact_messages", MessageRecords.Type),
  96. }
  97. }
  98. func (Contact) Annotations() []schema.Annotation {
  99. return []schema.Annotation{
  100. entsql.WithComments(true),
  101. entsql.Annotation{Table: "contact"},
  102. }
  103. }