feat: project public runs to multitable outbox
This commit is contained in:
@@ -9,6 +9,8 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"git.iwork-ai.com/xdc/iqudo-top1/internal/audit"
|
||||
"git.iwork-ai.com/xdc/iqudo-top1/internal/auth"
|
||||
"git.iwork-ai.com/xdc/iqudo-top1/internal/model"
|
||||
"git.iwork-ai.com/xdc/iqudo-top1/internal/response"
|
||||
"git.iwork-ai.com/xdc/iqudo-top1/internal/resultcontract"
|
||||
@@ -104,7 +106,10 @@ func (h *Handler) PublicStart(c *gin.Context) {
|
||||
return err
|
||||
}
|
||||
payload, _ := json.Marshal(gin.H{"source": "public_sdk", "mapped_field_keys": sortedKeys(normalized), "matched_rule_keys": matchedRules})
|
||||
return tx.Create(&model.SOPRunEvent{TenantID: scenario.TenantID, RunID: run.ID, NodeKey: run.CurrentNodeKey, Action: "start", Payload: datatypes.JSON(payload)}).Error
|
||||
if err := tx.Create(&model.SOPRunEvent{TenantID: scenario.TenantID, RunID: run.ID, NodeKey: run.CurrentNodeKey, Action: "start", Payload: datatypes.JSON(payload)}).Error; err != nil {
|
||||
return err
|
||||
}
|
||||
return audit.RecordTx(tx, auth.Principal{TenantID: scenario.TenantID, UserID: scenario.CreatedBy}, "start", "sop_run", run.ID, gin.H{"source": "public_sdk"})
|
||||
})
|
||||
if err != nil {
|
||||
if body.ExternalRef != "" {
|
||||
@@ -178,7 +183,13 @@ func (h *Handler) PublicSubmit(c *gin.Context) {
|
||||
if err := tx.Create(&model.SOPRunEvent{TenantID: run.TenantID, RunID: run.ID, NodeKey: run.CurrentNodeKey, Action: "answer", Payload: datatypes.JSON(payload)}).Error; err != nil {
|
||||
return err
|
||||
}
|
||||
return advancePublicRun(tx, &run)
|
||||
if err := advancePublicRun(tx, &run); err != nil {
|
||||
return err
|
||||
}
|
||||
if run.Status == "completed" {
|
||||
return audit.RecordTx(tx, auth.Principal{TenantID: run.TenantID, UserID: run.OperatorID}, "finish", "sop_run", run.ID, gin.H{"source": "public_sdk", "result": run.Result})
|
||||
}
|
||||
return nil
|
||||
})
|
||||
if err != nil {
|
||||
h.respondPublicMutationError(c, err, "提交节点失败")
|
||||
@@ -275,7 +286,7 @@ func (h *Handler) PublicFinish(c *gin.Context) {
|
||||
return err
|
||||
}
|
||||
run.Status, run.Result, run.FinalResult, run.CompletedAt = "completed", body.Result, datatypes.JSON(finalRaw), completedAt
|
||||
return nil
|
||||
return audit.RecordTx(tx, auth.Principal{TenantID: run.TenantID, UserID: run.OperatorID}, "finish", "sop_run", run.ID, gin.H{"source": "public_sdk", "result": body.Result})
|
||||
})
|
||||
if err != nil {
|
||||
h.respondPublicMutationError(c, err, "结束执行失败")
|
||||
|
||||
Reference in New Issue
Block a user