From c28888c12182d5b76906236ac709558998bd6ac8 Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Tue, 29 Aug 2023 17:40:09 +0800 Subject: [PATCH 1/3] fix --- server/websocket/internal/logic/ws_render_image.go | 4 ++-- utils/websocket_data/render_data.go | 7 ++++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/server/websocket/internal/logic/ws_render_image.go b/server/websocket/internal/logic/ws_render_image.go index 99cc8a6e..f8431c8e 100644 --- a/server/websocket/internal/logic/ws_render_image.go +++ b/server/websocket/internal/logic/ws_render_image.go @@ -198,8 +198,8 @@ func (w *wsConnectItem) consumeRenderCache(data []byte) { UploadCombineImageTakesTime: fmt.Sprintf("%dms", res.DiffTimeUploadFile), }, })) - //如果是传入了指定尺寸,则不走unity - if renderImageData.RenderData.SizeId > 0 { + //如果指定指定只返回刀版图 + if renderImageData.OnlyReturnCombineImage { logx.Info("云渲染传入size id则不走unity云渲染,只返回刀版图,render_id:", renderImageData.RenderId) return } diff --git a/utils/websocket_data/render_data.go b/utils/websocket_data/render_data.go index a0ba0e98..b9c9559e 100644 --- a/utils/websocket_data/render_data.go +++ b/utils/websocket_data/render_data.go @@ -10,8 +10,9 @@ type DataTransferData struct { // websocket接受要云渲染处理的数据 type RenderImageReqMsg struct { - RenderId string `json:"render_id"` //渲染id - RenderData RenderData `json:"render_data"` + RenderId string `json:"render_id"` //渲染id + OnlyReturnCombineImage bool `json:"only_return_combine_image"` //是否只返回刀版图 + RenderData RenderData `json:"render_data"` } type RenderData struct { TemplateTag string `json:"template_tag"` //模板标签(必须) @@ -21,7 +22,7 @@ type RenderData struct { Address string `json:"address"` //地址(可选) Phone string `json:"phone"` //电话(可选) Qrcode string `json:"qrcode"` //二维码(可选) - SizeId int64 `json:"size_id"` //尺寸id(可选,传值大于0则值返回刀版图不参与unity云渲染) + 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连接建立再赋值) 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 2/3] 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发送渲染完的数据 From a560098b3467ca9cdc1134932dbc44231e8091f7 Mon Sep 17 00:00:00 2001 From: momo <1012651275@qq.com> Date: Tue, 29 Aug 2023 18:00:37 +0800 Subject: [PATCH 3/3] =?UTF-8?q?fix:=E8=B0=83=E6=95=B4=E5=90=88=E5=9B=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/resource/etc/resource.yaml | 4 +- service/repositories/image_handle.go | 77 ++++++++++++++++++++-------- 2 files changed, 57 insertions(+), 24 deletions(-) diff --git a/server/resource/etc/resource.yaml b/server/resource/etc/resource.yaml index 6c11c903..1eede2ad 100644 --- a/server/resource/etc/resource.yaml +++ b/server/resource/etc/resource.yaml @@ -18,8 +18,8 @@ AWS: Secret: sjCEv0JxATnPCxno2KNLm0X8oDc7srUR+4vkYhvm Token: BLMService: - Url: "http://18.119.109.254:8999" - # Url: "http://192.168.1.7:8999" + # Url: "http://18.119.109.254:8999" + Url: "http://192.168.1.9:8999" LogoCombine: #Url: "http://192.168.1.7:8999/LogoCombine" Url: "http://18.119.109.254:8999/LogoCombine" \ No newline at end of file diff --git a/service/repositories/image_handle.go b/service/repositories/image_handle.go index 9344d3a3..c0f396ed 100644 --- a/service/repositories/image_handle.go +++ b/service/repositories/image_handle.go @@ -33,6 +33,9 @@ type ( } ImageHandle = interface { + // 获取logo最新信息 + LogoInfo(ctx context.Context, in *LogoInfoReq) (*LogoInfoRes, error) + // logo信息 LogoInfoSet(ctx context.Context, in *LogoInfoSetReq) (*LogoInfoSetRes, error) @@ -44,6 +47,50 @@ type ( } ) +/* 获取logo最新信息 */ +type ( + LogoInfoReq struct { + UserId int64 `json:"user_id"` + GuestId int64 `json:"guest_id"` + } + LogoInfoRes struct { + Metadata *string `json:"metadata"` + LogoUrl *string `json:"logo_url"` + } +) + +func (l *defaultImageHandle) LogoInfo(ctx context.Context, in *LogoInfoReq) (*LogoInfoRes, error) { + var metadata *string + var logoUrl *string + + userMaterialModel := gmodel.NewFsUserMaterialModel(l.MysqlConn) + userMaterialInfo, err := userMaterialModel.FindLatestOne(ctx, in.UserId, in.GuestId) + + if err != nil { + if errors.Is(err, gorm.ErrRecordNotFound) { + userMaterialInfoDefault, err := userMaterialModel.FindOneById(ctx, 0) + if err != nil { + logx.Error(err) + return nil, err + } + metadata = userMaterialInfoDefault.Metadata + logoUrl = userMaterialInfoDefault.ResourceUrl + } else { + logx.Error(err) + return nil, err + } + } else { + metadata = userMaterialInfo.Metadata + logoUrl = userMaterialInfo.ResourceUrl + } + return &LogoInfoRes{ + Metadata: metadata, + LogoUrl: logoUrl, + }, nil +} + +/* 获取logo最新信息 */ + /* logo信息 */ type ( LogoInfoSetReq struct { @@ -106,34 +153,20 @@ type ( func (l *defaultImageHandle) LogoCombine(ctx context.Context, in *LogoCombineReq) (*LogoCombineRes, error) { // 查询logo最新基础信息 - var metadata *string - var logoUrl *string - userMaterialModel := gmodel.NewFsUserMaterialModel(l.MysqlConn) - userMaterialInfo, err := userMaterialModel.FindLatestOne(ctx, in.UserId, in.GuestId) - + resLogoInfo, err := l.LogoInfo(ctx, &LogoInfoReq{ + UserId: in.UserId, + GuestId: in.GuestId, + }) if err != nil { - if errors.Is(err, gorm.ErrRecordNotFound) { - userMaterialInfoDefault, err := userMaterialModel.FindOneById(ctx, 0) - if err != nil { - logx.Error(err) - return nil, err - } - metadata = userMaterialInfoDefault.Metadata - logoUrl = userMaterialInfoDefault.ResourceUrl - } else { - logx.Error(err) - return nil, err - } - } else { - metadata = userMaterialInfo.Metadata - logoUrl = userMaterialInfo.ResourceUrl + logx.Error(err) + return nil, err } // 根据hash 查询数据资源 var hashKeyData = *in hashKeyData.GuestId = 0 hashKeyData.UserId = 0 - hashKeyData.LogoUrl = *logoUrl + hashKeyData.LogoUrl = *resLogoInfo.LogoUrl var hashKeyDataMap map[string]interface{} hashKeyDataB, _ := json.Marshal(hashKeyData) json.Unmarshal(hashKeyDataB, &hashKeyDataMap) @@ -184,7 +217,7 @@ func (l *defaultImageHandle) LogoCombine(ctx context.Context, in *LogoCombineReq moduleDataMap["materialList"] = materialList var combineParam map[string]interface{} - json.Unmarshal([]byte(*metadata), &combineParam) + json.Unmarshal([]byte(*resLogoInfo.Metadata), &combineParam) combineParam["template_tagid"] = in.TemplateTag combineParam["website"] = in.Website combineParam["slogan"] = in.Slogan