From e4fb6ca4a7a545fe4c1bf16eac28d6a4829df3a2 Mon Sep 17 00:00:00 2001 From: momo <1012651275@qq.com> Date: Mon, 11 Sep 2023 15:02:17 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E5=90=88=E5=9B=BE,=E9=BB=98=E8=AE=A4?= =?UTF-8?q?=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../internal/logic/logocombinelogic.go | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/server/resource/internal/logic/logocombinelogic.go b/server/resource/internal/logic/logocombinelogic.go index b1d5cc11..8cfbef28 100644 --- a/server/resource/internal/logic/logocombinelogic.go +++ b/server/resource/internal/logic/logocombinelogic.go @@ -2,15 +2,18 @@ package logic import ( "fmt" + "fusenapi/model/gmodel" "fusenapi/service/repositories" "fusenapi/utils/auth" "fusenapi/utils/basic" + "fusenapi/utils/template_switch_info" "context" "fusenapi/server/resource/internal/svc" "fusenapi/server/resource/internal/types" + "github.com/zeromicro/go-zero/core/logc" "github.com/zeromicro/go-zero/core/logx" ) @@ -57,6 +60,35 @@ func (l *LogoCombineLogic) LogoCombine(req *types.LogoCombineReq, userinfo *auth // 否则,使用用户ID和用户键名格式 userId = userinfo.UserId } + // 获取默认 + if req.Address == "" || req.Phone == "" || req.Website == "" || req.Qrcode == "" { + // 没有查到,先根据模版id 查询模版数据 请求算法数据 + productTemplateV2Model := gmodel.NewFsProductTemplateV2Model(l.svcCtx.MysqlConn) + productTemplateV2Info, err := productTemplateV2Model.FindOne(l.ctx, req.TemplateId) + + if err != nil { + logc.Errorf(l.ctx, "productTemplateV2Model.FindOne:%v", err) + return resp.SetStatus(basic.CodeServiceErr, "模版不存在") + } + templateSwitchInfo, err := template_switch_info.GetTemplateSwitchInfo(req.TemplateId, productTemplateV2Info.TemplateInfo, *productTemplateV2Info.MaterialImg) + if err != nil { + logc.Errorf(l.ctx, "template_switch_info.GetTemplateSwitchInfo,err:%v", err) + return resp.SetStatus(basic.CodeServiceErr, "默认模版不存在") + } + if req.Address == "" && templateSwitchInfo.MaterialData.Address.IfShow { + req.Address = templateSwitchInfo.MaterialData.Address.DefaultValue + } + if req.Phone == "" && templateSwitchInfo.MaterialData.Phone.IfShow { + req.Phone = templateSwitchInfo.MaterialData.Phone.DefaultValue + } + if req.Website == "" && templateSwitchInfo.MaterialData.Website.IfShow { + req.Website = templateSwitchInfo.MaterialData.Website.DefaultValue + } + if req.Qrcode == "" && templateSwitchInfo.MaterialData.QRcode.IfShow { + req.Qrcode = templateSwitchInfo.MaterialData.QRcode.DefaultValue + } + } + res, err := l.svcCtx.Repositories.ImageHandle.LogoCombine(l.ctx, &repositories.LogoCombineReq{ UserId: userId, GuestId: guestId,