contact.go 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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. "github.com/suyuan32/simple-admin-common/orm/ent/mixins"
  9. "wechat-api/ent/schema/localmixin"
  10. )
  11. type Contact struct {
  12. ent.Schema
  13. }
  14. func (Contact) Fields() []ent.Field {
  15. return []ent.Field{
  16. field.String("wx_wxid").Optional().Default("").
  17. Annotations(entsql.WithComments(true)).
  18. Comment("属主微信id"),
  19. field.Int("type").Optional().Default(1).
  20. Annotations(entsql.WithComments(true)).
  21. Comment("联系人类型:1好友,2群组,3公众号,4企业微信联系人"),
  22. field.String("wxid").Default("").
  23. Annotations(entsql.WithComments(true)).
  24. Comment("微信id 公众号微信ID"),
  25. field.String("account").Default("").
  26. Annotations(entsql.WithComments(true)).
  27. Comment("微信账号"),
  28. field.String("nickname").Default("").
  29. Annotations(entsql.WithComments(true)).
  30. Comment("微信昵称 群备注名称"),
  31. field.String("markname").Default("").
  32. Annotations(entsql.WithComments(true)).
  33. Comment("备注名"),
  34. field.String("headimg").Default("").
  35. Annotations(entsql.WithComments(true)).
  36. Comment("头像"),
  37. field.Int("sex").Default(0).
  38. Annotations(entsql.WithComments(true)).
  39. Comment("性别 0未知 1男 2女"),
  40. field.String("starrole").Default("").
  41. Annotations(entsql.WithComments(true)).
  42. Comment("星标 65/67=星标 1/3=未星标"),
  43. field.Int("dontseeit").Default(0).
  44. Annotations(entsql.WithComments(true)).
  45. Comment("不让他看我的朋友圈 0可以看 1不让看"),
  46. field.Int("dontseeme").Default(0).
  47. Annotations(entsql.WithComments(true)).
  48. Comment("不看他的朋友圈 0可以看 1不看 1=开启了不看他 128/129=仅聊天"),
  49. field.String("lag").Default("").
  50. Annotations(entsql.WithComments(true)).
  51. Comment("所属标签id清单,多开会用逗号隔开"),
  52. field.String("gid").Default("").
  53. Annotations(entsql.WithComments(true)).
  54. Comment("群组id"),
  55. field.String("gname").Default("").
  56. Annotations(entsql.WithComments(true)).
  57. Comment("群组名称"),
  58. field.String("v3").Default("").
  59. Annotations(entsql.WithComments(true)).
  60. Comment("v3数据"),
  61. }
  62. }
  63. func (Contact) Mixin() []ent.Mixin {
  64. return []ent.Mixin{
  65. mixins.IDMixin{},
  66. mixins.StatusMixin{},
  67. localmixin.SoftDeleteMixin{},
  68. }
  69. }
  70. func (Contact) Indexes() []ent.Index {
  71. return []ent.Index{
  72. index.Fields("wx_wxid", "wxid").Unique(),
  73. index.Fields("wxid"),
  74. index.Fields("type"),
  75. index.Fields("gid"),
  76. }
  77. }
  78. func (Contact) Edges() []ent.Edge {
  79. return nil
  80. }
  81. func (Contact) Annotations() []schema.Annotation {
  82. return []schema.Annotation{entsql.Annotation{Table: "contact"}}
  83. }