From 1b5e9623a02c60790332725e5df8d14d32af5e25 Mon Sep 17 00:00:00 2001 From: Hiven Date: Fri, 18 Aug 2023 19:37:11 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E5=90=88=E5=9B=BE=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- service/repositories/image_handle.go | 5 ++++- utils/hash/hash.go | 3 +-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/service/repositories/image_handle.go b/service/repositories/image_handle.go index d16e8704..54954862 100644 --- a/service/repositories/image_handle.go +++ b/service/repositories/image_handle.go @@ -92,7 +92,10 @@ func (l *defaultImageHandle) LogoCombine(ctx context.Context, in *LogoCombineReq hashKeyData.GuestId = 0 hashKeyData.UserId = 0 hashKeyData.LogoUrl = *userMaterialInfo.ResourceUrl - var resourceId string = hash.JsonHashKey(hashKeyData) + var hashKeyDataMap map[string]interface{} + hashKeyDataB, _ := json.Marshal(hashKeyData) + json.Unmarshal(hashKeyDataB, &hashKeyDataMap) + var resourceId string = hash.JsonHashKey(hashKeyDataMap) fmt.Println("hashKeyData:", hashKeyData) diff --git a/utils/hash/hash.go b/utils/hash/hash.go index 968decf1..228c8328 100644 --- a/utils/hash/hash.go +++ b/utils/hash/hash.go @@ -5,13 +5,12 @@ import ( "crypto/sha256" "encoding/json" "fmt" - "reflect" "sort" ) func JsonHashKey(v interface{}) string { - if reflect.TypeOf(v).Kind() == reflect.String { + if _, ok := v.(string); ok { var obj interface{} err := json.Unmarshal([]byte(v.(string)), &obj) if err == nil {