package schema

import (
	"entgo.io/ent/schema/edge"
	"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 Tutorial struct {
	ent.Schema
}

func (Tutorial) Fields() []ent.Field {
	return []ent.Field{
		field.Uint64("employee_id").Positive().Comment("employee_id | 员工ID"),
		field.Int("index").Comment("index | 序号"),
		field.String("title").Comment("title | 标题"),
		field.String("content").Comment("content | 内容"),
		field.Uint64("organization_id").Positive().Comment("organization_id | 租户ID"),
	}
}

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

func (Tutorial) Edges() []ent.Edge {
	return []ent.Edge{
		edge.From("employee", Employee.Type).
			Ref("em_tutorial").
			Field("employee_id").
			Unique().
			Required(),
	}
}

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

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