72 lines
1.8 KiB
Go
72 lines
1.8 KiB
Go
package schema
|
|
|
|
import (
|
|
"entgo.io/ent"
|
|
"entgo.io/ent/dialect/entsql"
|
|
"entgo.io/ent/schema"
|
|
"entgo.io/ent/schema/edge"
|
|
"entgo.io/ent/schema/field"
|
|
"entgo.io/ent/schema/index"
|
|
"github.com/saas-mingyang/mingyang-admin-common/orm/ent/mixins"
|
|
mixins2 "mingyang-admin-pay/rpc/ent/schema/mixins"
|
|
)
|
|
|
|
type PayNotifyTask struct {
|
|
ent.Schema
|
|
}
|
|
|
|
// Fields of the PayNotifyTask.
|
|
func (PayNotifyTask) Fields() []ent.Field {
|
|
return []ent.Field{
|
|
field.Uint8("type").Comment("通知类型").Default(1),
|
|
field.Uint64("data_id").Comment("数据 ID"),
|
|
field.Uint64("order_id").Comment("订单 ID"),
|
|
field.Uint64("app_id").Comment("应用 ID"),
|
|
field.Uint8("notify_status").Comment("通知状态"),
|
|
field.Time("next_notify_time").Optional().Comment("下次通知时间"),
|
|
field.Time("last_execute_time").Optional().Comment("最后一次执行时间"),
|
|
field.Uint32("retry_count").Optional().Comment("重试次数"),
|
|
field.Uint32("max_retry_count").Optional().Comment("最大重试次数"),
|
|
field.String("notify_url").Optional().Comment("通知地址"),
|
|
}
|
|
}
|
|
|
|
func (PayNotifyTask) Mixin() []ent.Mixin {
|
|
return []ent.Mixin{
|
|
mixins.IDMixin{},
|
|
mixins.StatusMixin{},
|
|
mixins.TenantMixin{},
|
|
mixins2.SoftDeleteMixin{},
|
|
}
|
|
|
|
}
|
|
func (PayNotifyTask) Edges() []ent.Edge {
|
|
return []ent.Edge{
|
|
edge.To("app", App.Type).
|
|
Field("app_id").
|
|
Unique().
|
|
Required(),
|
|
edge.To("order", PayOrder.Type).
|
|
Field("order_id").
|
|
Unique().
|
|
Required(),
|
|
edge.From("notify_log", PayNotifyLog.Type).
|
|
Ref("task"),
|
|
}
|
|
}
|
|
|
|
func (PayNotifyTask) Indexes() []ent.Index {
|
|
return []ent.Index{
|
|
index.Fields("order_id"),
|
|
index.Fields("data_id"),
|
|
}
|
|
}
|
|
|
|
func (PayNotifyTask) Annotations() []schema.Annotation {
|
|
return []schema.Annotation{
|
|
entsql.WithComments(true),
|
|
schema.Comment("PayNotifyTask Table | 异步通知任务表"),
|
|
entsql.Annotation{Table: "pay_notify_task"},
|
|
}
|
|
}
|