alloc_agent.go 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. package schema
  2. import (
  3. "entgo.io/ent/schema/index"
  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 AllocAgent struct {
  12. ent.Schema
  13. }
  14. func (AllocAgent) Fields() []ent.Field {
  15. return []ent.Field{
  16. field.String("user_id").Default("").Optional().Comment("user_id | 前台用户ID"),
  17. field.Uint64("organization_id").Optional().Default(0).Comment("organization_id | 租户ID"),
  18. field.JSON("agents", []uint64{}).Comment("agents | 分配的智能体IDs"),
  19. field.Int("status").Optional().Range(1, 2).Default(1).Comment("status | 状态 1-正常 2-禁用"),
  20. }
  21. }
  22. func (AllocAgent) Mixin() []ent.Mixin {
  23. return []ent.Mixin{
  24. mixins.IDMixin{},
  25. localmixin.SoftDeleteMixin{},
  26. }
  27. }
  28. func (AllocAgent) Edges() []ent.Edge {
  29. return nil
  30. }
  31. func (AllocAgent) Indexes() []ent.Index {
  32. return []ent.Index{
  33. index.Fields("organization_id"),
  34. index.Fields("user_id"),
  35. }
  36. }
  37. func (AllocAgent) Annotations() []schema.Annotation {
  38. return []schema.Annotation{
  39. entsql.WithComments(true),
  40. entsql.Annotation{Table: "alloc_agent"},
  41. }
  42. }