token.go 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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/field"
  8. "entgo.io/ent/schema/index"
  9. "github.com/suyuan32/simple-admin-common/orm/ent/mixins"
  10. )
  11. type Token struct {
  12. ent.Schema
  13. }
  14. func (Token) Fields() []ent.Field {
  15. return []ent.Field{
  16. field.Time("expire_at").Optional().Default(nil).Comment("过期时间"),
  17. field.String("token").Optional().Default("").Comment("Token"),
  18. field.String("mac").Default("").Comment("Mac地址"),
  19. field.Uint64("organization_id").Default(0).Comment("租户ID"),
  20. field.Uint64("agent_id").Default(0).Comment("智能体ID"),
  21. field.String("custom_agent_base").Optional().Default("").Comment("定制agent服务地址"),
  22. field.String("custom_agent_key").Optional().Default("").Comment("定制agent服务密钥"),
  23. field.String("openai_base").Optional().Default("").Comment("大模型服务地址"),
  24. field.String("openai_key").Optional().Default("").Comment("大模型服务密钥"),
  25. }
  26. }
  27. func (Token) Mixin() []ent.Mixin {
  28. return []ent.Mixin{
  29. mixins.IDMixin{},
  30. localmixin.SoftDeleteMixin{},
  31. }
  32. }
  33. func (Token) Indexes() []ent.Index {
  34. return []ent.Index{
  35. index.Fields("token").Unique(),
  36. }
  37. }
  38. func (Token) Edges() []ent.Edge {
  39. return nil
  40. }
  41. func (Token) Annotations() []schema.Annotation {
  42. return []schema.Annotation{
  43. entsql.WithComments(true),
  44. entsql.Annotation{Table: "token"},
  45. }
  46. }