回调
CI / changes (push) Successful in 37s
CI / ad (push) Successful in 30s
CI / admin (push) Successful in 22s
CI / bff (push) Successful in 39s
CI / chore (push) Successful in 20s
CI / equipment (push) Successful in 19s
CI / express (push) Successful in 17s
CI / product (push) Successful in 16s
CI / record (push) Successful in 17s
CI / sale (push) Successful in 16s
CI / task (push) Successful in 16s
CI / user (push) Successful in 17s
CI / wecom (push) Successful in 18s
CI / changes (push) Successful in 37s
CI / ad (push) Successful in 30s
CI / admin (push) Successful in 22s
CI / bff (push) Successful in 39s
CI / chore (push) Successful in 20s
CI / equipment (push) Successful in 19s
CI / express (push) Successful in 17s
CI / product (push) Successful in 16s
CI / record (push) Successful in 17s
CI / sale (push) Successful in 16s
CI / task (push) Successful in 16s
CI / user (push) Successful in 17s
CI / wecom (push) Successful in 18s
This commit is contained in:
@@ -2,6 +2,7 @@ package response
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"lone-services/pkg/utils"
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
@@ -16,6 +17,11 @@ type bodyWriter struct {
|
||||
buf bytes.Buffer
|
||||
}
|
||||
|
||||
type responseDataBack struct {
|
||||
ReturnCode string `json:"returnCode"`
|
||||
ReturnMsg string `json:"returnMsg"`
|
||||
}
|
||||
|
||||
type responseData struct {
|
||||
Code int32 `json:"code"`
|
||||
Data any `json:"data"`
|
||||
@@ -48,7 +54,21 @@ func Wrap(next http.HandlerFunc) http.HandlerFunc {
|
||||
return
|
||||
}
|
||||
}
|
||||
ctrl.OutPut(w, data.Code, unwrapJSONData(data.Data), data.Msg)
|
||||
if data.Code < utils.NumberOne {
|
||||
var back responseDataBack
|
||||
|
||||
if err := jsoniter.Unmarshal(raw, &back); err != nil {
|
||||
ctrl.Fail(w)
|
||||
return
|
||||
}
|
||||
if len(back.ReturnCode) < utils.NumberOne {
|
||||
ctrl.Fail(w)
|
||||
return
|
||||
}
|
||||
ctrl.OutPutBack(w, back)
|
||||
} else {
|
||||
ctrl.OutPut(w, data.Code, unwrapJSONData(data.Data), data.Msg)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user