diff --git a/rpc.go b/rpc.go index 72f8c57..df13caf 100644 --- a/rpc.go +++ b/rpc.go @@ -246,6 +246,9 @@ func (r *request) Send(ctx *gin.Context, serviceFlag string, apiFlag string, par // 解析响应的业务数据 code, message, data = r.getCodeAndMessageAndData(apiConfig, responseBody) + if !r.codeIsSuccess(code, apiConfig.SuccessCodeList) { + return fmt.Errorf("业务状态码异常 : %v -> %v", code, message) + } return nil } @@ -356,3 +359,17 @@ func (r *request) getCodeAndMessageAndData(apiConfig *Api, responseBody []byte) } return code, message, data } + +// codeIsSuccess 判断业务状态码是否为成功 +// +// Author : go_developer@163.com<白茶清欢> +// +// Date : 18:27 2022/6/30 +func (r *request) codeIsSuccess(input string, successCodeList []string) bool { + for _, item := range successCodeList { + if item == input { + return true + } + } + return false +}