category.go 941 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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 Category struct {
  12. ent.Schema
  13. }
  14. func (Category) Fields() []ent.Field {
  15. return []ent.Field{
  16. field.String("name").MaxLen(255).Comment("name | 角色名称"),
  17. field.Uint64("organization_id").Positive().Comment("organization_id | 租户ID"),
  18. }
  19. }
  20. func (Category) Mixin() []ent.Mixin {
  21. return []ent.Mixin{
  22. mixins.IDMixin{},
  23. localmixin.SoftDeleteMixin{},
  24. }
  25. }
  26. func (Category) Edges() []ent.Edge {
  27. return []ent.Edge{}
  28. }
  29. func (Category) Indexes() []ent.Index {
  30. return []ent.Index{
  31. index.Fields("organization_id"),
  32. }
  33. }
  34. func (Category) Annotations() []schema.Annotation {
  35. return []schema.Annotation{
  36. entsql.WithComments(true),
  37. entsql.Annotation{Table: "category"},
  38. }
  39. }