whatsapp.go 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. package schema
  2. import (
  3. "entgo.io/ent/schema/edge"
  4. "wechat-api/ent/schema/localmixin"
  5. "entgo.io/ent"
  6. "entgo.io/ent/dialect/entsql"
  7. "entgo.io/ent/schema"
  8. "entgo.io/ent/schema/field"
  9. "github.com/suyuan32/simple-admin-common/orm/ent/mixins"
  10. )
  11. type Whatsapp struct {
  12. ent.Schema
  13. }
  14. func (Whatsapp) Fields() []ent.Field {
  15. return []ent.Field{
  16. field.String("wa_id").Optional().Default("").Comment("通道ID"),
  17. field.String("wa_name").Optional().Default("").Comment("通道名"),
  18. field.String("callback").Optional().Default("").Comment("回调地址"),
  19. field.Uint64("agent_id").Default(0).Comment("AI角色ID"),
  20. field.String("account").Optional().Default("").Comment("账号"),
  21. field.String("cc").Default("").Comment("国家区号"),
  22. field.String("phone").Default("").Comment("手机号"),
  23. field.String("phone_name").Default("").Comment("号码名称"),
  24. field.Int8("phone_status").Default(0).Comment("号码状态"),
  25. field.Uint64("organization_id").Optional().Default(0).Comment("机构 ID"),
  26. field.String("api_base").Optional().Default("").Comment("大模型服务账号"),
  27. field.String("api_key").Optional().Default("").Comment("大模型服务密钥"),
  28. field.JSON("allow_list", []string{}).Optional().Comment("白名单"),
  29. field.JSON("group_allow_list", []string{}).Optional().Comment("群白名单"),
  30. field.JSON("block_list", []string{}).Optional().Comment("黑名单"),
  31. field.JSON("group_block_list", []string{}).Optional().Comment("群黑名单"),
  32. }
  33. }
  34. func (Whatsapp) Mixin() []ent.Mixin {
  35. return []ent.Mixin{
  36. mixins.IDMixin{},
  37. mixins.StatusMixin{},
  38. localmixin.SoftDeleteMixin{},
  39. }
  40. }
  41. func (Whatsapp) Indexes() []ent.Index {
  42. return []ent.Index{}
  43. }
  44. func (Whatsapp) Edges() []ent.Edge {
  45. return []ent.Edge{
  46. edge.From("agent", Agent.Type).
  47. Ref("wa_agent").
  48. Unique().
  49. Field("agent_id").
  50. Required(),
  51. }
  52. }
  53. func (Whatsapp) Annotations() []schema.Annotation {
  54. return []schema.Annotation{
  55. entsql.Annotation{Table: "whatsapp"},
  56. }
  57. }