package model import ( "approveflow/app/base" "encoding/json" ) // ApprovalReversal 审批反转表 type ApprovalReversal struct { InstanceID int64 `gorm:"type:bigint;index;not null" json:"instance_id"` // 关联的审批实例ID StepID int64 `gorm:"type:bigint;index;not null" json:"step_id"` // 关联的步骤ID StepKey string `gorm:"type:varchar(50);index;not null" json:"step_key"` // 关联的步骤ID ReversedStepKey string `gorm:"type:varchar(50);index;not null" json:"reversed_step_id"` // 反转的步骤ID FixAction string `gorm:"type:varchar(100);not null" json:"fix_action"` // 修正动作 Reason string `gorm:"type:text" json:"reason"` // 反转原因 base.Model } // FixAction 定义常量表示审批反转的修正动作 const ( FixActionReApproveAndUpdateData = "ReApproveAndUpdateData" FixActionReApprove = "ReApprove" // 重新审批 FixActionReassignApprover = "ReassignApprover" // 重新指定审批人 FixActionRollback = "Rollback" // 回滚到某个步骤 FixActionUpdateData = "UpdateData" // 更新审批数据 FixActionReopen = "Reopen" // 重新打开审批流程 ) func (reversal *ApprovalReversal) MarshalBinary() ([]byte, error) { return json.Marshal(reversal) } func (reversal *ApprovalReversal) UnmarshalBinary(data []byte) error { return json.Unmarshal(data, reversal) } func NewReversal(step *InstanceStep, reversedStep *InstanceStep, reason string, fixAction string) *ApprovalReversal { reversal := &ApprovalReversal{ StepID: step.ID, StepKey: step.Key, ReversedStepKey: reversedStep.Key, FixAction: fixAction, Reason: reason, } return reversal } // FixIssue 执行修正操作 func (reversal *ApprovalReversal) FixIssue(instance *ApprovalInstance, action, reason string) error { reversal.InstanceID = instance.ID reversal.FixAction = action reversal.Reason = reason // 根据修正动作进行修正逻辑 return nil }