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").Optional().Comment("AppKey"),
		field.String("app_secret").Optional().Comment("AppSecret"),
		field.String("token").Optional().Comment("Token"),
		field.String("encoding_key").Optional().Comment("加密key"),
		field.Uint64("organization_id").Positive().Comment("organization_id | 租户ID"),
	}
}

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"),
	}
}

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

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