package schema

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

type LabelLog struct {
	ent.Schema
}

func (LabelLog) Fields() []ent.Field {
	return []ent.Field{
		field.String("label_name").Default("").Annotations(entsql.WithComments(true)).Comment("标签名称"),
		field.Int("label_id").Default(0).Annotations(entsql.WithComments(true)).Comment("三方平台标签id"),
		field.String("wx_id").Default("").Annotations(entsql.WithComments(true)).Comment("微信ID"),
		field.Uint64("organization_id").Optional().Default(1).Comment("机构 ID").Annotations(entsql.WithComments(true)),
	}
}

func (LabelLog) Mixin() []ent.Mixin {
	return []ent.Mixin{
		mixins.IDMixin{},
	}
}

func (LabelLog) Indexes() []ent.Index {
	return []ent.Index{
		index.Fields("label_id", "wx_id", "organization_id").Unique().StorageKey("idx_org_label"),
	}
}

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

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