package schema

import (
	"entgo.io/ent/schema/index"
	"wechat-api/ent/schema/localmixin"

	"entgo.io/ent"
	"entgo.io/ent/dialect/entsql"
	"entgo.io/ent/schema"
	"entgo.io/ent/schema/field"
	"github.com/suyuan32/simple-admin-common/orm/ent/mixins"
)

type PayRecharge struct {
	ent.Schema
}

func (PayRecharge) Fields() []ent.Field {
	return []ent.Field{
		field.String("user_id").MaxLen(255).Comment("user_id | 用户ID"),
		field.Float32("number").Default(0.0).Comment("number | 变化积分数"),
		field.Int("status").Optional().Range(1, 2).Default(1).Comment("status | 状态 1-正常 2-禁用"),
		field.Float32("money").Optional().Default(0.0).Comment("money | 充值钱数"),
		field.String("out_trade_no").Optional().Default("").Comment("out_trade_no | 外部订单号"),
		field.Uint64("organization_id").Positive().Default(0).Comment("organization_id | 租户ID"),
	}
}

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

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

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

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