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

func (BatchMsg) Fields() []ent.Field {
	return []ent.Field{
		field.Uint8("status").Optional().Comment("状态 0 未开始 1 开始发送 2 发送完成 3 发送中止"),
		field.String("batch_no").Optional().Unique().Comment("批次号"),
		field.String("task_name").Optional().Default("").Comment("任务名称"),
		field.String("fromwxid").Optional().Comment("发送方微信ID"),
		field.String("msg").Optional().Comment("内容"),
		field.String("tag").Optional().Comment("发送规则 all 全部 tag1,tag2 按tag发送"),
		field.Int32("total").Optional().Comment("总数"),
		field.Int32("success").Optional().Comment("成功数量"),
		field.Int32("fail").Optional().Comment("失败数量"),
		field.Time("start_time").Optional().Comment("开始时间"),
		field.Time("stop_time").Optional().Comment("结束时间"),
		field.Int32("type").Optional().Comment("发送类型 1-群发消息 2-群发朋友圈"),
		field.Uint64("organization_id").Positive().Comment("organization_id | 租户ID"),
	}
}
func (BatchMsg) Mixin() []ent.Mixin {
	return []ent.Mixin{
		mixins.IDMixin{},
		localmixin.SoftDeleteMixin{},
	}
}
func (BatchMsg) Edges() []ent.Edge {
	return nil
}

func (BatchMsg) Indexes() []ent.Index {
	return []ent.Index{
		index.Fields("batch_no").Unique(),
		index.Fields("type"),
	}
}

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