From 5532cd1a11aeebbd1f5a91daabcfc1023551ee23 Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Thu, 27 Jul 2023 16:13:06 +0800 Subject: [PATCH] fix --- .../internal/logic/datatransferlogic.go | 4 ++-- .../internal/logic/rendernotifylogic.go | 4 ++-- .../internal/logic/ws_render_image_logic.go | 2 +- server/websocket/internal/types/types.go | 19 +++++++++++-------- server_api/websocket.api | 19 +++++++++++-------- 5 files changed, 27 insertions(+), 21 deletions(-) diff --git a/server/websocket/internal/logic/datatransferlogic.go b/server/websocket/internal/logic/datatransferlogic.go index 34d14adb..582624d1 100644 --- a/server/websocket/internal/logic/datatransferlogic.go +++ b/server/websocket/internal/logic/datatransferlogic.go @@ -241,8 +241,8 @@ func (w *wsConnectItem) sendToOutChan(data []byte) { } // 获取需要渲染图片的map key -func (w *wsConnectItem) getRenderImageMapKey(productId, templateTagId int64) string { - return fmt.Sprintf("%d-%d", productId, templateTagId) +func (w *wsConnectItem) getRenderImageMapKey(productId, templateTagId int64, algorithmVersion string) string { + return fmt.Sprintf("%d-%d-%s", productId, templateTagId, algorithmVersion) } // 处理接受到的数据 diff --git a/server/websocket/internal/logic/rendernotifylogic.go b/server/websocket/internal/logic/rendernotifylogic.go index 20ab5c9a..06ab1172 100644 --- a/server/websocket/internal/logic/rendernotifylogic.go +++ b/server/websocket/internal/logic/rendernotifylogic.go @@ -50,7 +50,7 @@ func (l *RenderNotifyLogic) RenderNotify(req *types.RenderNotifyReq) (resp *basi h.Write([]byte(fmt.Sprintf(constants.RENDER_NOTIFY_SIGN_KEY, string(notifyByte), req.Time))) signHex := h.Sum(nil) sign := hex.EncodeToString(signHex) - fmt.Println(sign) + //fmt.Println(sign) if req.Sign != sign { return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "invalid sign") } @@ -61,7 +61,7 @@ func (l *RenderNotifyLogic) RenderNotify(req *types.RenderNotifyReq) (resp *basi if !ok { return true } - renderKey := ws.getRenderImageMapKey(req.Info.ProductId, req.Info.TemplateTagId) + renderKey := ws.getRenderImageMapKey(req.Info.ProductId, req.Info.TemplateTagId, req.Info.AlgorithmVersion) //查询有无该渲染任务 _, ok = ws.renderProperty.renderImageTask[renderKey] if !ok { diff --git a/server/websocket/internal/logic/ws_render_image_logic.go b/server/websocket/internal/logic/ws_render_image_logic.go index 012d7d6b..634b6267 100644 --- a/server/websocket/internal/logic/ws_render_image_logic.go +++ b/server/websocket/internal/logic/ws_render_image_logic.go @@ -33,7 +33,7 @@ func (w *wsConnectItem) SendToCloudRender(data []byte) { return default: //加入渲染任务 - key := w.getRenderImageMapKey(productId, renderImageData.TemplateTagId) + key := w.getRenderImageMapKey(productId, renderImageData.TemplateTagId, renderImageData.AlgorithmVersion) w.renderProperty.renderImageTaskCtlChan <- renderImageControlChanItem{ Option: 1, //0删除 1添加 Key: key, diff --git a/server/websocket/internal/types/types.go b/server/websocket/internal/types/types.go index 01801c85..c8aa0da8 100644 --- a/server/websocket/internal/types/types.go +++ b/server/websocket/internal/types/types.go @@ -11,14 +11,16 @@ type DataTransferData struct { } type RenderImageReqMsg struct { - ProductIds []int64 `json:"product_ids"` //产品 id - TemplateTagId int64 `json:"template_tag_id"` //模板标签id + ProductIds []int64 `json:"product_ids"` //产品 id + TemplateTagId int64 `json:"template_tag_id"` //模板标签id + AlgorithmVersion string `json:"algorithm_version,optional"` //算法版本 } type RenderImageRspMsg struct { - ProductId int64 `json:"product_id"` //产品 id - TemplateTagId int64 `json:"template_tag_id"` //模板标签id - Image string `json:"image"` //渲染后的图片 + ProductId int64 `json:"product_id"` //产品 id + TemplateTagId int64 `json:"template_tag_id"` //模板标签id + AlgorithmVersion string `json:"algorithm_version,optional"` //算法版本 + Image string `json:"image"` //渲染后的图片 } type RenderNotifyReq struct { @@ -28,9 +30,10 @@ type RenderNotifyReq struct { } type NotifyInfo struct { - ProductId int64 `json:"product_id"` - TemplateTagId int64 `json:"template_tag_id"` //模板标签id - Image string `json:"image"` + ProductId int64 `json:"product_id"` //产品id + TemplateTagId int64 `json:"template_tag_id"` //模板标签id + AlgorithmVersion string `json:"algorithm_version,optional"` //算法版本 + Image string `json:"image"` } type Request struct { diff --git a/server_api/websocket.api b/server_api/websocket.api index 2b46d61f..c2dc6430 100644 --- a/server_api/websocket.api +++ b/server_api/websocket.api @@ -23,13 +23,15 @@ type DataTransferData { D interface{} `json:"d"` //传递的消息 } type RenderImageReqMsg { //websocket接受要云渲染处理的数据 - ProductIds []int64 `json:"product_ids"` //产品 id - TemplateTagId int64 `json:"template_tag_id"` //模板标签id + ProductIds []int64 `json:"product_ids"` //产品 id + TemplateTagId int64 `json:"template_tag_id"` //模板标签id + AlgorithmVersion string `json:"algorithm_version,optional"` //算法版本 } type RenderImageRspMsg { //websocket发送渲染完的数据 - ProductId int64 `json:"product_id"` //产品 id - TemplateTagId int64 `json:"template_tag_id"` //模板标签id - Image string `json:"image"` //渲染后的图片 + ProductId int64 `json:"product_id"` //产品 id + TemplateTagId int64 `json:"template_tag_id"` //模板标签id + AlgorithmVersion string `json:"algorithm_version,optional"` //算法版本 + Image string `json:"image"` //渲染后的图片 } //渲染完了通知接口 type RenderNotifyReq { @@ -38,7 +40,8 @@ type RenderNotifyReq { Info NotifyInfo `json:"info"` } type NotifyInfo { - ProductId int64 `json:"product_id"` - TemplateTagId int64 `json:"template_tag_id"` //模板标签id - Image string `json:"image"` + ProductId int64 `json:"product_id"` //产品id + TemplateTagId int64 `json:"template_tag_id"` //模板标签id + AlgorithmVersion string `json:"algorithm_version,optional"` //算法版本 + Image string `json:"image"` } \ No newline at end of file