From d6c43e3e94ee6631a1ef212e2ca061f5147bf432 Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Fri, 8 Sep 2023 14:23:34 +0800 Subject: [PATCH] fix --- .../internal/logic/ws_render_image.go | 34 +++++++------------ 1 file changed, 13 insertions(+), 21 deletions(-) diff --git a/server/websocket/internal/logic/ws_render_image.go b/server/websocket/internal/logic/ws_render_image.go index 26976272..167d3831 100644 --- a/server/websocket/internal/logic/ws_render_image.go +++ b/server/websocket/internal/logic/ws_render_image.go @@ -110,29 +110,21 @@ func (w *wsConnectItem) renderImage(data []byte) { w.renderErrResponse(renderImageData.RenderId, renderImageData.RenderData.TemplateTag, "", "该产品不可定制", renderImageData.RenderData.ProductId, w.userId, w.guestId, 0, 0, 0, 0) return } - //获取上传最近的logo - userMaterial, err := w.logic.svcCtx.AllModels.FsUserMaterial.FindLatestOne(w.logic.ctx, w.userId, w.guestId) + //获取用户需要渲染logo + logoInfo, err := w.logic.svcCtx.Repositories.ImageHandle.LogoInfo(w.logic.ctx, &repositories.LogoInfoReq{ + UserId: w.userId, + GuestId: w.guestId, + }) if err != nil { - if !errors.Is(err, gorm.ErrRecordNotFound) { - w.renderErrResponse(renderImageData.RenderId, renderImageData.RenderData.TemplateTag, "", "获取用户上传logo素材失败", renderImageData.RenderData.ProductId, w.userId, w.guestId, 0, 0, 0, 0) - logx.Error("failed to get user logo") - return - } - //使用默认logo(id=0) - userMaterialDefault, err := w.logic.svcCtx.AllModels.FsUserMaterial.FindOneById(w.logic.ctx, 0) - if err != nil { - if errors.Is(err, gorm.ErrRecordNotFound) { - w.renderErrResponse(renderImageData.RenderId, renderImageData.RenderData.TemplateTag, "", "默认logo不存在", renderImageData.RenderData.ProductId, w.userId, w.guestId, 0, 0, 0, 0) - return - } - w.renderErrResponse(renderImageData.RenderId, renderImageData.RenderData.TemplateTag, "", "获取默认logo失败", renderImageData.RenderData.ProductId, w.userId, w.guestId, 0, 0, 0, 0) - logx.Error("default logo is not exists") - return - } - renderImageData.RenderData.Logo = *userMaterialDefault.ResourceUrl - } else { - renderImageData.RenderData.Logo = *userMaterial.ResourceUrl + w.renderErrResponse(renderImageData.RenderId, renderImageData.RenderData.TemplateTag, "", "获取用户logo素材错误", renderImageData.RenderData.ProductId, w.userId, w.guestId, 0, 0, 0, 0) + logx.Error(err) + return } + if logoInfo == nil || logoInfo.LogoUrl == nil { + w.renderErrResponse(renderImageData.RenderId, renderImageData.RenderData.TemplateTag, "", "用户logo素材url是空的", renderImageData.RenderData.ProductId, w.userId, w.guestId, 0, 0, 0, 0) + return + } + renderImageData.RenderData.Logo = *logoInfo.LogoUrl //用户id赋值 renderImageData.RenderData.UserId = w.userId renderImageData.RenderData.GuestId = w.guestId