Commit eb44aa60 authored by Cloud User's avatar Cloud User

update http api

parent 822fca34
...@@ -603,6 +603,7 @@ type ResponseJson struct { ...@@ -603,6 +603,7 @@ type ResponseJson struct {
TaskFee string `json:"task_fee"` TaskFee string `json:"task_fee"`
IsSuccess bool `json:"is_success"` IsSuccess bool `json:"is_success"`
TaskError string `json:"task_error"` TaskError string `json:"task_error"`
ResultCode int32 `json:"task_code"`
} }
func newCache(redisAddr, redisPass, mysqlIP, dbName, user, passwd string, port int) *cachedata.CacheData { func newCache(redisAddr, redisPass, mysqlIP, dbName, user, passwd string, port int) *cachedata.CacheData {
...@@ -1333,10 +1334,9 @@ func syncOrAsyncReturn(c *fiber.Ctx, resAsPb pbUpstream.TaskResponse, reqTaskId ...@@ -1333,10 +1334,9 @@ func syncOrAsyncReturn(c *fiber.Ctx, resAsPb pbUpstream.TaskResponse, reqTaskId
func Return(c *fiber.Ctx, resAsPb pbUpstream.TaskResponse) error { func Return(c *fiber.Ctx, resAsPb pbUpstream.TaskResponse) error {
if resAsPb.TaskIsSucceed { // if resAsPb.TaskIsSucceed {
// return c.Send(resAsPb.GetTaskResultBody())
return c.Send(resAsPb.GetTaskResultBody()) // }
}
//fmt.Println("syncMode-------------", syncMode) //fmt.Println("syncMode-------------", syncMode)
resAsJson := ResponseJson{ resAsJson := ResponseJson{
...@@ -1346,31 +1346,32 @@ func Return(c *fiber.Ctx, resAsPb pbUpstream.TaskResponse) error { ...@@ -1346,31 +1346,32 @@ func Return(c *fiber.Ctx, resAsPb pbUpstream.TaskResponse) error {
TaskFee: resAsPb.TaskFee, TaskFee: resAsPb.TaskFee,
IsSuccess: resAsPb.TaskIsSucceed, IsSuccess: resAsPb.TaskIsSucceed,
TaskError: resAsPb.TaskError, TaskError: resAsPb.TaskError,
//TaskResultCode: resAsPb.TaskResultCode,
} }
return c.JSON(resAsJson) return c.JSON(resAsJson)
} }
func redirectReturn(c *fiber.Ctx, resAsPb pbUpstream.TaskResponse) error { // func redirectReturn(c *fiber.Ctx, resAsPb pbUpstream.TaskResponse) error {
//c.Status(int(resAsPb.TaskResultCode)).Response().Header.SetL // //c.Status(int(resAsPb.TaskResultCode)).Response().Header.SetL
if resAsPb.TaskIsSucceed { // if resAsPb.TaskIsSucceed {
return c.Status(int(resAsPb.TaskResultCode)).Send(resAsPb.GetTaskResultBody()) // return c.Status(int(resAsPb.TaskResultCode)).Send(resAsPb.GetTaskResultBody())
} // }
//fmt.Println("syncMode-------------", syncMode) // //fmt.Println("syncMode-------------", syncMode)
resAsJson := ResponseJson{ // resAsJson := ResponseJson{
TaskId: resAsPb.TaskId, // TaskId: resAsPb.TaskId,
TaskResult: resAsPb.GetTaskResultBody(), // TaskResult: resAsPb.GetTaskResultBody(),
TaskUid: resAsPb.TaskUid, // TaskUid: resAsPb.TaskUid,
TaskFee: resAsPb.TaskFee, // TaskFee: resAsPb.TaskFee,
IsSuccess: resAsPb.TaskIsSucceed, // IsSuccess: resAsPb.TaskIsSucceed,
TaskError: resAsPb.TaskError, // TaskError: resAsPb.TaskError,
} // }
return c.Status(int(resAsPb.TaskResultCode)).JSON(resAsJson) // return c.Status(int(resAsPb.TaskResultCode)).JSON(resAsJson)
} // }
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