package tables import ( "time" "git.x2erp.com/qdy/go-db/sqldef" ) func init() { sqldef.AddRegistration(func(r *sqldef.Registry) { tb := sqldef.NewTable("decision_task", "决策任务表"). ID("task_id", 32).Comment("任务ID,主键").End(). String("sku_id", 32).NotNull().Comment("关联商品").End(). String("task_type", 32).NotNull().Comment("任务类型(调拨/促销/反单/保持)").End(). String("task_status", 32).NotNull().Default("'pending'").Comment("任务状态(pending/approved/rejected/executed)").End(). Text("task_content").NotNull().Comment("任务详细内容与参数(JSON格式)").End(). Text("diagnosis_basis").NotNull().Comment("诊断依据与数据快照(JSON格式)").End(). String("creator", 32).Comment("任务创建人(系统或用户)").End(). String("approver", 32).Comment("审批人").End(). DateTime("approved_at").Comment("审批时间").End(). String("executor", 32).Comment("执行人").End(). String("tenant_id", 8).NotNull().Comment("租户ID").End(). DateTime("executed_at").Comment("执行时间").End(). Text("execution_feedback").Comment("执行反馈(JSON格式)").End(). DateTime("created_at").NotNull().Default("CURRENT_TIMESTAMP").Comment("创建时间").End(). DateTime("updated_at").NotNull().Default("CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP").Comment("更新时间").End() r.RegisterTable(tb.Build()) }) } // DecisionTask 决策任务表结构体 type DecisionTask struct { TaskID string `gorm:"column:task_id;type:varchar(32);primaryKey;not null;comment:任务ID,主键"` SkuID string `gorm:"column:sku_id;type:varchar(32);not null;comment:关联商品;index"` TaskType string `gorm:"column:task_type;type:varchar(32);not null;comment:任务类型(调拨/促销/反单/保持)"` TaskStatus string `gorm:"column:task_status;type:varchar(32);not null;default:'pending';comment:任务状态(pending/approved/rejected/executed)"` TaskContent string `gorm:"column:task_content;type:text;not null;comment:任务详细内容与参数(JSON格式)"` DiagnosisBasis string `gorm:"column:diagnosis_basis;type:text;not null;comment:诊断依据与数据快照(JSON格式)"` Creator string `gorm:"column:creator;type:varchar(32);comment:任务创建人(系统或用户)"` Approver string `gorm:"column:approver;type:varchar(32);comment:审批人"` ApprovedAt time.Time `gorm:"column:approved_at;comment:审批时间"` Executor string `gorm:"column:executor;type:varchar(32);comment:执行人"` ExecutedAt time.Time `gorm:"column:executed_at;comment:执行时间"` ExecutionFeedback string `gorm:"column:execution_feedback;type:text;comment:执行反馈(JSON格式)"` CreatedAt time.Time `gorm:"column:created_at;not null;default:CURRENT_TIMESTAMP;comment:创建时间"` UpdatedAt time.Time `gorm:"column:updated_at;not null;default:CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP;comment:更新时间"` TenantId string `gorm:"column:tenant_id;type:varchar(8);comment:租户ID"` } func (DecisionTask) TableName() string { return "decision_task" }