diff --git a/app/hdl/hdl_demo.go b/app/hdl/hdl_demo.go index 5b8ebdb..975a335 100644 --- a/app/hdl/hdl_demo.go +++ b/app/hdl/hdl_demo.go @@ -102,14 +102,19 @@ func CreateSign(c *gin.Context) { if string(body) != "" { aesStr = aes.AesEncryptByECB(md.AesKey, string(body)) - var bodyParams = map[string]string{} + var bodyParams = map[string]interface{}{} err = json.Unmarshal(body, &bodyParams) if err != nil { e.OutErr(c, e.ERR, err.Error()) return } for key, value := range bodyParams { - query[key] = value + // 使用类型断言判断是否为 string 类型 + if _, ok := value.(string); ok { + query[key] = value.(string) + } else { + query[key] = utils.SerializeStr(value) + } } } } diff --git a/app/lib/aes/check.go b/app/lib/aes/check.go index d12f3ca..5b470d4 100644 --- a/app/lib/aes/check.go +++ b/app/lib/aes/check.go @@ -42,13 +42,18 @@ func CheckSign(c *gin.Context) error { if str != "" { c.Request.Body = ioutil.NopCloser(bytes.NewBuffer([]byte(str))) - var bodyParams = map[string]string{} + var bodyParams = map[string]interface{}{} err = json.Unmarshal([]byte(str), &bodyParams) if err != nil { return err } for key, value := range bodyParams { - query[key] = value + // 使用类型断言判断是否为 string 类型 + if _, ok := value.(string); ok { + query[key] = value.(string) + } else { + query[key] = utils.SerializeStr(value) + } } } }