From 6e887d44cbda34150c0633214bc468e9141e5fab Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Tue, 29 Aug 2023 17:48:52 +0800 Subject: [PATCH] fix --- .../internal/logic/ws_render_image.go | 8 +++---- utils/websocket_data/render_data.go | 22 +++++++++---------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/server/websocket/internal/logic/ws_render_image.go b/server/websocket/internal/logic/ws_render_image.go index f8431c8e..4b719410 100644 --- a/server/websocket/internal/logic/ws_render_image.go +++ b/server/websocket/internal/logic/ws_render_image.go @@ -111,18 +111,18 @@ func (w *wsConnectItem) consumeRenderCache(data []byte) { renderImageData.RenderData.GuestId = w.guestId var productSize *gmodel.FsProductSize //指定尺寸 - if renderImageData.RenderData.SizeId > 0 { - productSize, err = w.logic.svcCtx.AllModels.FsProductSize.FindOneByIdProductId(w.logic.ctx, renderImageData.RenderData.SizeId, renderImageData.RenderData.ProductId) + if renderImageData.RenderData.ProductSizeId > 0 { + productSize, err = w.logic.svcCtx.AllModels.FsProductSize.FindOneByIdProductId(w.logic.ctx, renderImageData.RenderData.ProductSizeId, renderImageData.RenderData.ProductId) } else { //获取产品第一个尺寸 productSize, err = w.logic.svcCtx.AllModels.FsProductSize.GetProductFirstSize(w.logic.ctx, renderImageData.RenderData.ProductId) } if err != nil { if errors.Is(err, gorm.ErrRecordNotFound) { - w.renderErrResponse(renderImageData.RenderId, renderImageData.RenderData.TemplateTag, "", "product first size is not exists", w.userId, w.guestId, 0, 0, renderImageData.RenderData.SizeId, 0) + w.renderErrResponse(renderImageData.RenderId, renderImageData.RenderData.TemplateTag, "", "product first size is not exists", w.userId, w.guestId, 0, 0, renderImageData.RenderData.ProductSizeId, 0) logx.Error("product size is not found") return } - w.renderErrResponse(renderImageData.RenderId, renderImageData.RenderData.TemplateTag, "", "failed to get product first size", w.userId, w.guestId, 0, 0, renderImageData.RenderData.SizeId, 0) + w.renderErrResponse(renderImageData.RenderId, renderImageData.RenderData.TemplateTag, "", "failed to get product first size", w.userId, w.guestId, 0, 0, renderImageData.RenderData.ProductSizeId, 0) logx.Error("failed to get product size:", err) return } diff --git a/utils/websocket_data/render_data.go b/utils/websocket_data/render_data.go index b9c9559e..013ee5b6 100644 --- a/utils/websocket_data/render_data.go +++ b/utils/websocket_data/render_data.go @@ -15,17 +15,17 @@ type RenderImageReqMsg struct { RenderData RenderData `json:"render_data"` } type RenderData struct { - TemplateTag string `json:"template_tag"` //模板标签(必须) - ProductId int64 `json:"product_id"` //产品id(必须) - Website string `json:"website"` //网站(可选) - Slogan string `json:"slogan"` //slogan(可选) - Address string `json:"address"` //地址(可选) - Phone string `json:"phone"` //电话(可选) - Qrcode string `json:"qrcode"` //二维码(可选) - SizeId int64 `json:"size_id"` //尺寸id(可选) - UserId int64 `json:"user_id"` //用户id(websocket连接建立再赋值) - GuestId int64 `json:"guest_id"` //游客id(websocket连接建立再赋值) - Logo string `json:"logo"` //log资源地址(websocket连接建立再赋值) + TemplateTag string `json:"template_tag"` //模板标签(必须) + ProductId int64 `json:"product_id"` //产品id(必须) + Website string `json:"website"` //网站(可选) + Slogan string `json:"slogan"` //slogan(可选) + Address string `json:"address"` //地址(可选) + Phone string `json:"phone"` //电话(可选) + Qrcode string `json:"qrcode"` //二维码(可选) + ProductSizeId int64 `json:"product_size_id"` //尺寸id(可选) + UserId int64 `json:"user_id"` //用户id(websocket连接建立再赋值) + GuestId int64 `json:"guest_id"` //游客id(websocket连接建立再赋值) + Logo string `json:"logo"` //log资源地址(websocket连接建立再赋值) } // websocket发送渲染完的数据