62 lines
2.1 KiB
Go
62 lines
2.1 KiB
Go
package schema
|
||||
|
|
|
|||
|
|
import (
|
|||
|
|
"time"
|
|||
|
|
|
|||
|
|
"bj_power_mes/constants"
|
|||
|
|
|
|||
|
|
"entgo.io/ent"
|
|||
|
|
"entgo.io/ent/dialect"
|
|||
|
|
"entgo.io/ent/dialect/entsql"
|
|||
|
|
"entgo.io/ent/schema"
|
|||
|
|
"entgo.io/ent/schema/field"
|
|||
|
|
"entgo.io/ent/schema/index"
|
|||
|
|
)
|
|||
|
|
|
|||
|
|
// ManualAction 人工交互记录,需��作员手动确认或处�的交互任务
|
|||
|
|
type ManualAction struct {
|
|||
|
|
ent.Schema
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
func (ManualAction) Annotations() []schema.Annotation {
|
|||
|
|
return []schema.Annotation{
|
|||
|
|
entsql.Annotation{
|
|||
|
|
Table: "manual_action",
|
|||
|
|
Options: "COMMENT='人工交互记录表,å˜å‚¨éœ€è¦�æ“�作员手动确认或处ç�†çš„交互任务,如异常确认ã€�æ�¢æ–™è¯·æ±?",
|
|||
|
|
},
|
|||
|
|
entsql.WithComments(true),
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
func (ManualAction) Fields() []ent.Field {
|
|||
|
|
return []ent.Field{
|
|||
|
|
field.Int("id").Positive().Comment("主键ID"),
|
|||
|
|
field.Enum("actionType").
|
|||
|
|
GoType(constants.ManualActionType("")).
|
|||
|
|
Comment("交互类型:AbnormalConfirm/MaterialRequest/QualityCheckç?),
|
|||
|
|
field.Enum("status").
|
|||
|
|
GoType(constants.ManualActionStatus("")).
|
|||
|
|
Default(string(constants.ManualActionStatus_PENDING)).
|
|||
|
|
Comment("交互状�:PENDING/RESOLVED/TIMEOUT"),
|
|||
|
|
field.Int("orderId").Optional().Nillable().Comment("关�工�ID"),
|
|||
|
|
field.Int("jobId").Optional().Nillable().Comment("关�工件ID"),
|
|||
|
|
field.Int("equipmentId").Optional().Nillable().Comment("关�设备ID"),
|
|||
|
|
field.JSON("context", map[string]any{}).Optional().SchemaType(map[string]string{
|
|||
|
|
dialect.Postgres: "jsonb",
|
|||
|
|
}).Comment("业务上下文,�带交互相关的结构化数�,如异常详情�请求��),
|
|||
|
|
field.String("resolvedAction").Default("").Comment("处�动作,�作员选择的处�方�),
|
|||
|
|
field.String("resolvedBy").Default("").Comment("处ç�†äººï¼Œæ‰§è¡Œå¤„ç�†æ“�ä½œçš„ç”¨æˆ·æ ‡è¯?),
|
|||
|
|
field.Time("resolvedAt").Optional().Nillable().Comment("处�时间,交互被确认或处�的时刻"),
|
|||
|
|
field.Time("createdAt").Default(time.Now).Immutable().Comment("创建时间,交互记录产生的时刻"),
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
func (ManualAction) Indexes() []ent.Index {
|
|||
|
|
return []ent.Index{
|
|||
|
|
index.Fields("actionType"),
|
|||
|
|
index.Fields("status"),
|
|||
|
|
index.Fields("orderId"),
|
|||
|
|
index.Fields("createdAt"),
|
|||
|
|
}
|
|||
|
|
}
|