agent.go 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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 Agent struct {
  12. ent.Schema
  13. }
  14. func (Agent) Fields() []ent.Field {
  15. return []ent.Field{
  16. field.String("name").MaxLen(20).Comment("name | 角色名称"),
  17. field.String("role").MaxLen(1000).Comment("role | 角色设定"),
  18. field.Int("status").Optional().Default(1).Comment("status | 状态 1-正常 2-禁用"),
  19. field.String("background").MaxLen(1000).Comment("background | 背景介绍"),
  20. field.String("examples").MaxLen(5000).Comment("examples | 对话案例"),
  21. field.Uint64("organization_id").Comment("organization_id | 租户ID"),
  22. }
  23. }
  24. func (Agent) Mixin() []ent.Mixin {
  25. return []ent.Mixin{
  26. mixins.IDMixin{},
  27. localmixin.SoftDeleteMixin{},
  28. }
  29. }
  30. func (Agent) Edges() []ent.Edge {
  31. return nil
  32. }
  33. func (Agent) Indexes() []ent.Index {
  34. return []ent.Index{
  35. index.Fields("organization_id"),
  36. }
  37. }
  38. func (Agent) Annotations() []schema.Annotation {
  39. return []schema.Annotation{
  40. entsql.WithComments(true),
  41. entsql.Annotation{Table: "agent"},
  42. }
  43. }