From cdbea17efeea7ae0a4781261c4b638a5f8c7f574 Mon Sep 17 00:00:00 2001 From: dengbiao Date: Wed, 20 Nov 2024 15:50:06 +0800 Subject: [PATCH] update --- app/hdl/hdl_demo.go | 9 +++++++-- app/lib/aes/check.go | 9 +++++++-- 2 files changed, 14 insertions(+), 4 deletions(-) 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) + } } } }