package schema

import (
	"wechat-api/ent/schema/localmixin"

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

func (Xunji) Fields() []ent.Field {
	return []ent.Field{
		field.String("app_key").Comment("AppKey"),
		field.String("app_secret").Comment("AppSecret"),
		field.String("token").Comment("Token"),
		field.String("encoding_key").Comment("加密key"),
		field.Uint64("agent_id").Comment("角色ID"),
		field.Uint64("organization_id").Positive().Comment("organization_id | 租户ID"),
		field.String("wxid").Comment("微信ID"),
		field.String("api_base").Optional().Default("").Comment("大模型服务地址"),
		field.String("api_key").Optional().Default("").Comment("大模型服务密钥"),
	}
}

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

func (Xunji) Indexes() []ent.Index {
	return []ent.Index{
		index.Fields("app_key", "token"),
		index.Fields("wxid"),
	}
}

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

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