contact.go 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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. }
  66. }
  67. func (Contact) Mixin() []ent.Mixin {
  68. return []ent.Mixin{
  69. mixins.IDMixin{},
  70. mixins.StatusMixin{},
  71. localmixin.SoftDeleteMixin{},
  72. }
  73. }
  74. func (Contact) Indexes() []ent.Index {
  75. return []ent.Index{
  76. index.Fields("wx_wxid", "wxid").Unique(),
  77. index.Fields("wxid"),
  78. index.Fields("type"),
  79. index.Fields("gid"),
  80. }
  81. }
  82. func (Contact) Edges() []ent.Edge {
  83. return []ent.Edge{
  84. edge.To("contact_relationships", LabelRelationship.Type),
  85. edge.To("contact_messages", MessageRecords.Type),
  86. }
  87. }
  88. func (Contact) Annotations() []schema.Annotation {
  89. return []schema.Annotation{
  90. entsql.WithComments(true),
  91. entsql.Annotation{Table: "contact"},
  92. }
  93. }