升级validate pkg

This commit is contained in:
2025-04-28 12:46:18 +08:00
parent 19992ab41c
commit db679f05e9
3 changed files with 21 additions and 10 deletions

View File

@ -95,18 +95,19 @@ func (c *client) Request() *Response {
Errmsg: "",
})
}
resByte, err := validate.Run(respByte, fieldList)
validateRes, err := validate.Run(respByte, fieldList)
if nil != err {
c.resp.ErrorCode = "-500"
c.resp.ErrorMessage = err.Error()
return c.resp
}
c.resp.Raw = respByte // 原始返回数据
serialize.JSON.UnmarshalWithNumberIgnoreError(resByte, &c.resp.DataMap) // map结果
c.resp.Raw = respByte // 原始返回数据
c.resp.DataMap, _ = validateRes.Map("json")
// serialize.JSON.UnmarshalWithNumberIgnoreError(resByte, &c.resp.DataMap) // map结果
if nil != c.receiver {
// 解析到receiver
if err = serialize.JSON.UnmarshalWithNumber(resByte, c.receiver); nil != err {
if err = validateRes.Transform("json", c.receiver); nil != err {
c.resp.ErrorCode = "-500"
c.resp.ErrorMessage = err.Error()
return c.resp
@ -236,7 +237,7 @@ func (c *client) buildRequestParams(apiCfg *RequestConfigGroupItem) (map[string]
return nil, err
}
var d map[string]map[string]any
if err = serialize.JSON.UnmarshalWithNumber(buildRes, &d); nil != err {
if err = buildRes.Transform("json", &d); nil != err {
return nil, err
}
return d, err