token.go 1021 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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. }
  21. }
  22. func (Token) Mixin() []ent.Mixin {
  23. return []ent.Mixin{
  24. mixins.IDMixin{},
  25. localmixin.SoftDeleteMixin{},
  26. }
  27. }
  28. func (Token) Indexes() []ent.Index {
  29. return []ent.Index{
  30. index.Fields("token").Unique(),
  31. }
  32. }
  33. func (Token) Edges() []ent.Edge {
  34. return nil
  35. }
  36. func (Token) Annotations() []schema.Annotation {
  37. return []schema.Annotation{
  38. entsql.WithComments(true),
  39. entsql.Annotation{Table: "token"},
  40. }
  41. }