Commit ff6354a4 authored by duanjinfei's avatar duanjinfei

update json marshal encoding

parent 5502292d
...@@ -39,9 +39,12 @@ type TaskResult struct { ...@@ -39,9 +39,12 @@ type TaskResult struct {
} }
type ApiResp struct { type ApiResp struct {
Code int32 `json:"code"` TaskId string `json:"task_id"`
Msg string `json:"msg"` TaskResult []byte `json:"task_result"`
Res interface{} `json:"res"` TaskUid string `json:"task_uid"`
TaskFee string `json:"task_fee"`
IsSuccess bool `json:"is_success"`
TaskError string `json:"task_error"`
} }
type HardwareRequire struct { type HardwareRequire struct {
......
...@@ -289,24 +289,23 @@ func (t *TaskHandler) ComputeTaskHandler(taskMsg *nodeManagerV1.PushTaskMessage) ...@@ -289,24 +289,23 @@ func (t *TaskHandler) ComputeTaskHandler(taskMsg *nodeManagerV1.PushTaskMessage)
} }
} }
if len(apiRes) > 1 { if len(apiRes) > 1 {
res := &models.ApiResp{ fileCacheBody := bytes.NewBuffer([]byte{})
Code: 200, encoder := json.NewEncoder(fileCacheBody)
Msg: "success",
Res: apiRes,
}
apiResBody := bytes.NewBuffer([]byte{})
encoder := json.NewEncoder(apiResBody)
encoder.SetEscapeHTML(false) encoder.SetEscapeHTML(false)
err := encoder.Encode(res) err := encoder.Encode(apiRes)
if err != nil { if err != nil {
log.WithError(err).Error("encoder Encode") log.WithError(err).Error("encoder Encode")
} }
//apiResBody, err := json.Marshal(res) res := &models.ApiResp{
//if err != nil { IsSuccess: true,
// log.WithError(err).Error("json marshal upload oss uri") TaskResult: fileCacheBody.Bytes(),
//} }
log.WithField("apiResBody", string(apiResBody.Bytes())).Info("model resp") apiResBody, err := json.Marshal(res)
taskExecResult.TaskRespBody = apiResBody.Bytes() if err != nil {
log.WithError(err).Error("json marshal upload oss uri")
}
log.WithField("apiResBody", string(apiResBody)).Info("model resp")
taskExecResult.TaskRespBody = apiResBody
} }
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment