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 Employee struct {
	ent.Schema
}

func (Employee) Fields() []ent.Field {
	return []ent.Field{
		field.String("title").MaxLen(1000).Comment("title | 标题"),
		field.String("avatar").Comment("avatar | 头像"),
		field.String("tags").Comment("tags | 个人标签"),
		field.Int("hire_count").Positive().Default(0).Comment("hire_count | 被雇佣次数"),
		field.Int("service_count").Positive().Default(0).Comment("service_count | 已服务次数"),
		field.Int("achievement_count").Positive().Default(0).Comment("achievement_count | 业绩单数"),
		field.String("intro").Default("").Comment("intro | 个人介绍"),
		field.String("estimate").Default("").Comment("estimate | 自我评价"),
		field.String("skill").Default("").Comment("skill | 技能卡"),
		field.String("ability_type").Default("").Comment("ability_type | 能力类型"),
		field.String("scene").Default("").Comment("scene | 使用场景"),
		field.String("switch_in").Default("").Comment("switch_in | 支持介入"),
		field.String("video_url").Default("").Comment("video_url | 视频地址"),
		field.Uint64("organization_id").Positive().Comment("organization_id | 租户ID"),
		field.Uint64("category_id").Positive().Comment("category_id | 分类ID"),
		field.String("api_base").Default("").Comment("api_base"),
		field.String("api_key").Default("").Comment("api_key"),
		field.String("ai_info").Optional().Comment("AI信息"),
		field.Int("is_vip").Default(0).Comment("是否VIP：0-否 1-是"),
		field.String("chat_url").Comment("聊天URL"),
	}
}

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

func (Employee) Edges() []ent.Edge {
	return []ent.Edge{
		edge.To("em_work_experiences", WorkExperience.Type),
		edge.To("em_tutorial", Tutorial.Type),
	}
}

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

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