Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions api/dms/service/v1/data_export_workflow.go
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,11 @@ type WorkflowStep struct {
Reason string `json:"reason,omitempty"`
}

type ApproveDataExportWorkflowPayload struct {
// optional approval comment; empty / omitted means no comment
Reason string `json:"reason"`
}

// swagger:parameters ApproveDataExportWorkflow
type ApproveDataExportWorkflowReq struct {
// project id
Expand All @@ -325,6 +330,8 @@ type ApproveDataExportWorkflowReq struct {
// Required: true
// in:path
DataExportWorkflowUid string `param:"data_export_workflow_uid" json:"data_export_workflow_uid" validate:"required"`
// optional body; omit / empty payload / empty reason → ""
Payload ApproveDataExportWorkflowPayload `json:"payload"`
}

// swagger:parameters ExportDataExportWorkflow
Expand Down
20 changes: 17 additions & 3 deletions internal/apiserver/service/dms_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"path/filepath"
"strings"
"time"
"unicode/utf8"

"github.com/actiontech/dms/api"
aV1 "github.com/actiontech/dms/api/dms/service/v1"
Expand Down Expand Up @@ -3763,10 +3764,23 @@ func (ctl *DMSController) AddDataExportWorkflow(c echo.Context) error {
// default: body:GenericResp
func (ctl *DMSController) ApproveDataExportWorkflow(c echo.Context) error {
req := &aV1.ApproveDataExportWorkflowReq{}
err := bindAndValidateReq(c, req)
if nil != err {
return NewErrResp(c, err, apiError.BadRequestErr)
// 兼容旧客户端:无 body / ContentLength=0 时按空意见处理。
// path 参数与 body 同属 req,跳过 bind 时须从 Param 注入,避免空 uid 查库失败。
if c.Request().ContentLength != 0 {
err := bindAndValidateReq(c, req)
if nil != err {
return NewErrResp(c, err, apiError.BadRequestErr)
}
} else {
req.ProjectUid = c.Param("project_uid")
req.DataExportWorkflowUid = c.Param("data_export_workflow_uid")
}

reason := strings.TrimSpace(req.Payload.Reason)
if utf8.RuneCountInString(reason) > 255 {
return NewErrResp(c, fmt.Errorf("审批意见不能超过255个字符"), apiError.BadRequestErr)
}
req.Payload.Reason = reason

currentUserUid, err := jwt.GetUserUidStrFromContext(c)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion internal/dms/biz/data_export_workflow_ce.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func (d *DataExportWorkflowUsecase) GetDataExportWorkflow(ctx context.Context, w
return nil, errNotDataExportWorkflow
}

func (d *DataExportWorkflowUsecase) ApproveDataExportWorkflow(ctx context.Context, projectId, workflowId, userId string) error {
func (d *DataExportWorkflowUsecase) ApproveDataExportWorkflow(ctx context.Context, projectId, workflowId, userId, reason string) error {
return errNotDataExportWorkflow
}

Expand Down
2 changes: 1 addition & 1 deletion internal/dms/service/data_export_workflow.go
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ func (d *DMSService) ListDataExportTaskSQLs(ctx context.Context, req *dmsV1.List
}

func (d *DMSService) ApproveDataExportWorkflow(ctx context.Context, req *dmsV1.ApproveDataExportWorkflowReq, userId string) (err error) {
return d.DataExportWorkflowUsecase.ApproveDataExportWorkflow(ctx, req.ProjectUid, req.DataExportWorkflowUid, userId)
return d.DataExportWorkflowUsecase.ApproveDataExportWorkflow(ctx, req.ProjectUid, req.DataExportWorkflowUid, userId, req.Payload.Reason)
}

func (d *DMSService) RejectDataExportWorkflow(ctx context.Context, req *dmsV1.RejectDataExportWorkflowReq, userId string) (err error) {
Expand Down