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

func (UsageTotal) Fields() []ent.Field {
	return []ent.Field{
		field.Int("type").Optional().Default(1).
			Annotations(entsql.WithComments(true)).
			Comment("1 微信 2 名片"),
		field.String("bot_id").Default("").
			Annotations(entsql.WithComments(true)).
			Comment("微信或名片id"),
		field.Uint64("total_tokens").Optional().Default(0).
			Annotations(entsql.WithComments(true)).
			Comment("使用token总数"),
		field.Uint64("start_index").Optional().Default(0).
			Annotations(entsql.WithComments(true)).
			Comment("重制后的起始usage_detail 索引"),
		field.Uint64("end_index").Optional().Default(0).
			Annotations(entsql.WithComments(true)).
			Comment("usage_detail 索引"),
		field.Uint64("organization_id").Optional().Default(1).
			Comment("机构 ID").
			Annotations(entsql.WithComments(true)),
	}
}

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

func (UsageTotal) Indexes() []ent.Index {
	return []ent.Index{
		index.Fields("bot_id"),
		index.Fields("organization_id"),
	}
}

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

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