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"}, } } func (ManualAction) Fields() []ent.Field { return []ent.Field{ field.Int("id").Positive(), field.Enum("actionType"). GoType(constants.ManualActionType("")). Comment("交互类型"), field.Enum("status"). GoType(constants.ManualActionStatus("")). Default(string(constants.ManualActionStatus_PENDING)). Comment("交互状态"), 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"), } }