From ace57c52f41f32f6e7293c526bd575589b69189c Mon Sep 17 00:00:00 2001 From: momo <1012651275@qq.com> Date: Thu, 26 Oct 2023 16:46:14 +0800 Subject: [PATCH] =?UTF-8?q?fix:upload=E8=AE=BE=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../internal/logic/userlogodatasetlogic.go | 25 ++++++++++++++++++- .../internal/logic/userlogosetlogic.go | 10 ++++++-- 2 files changed, 32 insertions(+), 3 deletions(-) diff --git a/server/home-user-auth/internal/logic/userlogodatasetlogic.go b/server/home-user-auth/internal/logic/userlogodatasetlogic.go index a8e34190..f2eec55b 100644 --- a/server/home-user-auth/internal/logic/userlogodatasetlogic.go +++ b/server/home-user-auth/internal/logic/userlogodatasetlogic.go @@ -2,7 +2,9 @@ package logic import ( "errors" + "fmt" "fusenapi/model/gmodel" + "fusenapi/service/repositories" "fusenapi/utils/auth" "fusenapi/utils/basic" "fusenapi/utils/s3url_to_s3id" @@ -65,6 +67,27 @@ func (l *UserLogoDataSetLogic) UserLogoDataSet(req *types.UserLogoDataSetReq, us } return resp.SetStatus(basic.CodeApiErr) } + + var userMaterialMetadata []byte + if logoData.Metadata == nil { + var resultStr string + resLogoStandard, err := l.svcCtx.Repositories.ImageHandle.LogoInfoSet(l.ctx, &repositories.LogoInfoSetReq{ + LogoUrl: *logoData.ResourceUrl, + Version: l.svcCtx.Config.BLMService.Version, + Debug: userinfo.Debug, + }) + + if err != nil { + logx.Error(err) + basic.CodeServiceErr.Message = fmt.Sprintf("算法请求--LOGO信息--错误:%+v", err) + return resp.SetStatus(basic.CodeServiceErr, fmt.Sprintf("算法请求--LOGO信息--错误:%+v", err)) + } + resultStr = resLogoStandard.Res + userMaterialMetadata = []byte(resultStr) + } else { + userMaterialMetadata = *logoData.Metadata + } + // 新增素材 var module = "logo" var nowTime = time.Now().UTC() @@ -76,7 +99,7 @@ func (l *UserLogoDataSetLogic) UserLogoDataSet(req *types.UserLogoDataSetReq, us GuestId: &guestId, ResourceId: &resourceId, ResourceUrl: logoData.ResourceUrl, - Metadata: logoData.Metadata, + Metadata: &userMaterialMetadata, Ctime: &nowTime, } resCreate := l.svcCtx.MysqlConn.Create(&materialInfo) diff --git a/server/home-user-auth/internal/logic/userlogosetlogic.go b/server/home-user-auth/internal/logic/userlogosetlogic.go index 2aa57b56..1912e2e5 100644 --- a/server/home-user-auth/internal/logic/userlogosetlogic.go +++ b/server/home-user-auth/internal/logic/userlogosetlogic.go @@ -106,6 +106,7 @@ func (l *UserLogoSetLogic) UserLogoSet(req *types.UserLogoSetReq, userinfo *auth return err } } + var logoCategoryId int64 // 更新merchant_category if req.SetLogoCategory == 1 { var metadataChildUserMaterial = make(map[string]interface{}, 1) @@ -129,7 +130,7 @@ func (l *UserLogoSetLogic) UserLogoSet(req *types.UserLogoSetReq, userinfo *auth return err } } - + logoCategoryId = req.CategoryId } var module = "profile" if req.SetLogoSelected == 1 { @@ -182,11 +183,16 @@ func (l *UserLogoSetLogic) UserLogoSet(req *types.UserLogoSetReq, userinfo *auth templateTagSelected["template_tag"] = userMaterialTemplateIdTagId templateTagSelected["selected_index"] = 0 - metadataChildUserInfo["logo_selected"] = map[string]interface{}{ + var logoSelectedMap = map[string]interface{}{ "logo_selected_id": req.LogoSelectedId, "logo_url": userMaterialInfo.ResourceUrl, "template_tag_selected": templateTagSelected, } + if logoCategoryId != 0 { + logoSelectedMap["merchant_category"] = logoCategoryId + } + + metadataChildUserInfo["logo_selected"] = logoSelectedMap metadataMapUserInfo, err := metadata.SetMetadata(metadataChildUserInfo, metadataMapOldUserInfo) if err != nil {