package schema

import (
	"entgo.io/ent/schema/index"
	"wechat-api/ent/schema/localmixin"

	"entgo.io/ent"
	"entgo.io/ent/dialect/entsql"
	"entgo.io/ent/schema"
	"entgo.io/ent/schema/field"
	"github.com/suyuan32/simple-admin-common/orm/ent/mixins"
)

type Category struct {
	ent.Schema
}

func (Category) Fields() []ent.Field {
	return []ent.Field{
		field.String("name").MaxLen(255).Comment("name | 角色名称"),
		field.Uint64("organization_id").Positive().Comment("organization_id | 租户ID"),
	}
}

func (Category) Mixin() []ent.Mixin {
	return []ent.Mixin{
		mixins.IDMixin{},
		localmixin.SoftDeleteMixin{},
	}
}

func (Category) Edges() []ent.Edge {
	return []ent.Edge{}
}

func (Category) Indexes() []ent.Index {
	return []ent.Index{
		index.Fields("organization_id"),
	}
}

func (Category) Annotations() []schema.Annotation {
	return []schema.Annotation{
		entsql.WithComments(true),
		entsql.Annotation{Table: "category"},
	}
}
