From 640560acf6efedd259c8b0970b4007fe98709268 Mon Sep 17 00:00:00 2001 From: momo <1012651275@qq.com> Date: Tue, 19 Sep 2023 14:50:54 +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 --- .../internal/logic/userlogosetlogic.go | 49 ++++++++----------- service/repositories/image_handle.go | 9 ++-- 2 files changed, 25 insertions(+), 33 deletions(-) diff --git a/server/home-user-auth/internal/logic/userlogosetlogic.go b/server/home-user-auth/internal/logic/userlogosetlogic.go index f6d4df4b..ee6ec9f1 100644 --- a/server/home-user-auth/internal/logic/userlogosetlogic.go +++ b/server/home-user-auth/internal/logic/userlogosetlogic.go @@ -137,38 +137,31 @@ func (l *UserLogoSetLogic) UserLogoSet(req *types.UserLogoSetReq, userinfo *auth var metadataChildUserInfo = make(map[string]interface{}, 1) - _, userInfoLogoSelectedEx := metadataMapOldUserInfo["logo_selected"] - if !userInfoLogoSelectedEx { - userMaterialTemplateTagData, userMaterialTemplateTagEx := metadataMapOldUserMaterial["template_tag"] - if !userMaterialTemplateTagEx { - logc.Errorf(l.ctx, "userMaterialInfo Metadata template_tag err:%+v", err) - return err - } - userMaterialTemplateIdTagIdData, userMaterialTemplateTagIdEx := metadataMapOldUserMaterial["template_tag_id"] - if !userMaterialTemplateTagIdEx { - logc.Errorf(l.ctx, "userMaterialInfo Metadata template_tag_id err:%+v", err) - return err - } - userMaterialTemplateIdTagIds := userMaterialTemplateIdTagIdData.([]interface{}) + userMaterialTemplateTagData, userMaterialTemplateTagEx := metadataMapOldUserMaterial["template_tag"] + if !userMaterialTemplateTagEx { + logc.Errorf(l.ctx, "userMaterialInfo Metadata template_tag err:%+v", err) + return err + } + userMaterialTemplateIdTagIdData, userMaterialTemplateTagIdEx := metadataMapOldUserMaterial["template_tag_id"] + if !userMaterialTemplateTagIdEx { + logc.Errorf(l.ctx, "userMaterialInfo Metadata template_tag_id err:%+v", err) + return err + } + userMaterialTemplateIdTagIds := userMaterialTemplateIdTagIdData.([]interface{}) - userMaterialTemplateIdTagId := userMaterialTemplateIdTagIds[0].(string) + userMaterialTemplateIdTagId := userMaterialTemplateIdTagIds[0].(string) - userMaterialTemplateTag := userMaterialTemplateTagData.(map[string]interface{}) - userMaterialTemplateTagIndex := userMaterialTemplateTag[userMaterialTemplateIdTagId] + userMaterialTemplateTag := userMaterialTemplateTagData.(map[string]interface{}) + userMaterialTemplateTagIndex := userMaterialTemplateTag[userMaterialTemplateIdTagId] - templateTagSelected := make(map[string]interface{}, 3) - templateTagSelected["color"] = userMaterialTemplateTagIndex - templateTagSelected["template_tag"] = userMaterialTemplateIdTagId - templateTagSelected["selected_index"] = 0 + templateTagSelected := make(map[string]interface{}, 3) + templateTagSelected["color"] = userMaterialTemplateTagIndex + templateTagSelected["template_tag"] = userMaterialTemplateIdTagId + templateTagSelected["selected_index"] = 0 - metadataChildUserInfo["logo_selected"] = map[string]interface{}{ - "logo_selected_id": req.LogoSelectedId, - "template_tag_selected": templateTagSelected, - } - } else { - metadataChildUserInfo["logo_selected"] = map[string]interface{}{ - "logo_selected_id": req.LogoSelectedId, - } + metadataChildUserInfo["logo_selected"] = map[string]interface{}{ + "logo_selected_id": req.LogoSelectedId, + "template_tag_selected": templateTagSelected, } metadataMapUserInfo, err := metadata.SetMetadata(metadataChildUserInfo, metadataMapOldUserInfo) diff --git a/service/repositories/image_handle.go b/service/repositories/image_handle.go index fe8e486c..4dd94fd7 100644 --- a/service/repositories/image_handle.go +++ b/service/repositories/image_handle.go @@ -102,13 +102,13 @@ func (l *defaultImageHandle) LogoInfo(ctx context.Context, in *LogoInfoReq) (*Lo LogoSelectedId int64 `json:"logo_selected_id"` } `json:"logo_selected"` } + userInfo.Id = 0 if userInfo.Id == 0 { userMaterialInfo, err = userMaterialModel.FindLatestOne(ctx, in.UserId, in.GuestId) - if err != gorm.ErrRecordNotFound { + if err != nil && err != gorm.ErrRecordNotFound { logc.Errorf(ctx, "FsUserMaterial FindLatestOne err:%+v", err) return nil, err } - // var userMaterialInfoMetadata map[string]interface{} } else { if userInfo.Metadata != nil { err = json.Unmarshal([]byte(*userInfo.Metadata), &metadataUserInfo) @@ -150,9 +150,8 @@ func (l *defaultImageHandle) LogoInfo(ctx context.Context, in *LogoInfoReq) (*Lo logoUrl = userMaterialInfo.ResourceUrl } return &LogoInfoRes{ - Metadata: metadata, - LogoUrl: logoUrl, - LogoSelected: metadataUserInfo.LogoSelected, + Metadata: metadata, + LogoUrl: logoUrl, }, nil }