From ccf1ae19b27d460f3b23d52be5b763dd103a6eb2 Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Tue, 11 Jul 2023 18:37:36 +0800 Subject: [PATCH] fix --- proxyserver/main.go | 2 +- .../internal/logic/getproductinfologic.go | 26 ++++++++++++++++--- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/proxyserver/main.go b/proxyserver/main.go index ae406159..8e73eb6e 100644 --- a/proxyserver/main.go +++ b/proxyserver/main.go @@ -16,7 +16,7 @@ var Backends []*Backend func main() { rootDir := "../server" // Change this to your root directory - vueBuild := "/home/eson/workspace/fusenpack-vue-created" + vueBuild := "/home/ldm/workdir/fusenpack-vue-created" apiURL, err := url.Parse("http://localhost:9900") if err != nil { panic(err) diff --git a/server/product/internal/logic/getproductinfologic.go b/server/product/internal/logic/getproductinfologic.go index 3ef3b921..7ec71273 100644 --- a/server/product/internal/logic/getproductinfologic.go +++ b/server/product/internal/logic/getproductinfologic.go @@ -10,6 +10,7 @@ import ( "fusenapi/utils/auth" "fusenapi/utils/basic" "fusenapi/utils/color_list" + "fusenapi/utils/encryption_decryption" "fusenapi/utils/format" "fusenapi/utils/image" "fusenapi/utils/step_price" @@ -380,7 +381,17 @@ func (l *GetProductInfoLogic) GetProductInfo(req *types.GetProductInfoReq, useri if req.HaveCloudRendering == true { renderDesign = l.getRenderDesign(req.ClientNo) } - return resp.SetStatusWithMessage(basic.CodeOK, "success", types.GetProductInfoRsp{ + //查询是否是加密的(不太合理) + encryptWebsetting, err := l.svcCtx.AllModels.FsWebSet.FindValueByKey(l.ctx, "is_encrypt") + if err != nil { + if errors.Is(err, gorm.ErrRecordNotFound) { + return resp.SetStatusWithMessage(basic.CodeDbRecordNotFoundErr, "web setting is_encrypt is not exists") + } + logx.Error(err) + return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "failed to get web setting") + } + //不加密 + rspData := types.GetProductInfoRsp{ Id: productInfo.Id, Type: *productInfo.Type, Title: *productInfo.Title, @@ -396,8 +407,17 @@ func (l *GetProductInfoLogic) GetProductInfo(req *types.GetProductInfoReq, useri LastDesign: lastDesign, RenderDesign: renderDesign, Colors: color_list.GetColor(), - }) - + } + if encryptWebsetting.Value == nil || *encryptWebsetting.Value == "0" { + return resp.SetStatusWithMessage(basic.CodeOK, "success", rspData) + } + bytesData, _ := json.Marshal(rspData) + enData, err := encryption_decryption.CBCEncrypt(string(bytesData)) + if err != nil { + logx.Error(err) + return resp.SetStatusWithMessage(basic.CodeServiceErr, "failed to encryption response data") + } + return resp.SetStatusWithMessage(basic.CodeOK, "success", enData) } // 获取渲染设计