From 9d8ae61a560c269b7c958d1dd3fbe2444f3a27b4 Mon Sep 17 00:00:00 2001 From: momo <1012651275@qq.com> Date: Mon, 30 Oct 2023 16:19:14 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E4=B8=8A=E4=BC=A0logo--debug=E6=A8=A1?= =?UTF-8?q?=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../internal/logic/userlogodatasetlogic.go | 4 +- .../internal/logic/userlogosetlogic.go | 41 +++++++++++++------ 2 files changed, 30 insertions(+), 15 deletions(-) diff --git a/server/home-user-auth/internal/logic/userlogodatasetlogic.go b/server/home-user-auth/internal/logic/userlogodatasetlogic.go index f2eec55b..80680ae4 100644 --- a/server/home-user-auth/internal/logic/userlogodatasetlogic.go +++ b/server/home-user-auth/internal/logic/userlogodatasetlogic.go @@ -88,8 +88,8 @@ func (l *UserLogoDataSetLogic) UserLogoDataSet(req *types.UserLogoDataSetReq, us userMaterialMetadata = *logoData.Metadata } - // 新增素材 - var module = "logo" + // 新增素材--预备logo + var module = "logo-prepare" var nowTime = time.Now().UTC() var resourceId = s3url_to_s3id.GetS3ResourceIdFormUrl(*logoData.ResourceUrl) // 新增素材记录 diff --git a/server/home-user-auth/internal/logic/userlogosetlogic.go b/server/home-user-auth/internal/logic/userlogosetlogic.go index 27b6a822..c6b36255 100644 --- a/server/home-user-auth/internal/logic/userlogosetlogic.go +++ b/server/home-user-auth/internal/logic/userlogosetlogic.go @@ -96,6 +96,10 @@ func (l *UserLogoSetLogic) UserLogoSet(req *types.UserLogoSetReq, userinfo *auth logc.Errorf(l.ctx, "FsUserMaterial FindOne err:%+v", err) return resp.SetStatus(basic.CodeLogoSetCategory, "logo not find") } + var materialModule string + if *userMaterialInfo.Module == "logo-prepare" { + materialModule = "logo" + } err = l.svcCtx.MysqlConn.WithContext(l.ctx).Transaction(func(tx *gorm.DB) error { var metadataMapOldUserMaterial map[string]interface{} @@ -108,21 +112,32 @@ func (l *UserLogoSetLogic) UserLogoSet(req *types.UserLogoSetReq, userinfo *auth } var logoCategoryId int64 // 更新merchant_category - if req.SetLogoCategory == 1 { - var metadataChildUserMaterial = make(map[string]interface{}, 1) - metadataChildUserMaterial["merchant_category"] = req.CategoryId - metadataMapUserMaterial, err := metadata.SetMetadata(metadataChildUserMaterial, metadataMapOldUserMaterial) - if err != nil { - logc.Errorf(l.ctx, "userMaterialInfo Metadata SetMetadata err:%+v", err) - return err + if req.SetLogoCategory == 1 || materialModule != "" { + var updateSelect []string + updateSelect = append(updateSelect, "utime") + if req.SetLogoCategory == 1 { + var metadataChildUserMaterial = make(map[string]interface{}, 1) + metadataChildUserMaterial["merchant_category"] = req.CategoryId + metadataMapUserMaterial, err := metadata.SetMetadata(metadataChildUserMaterial, metadataMapOldUserMaterial) + if err != nil { + logc.Errorf(l.ctx, "userMaterialInfo Metadata SetMetadata err:%+v", err) + return err + } + metadataBUserMaterial, err := json.Marshal(metadataMapUserMaterial) + if err != nil { + logc.Errorf(l.ctx, "userMaterialInfo Metadata err:%+v", err) + return err + } + userMaterialInfo.Metadata = &metadataBUserMaterial + updateSelect = append(updateSelect, "metadata") } - metadataBUserMaterial, err := json.Marshal(metadataMapUserMaterial) - if err != nil { - logc.Errorf(l.ctx, "userMaterialInfo Metadata err:%+v", err) - return err + + if materialModule != "" { + userMaterialInfo.Module = &materialModule + updateSelect = append(updateSelect, "module") } - userMaterialInfo.Metadata = &metadataBUserMaterial - resUpdates := tx.Model(&gmodel.FsUserMaterial{}).Select("metadata", "utime").Where("id = ?", req.LogoSelectedId).Updates(&userMaterialInfo) + + resUpdates := tx.Model(&gmodel.FsUserMaterial{}).Select(updateSelect).Where("id = ?", req.LogoSelectedId).Updates(&userMaterialInfo) err = resUpdates.Error if err != nil { if err != gorm.ErrRecordNotFound {