wx.go 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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 Wx struct {
  13. ent.Schema
  14. }
  15. func (Wx) Fields() []ent.Field {
  16. return []ent.Field{
  17. field.Uint64("server_id").Optional().Default(0).
  18. Annotations(entsql.WithComments(true)).
  19. Comment("服务器id"),
  20. field.String("port").Default("").
  21. Annotations(entsql.WithComments(true)).
  22. Comment("端口号"),
  23. field.String("process_id").Default("").
  24. Annotations(entsql.WithComments(true)).
  25. Comment("进程号"),
  26. field.String("callback").Default("").
  27. Annotations(entsql.WithComments(true)).
  28. Comment("回调地址"),
  29. field.String("wxid").Default("").
  30. Default("").
  31. Annotations(entsql.WithComments(true)).
  32. Comment("微信id"),
  33. field.String("account").Default("").
  34. Annotations(entsql.WithComments(true)).
  35. Comment("微信账号"),
  36. field.String("nickname").Default("").
  37. Annotations(entsql.WithComments(true)).
  38. Comment("微信昵称"),
  39. field.String("tel").Default("").
  40. Annotations(entsql.WithComments(true)).
  41. Comment("手机号"),
  42. field.String("head_big").Default("").
  43. Annotations(entsql.WithComments(true)).
  44. Comment("微信头像"),
  45. }
  46. }
  47. func (Wx) Mixin() []ent.Mixin {
  48. return []ent.Mixin{
  49. mixins.IDMixin{},
  50. mixins.StatusMixin{},
  51. localmixin.SoftDeleteMixin{},
  52. }
  53. }
  54. func (Wx) Indexes() []ent.Index {
  55. return []ent.Index{
  56. index.Fields("server_id", "port").Unique(),
  57. index.Fields("wxid").Unique(),
  58. index.Fields("account"),
  59. index.Fields("nickname"),
  60. index.Fields("tel"),
  61. }
  62. }
  63. func (Wx) Edges() []ent.Edge {
  64. return []ent.Edge{
  65. edge.From("server", Server.Type).Ref("wxs").Unique().Field("server_id"),
  66. }
  67. }
  68. func (Wx) Annotations() []schema.Annotation {
  69. return []schema.Annotation{
  70. entsql.WithComments(true),
  71. entsql.Annotation{Table: "wx"},
  72. }
  73. }