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

type ChatRecords struct {
	ent.Schema
}

func (ChatRecords) Fields() []ent.Field {
	return []ent.Field{
		field.String("content").Default("").Comment("内容"),
		field.Uint8("content_type").Default(1).Comment("内容类型：1-提问 2-回答"),
		field.Uint64("session_id").Default(0).Comment("会话ID"),
		field.Uint64("user_id").Default(0).Comment("用户ID"),
		field.Uint64("bot_id").Default(0).Comment("聊天ID"),
		field.Uint8("bot_type").Default(2).Comment("类型:1-微信 2-小程序card 3-智能体"),
	}
}

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

func (ChatRecords) Indexes() []ent.Index {
	return []ent.Index{
		index.Fields("user_id", "bot_id", "bot_type"),
		index.Fields("session_id"),
	}
}

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

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