From aab066ab2d90d235848f67d4aac3b15c8f778b3c Mon Sep 17 00:00:00 2001 From: zhangqian <zhangqian@123.com> Date: 星期六, 19 八月 2023 18:37:07 +0800 Subject: [PATCH] 增加获取完成进度接口 --- api/v1/task.go | 20 +++++++++++++++----- 1 files changed, 15 insertions(+), 5 deletions(-) diff --git a/api/v1/task.go b/api/v1/task.go index 9915449..17c8dba 100644 --- a/api/v1/task.go +++ b/api/v1/task.go @@ -41,7 +41,7 @@ // @Summary 浠诲姟寮�濮� // @Produce application/json // @Param id path int true "宸ュ簭id" -// @Success 200 {object} contextx.Response{data=[]response.ProcessParams} "鎴愬姛" +// @Success 200 {object} contextx.Response{data=response.ProcessParamsResponse} "鎴愬姛" // @Router /v1/task/start/{id} [get] func (slf *TaskApi) TaskStart(c *gin.Context) { ctx, ok := contextx.NewContext(c, nil) @@ -59,6 +59,12 @@ ctx.Fail(code) return } + + if procedure.Status != model.ProcedureStatusUnFinished { + ctx.FailWithMsg(ecode.ParamsErr, "璇ュ伐搴忓凡缁撴潫") + return + } + order, err := service.NewTaskService().GetOrderByWorkOrderId(procedure.WorkOrderID) if err != nil { ctx.Fail(ecode.UnknownErr) @@ -77,18 +83,22 @@ if err != nil { logx.Errorf("TaskStart Notice GetProcessModel error: %v", err.Error()) - ctx.Fail(ecode.UnknownErr) + ctx.FailWithMsg(ecode.UnknownErr, "鏈幏鍙栧埌宸ヨ壓鍙傛暟") return } - processParamsArr := make([]*response.ProcessParams, 0, len(resp.ParamsMap)) + processParamsArr := make([]response.ProcessParams, 0, len(resp.ParamsMap)) for k, v := range resp.ParamsMap { - processParamsArr = append(processParamsArr, &response.ProcessParams{ + processParamsArr = append(processParamsArr, response.ProcessParams{ Key: k, Value: v, }) } + response := response.ProcessParamsResponse{ + Number: resp.Number, + Params: processParamsArr, + } logx.Infof("TaskStart Notice GetProcessModel: %+v", resp) - ctx.OkWithDetailed(processParamsArr) + ctx.OkWithDetailed(response) } // TaskFinish -- Gitblit v1.8.0