package schema

import (
	"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"
	"wechat-api/ent/schema/localmixin"
)

type LabelTagging struct {
	ent.Schema
}

func (LabelTagging) Fields() []ent.Field {
	return []ent.Field{
		field.Uint64("organization_id").Default(1).
			Comment("机构 ID").
			Annotations(entsql.WithComments(true)),
		field.Int("type").Default(1).
			Annotations(entsql.WithComments(true)).
			Comment("标签类型：1好友，2群组，3公众号，4企业微信联系人"),
		field.String("conditions").Default("").
			Annotations(entsql.WithComments(true)).
			Comment("关键词"),
		field.JSON("action_label_add", []uint64{}).Optional().
			Annotations(entsql.WithComments(true)).
			Comment("命中后需要打的标签"),
		field.JSON("action_label_del", []uint64{}).Optional().
			Annotations(entsql.WithComments(true)).
			Comment("命中后需要移除的标签"),
	}
}

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

func (LabelTagging) Indexes() []ent.Index {
	return []ent.Index{}
}

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

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