contact.go 2.8 KB

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