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

func (Msg) Fields() []ent.Field {
	return []ent.Field{
		field.Uint8("status").Optional().Comment("Status 1: normal 2: ban | 状态 1 正常 2 禁用"),
		field.String("fromwxid").Optional().Comment("发送方微信ID"),
		field.String("toid").Optional().Comment("接收人微信ID/群ID"),
		field.Int32("msgtype").Optional().Comment("消息类型"),
		field.String("msg").Optional().Comment("消息"),
		field.String("batch_no").Optional().Comment("批次号")}
}

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

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

func (Msg) Indexes() []ent.Index {
	return []ent.Index{
		index.Fields("batch_no"),
		index.Fields("id"),
		index.Fields("status")}
}

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