security_secret.go 822 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. package schema
  2. import (
  3. "github.com/Wei-Shaw/sub2api/ent/schema/mixins"
  4. "entgo.io/ent"
  5. "entgo.io/ent/dialect"
  6. "entgo.io/ent/dialect/entsql"
  7. "entgo.io/ent/schema"
  8. "entgo.io/ent/schema/field"
  9. )
  10. // SecuritySecret 存储系统级安全密钥(如 JWT 签名密钥、TOTP 加密密钥)。
  11. type SecuritySecret struct {
  12. ent.Schema
  13. }
  14. func (SecuritySecret) Annotations() []schema.Annotation {
  15. return []schema.Annotation{
  16. entsql.Annotation{Table: "security_secrets"},
  17. }
  18. }
  19. func (SecuritySecret) Mixin() []ent.Mixin {
  20. return []ent.Mixin{
  21. mixins.TimeMixin{},
  22. }
  23. }
  24. func (SecuritySecret) Fields() []ent.Field {
  25. return []ent.Field{
  26. field.String("key").
  27. MaxLen(100).
  28. NotEmpty().
  29. Unique(),
  30. field.String("value").
  31. NotEmpty().
  32. SchemaType(map[string]string{
  33. dialect.Postgres: "text",
  34. }),
  35. }
  36. }