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

func (WorkExperience) Fields() []ent.Field {
	return []ent.Field{
		field.Uint64("employee_id").Comment("employee_id | 员工ID"),
		field.Time("start_date").Comment("start_date | 开始时间"),
		field.Time("end_date").Comment("end_date | 结束时间"),
		field.String("company").Comment("company | 公司名"),
		field.Text("experience").Comment("experience | 工作内容"),
		field.Uint64("organization_id").Comment("organization_id | 租户ID"),
	}
}

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

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

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

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