优化ws代码结构

This commit is contained in:
laodaming 2023-09-05 15:08:03 +08:00
parent d9daae7829
commit e5ddc9e3dc

View File

@ -173,7 +173,7 @@ func (w *wsConnectItem) renderImage(data []byte) {
return
}
//获取唯一id
taskId := w.genRenderTaskId(renderImageData, model3dInfo, productTemplate, element)
taskId := w.genRenderTaskId(combineImage, renderImageData, model3dInfo, productTemplate, element)
//查询有没有缓存的资源,有就返回######################
resource, err := w.logic.svcCtx.AllModels.FsResource.FindOneById(w.logic.ctx, taskId)
if err != nil {
@ -492,7 +492,7 @@ func (w *wsConnectItem) modifyRenderTaskProperty(taskId string, property renderT
}
// 组装渲染任务id
func (w *wsConnectItem) genRenderTaskId(renderImageData websocket_data.RenderImageReqMsg, model3dInfo *gmodel.FsProductModel3d, productTemplate *gmodel.FsProductTemplateV2, element *gmodel.FsProductTemplateElement) string {
func (w *wsConnectItem) genRenderTaskId(combineImage string, renderImageData websocket_data.RenderImageReqMsg, model3dInfo *gmodel.FsProductModel3d, productTemplate *gmodel.FsProductTemplateV2, element *gmodel.FsProductTemplateElement) string {
//生成任务id(需要把user_id,guest_id设为0)
incomeHashParam := renderImageData.RenderData
incomeHashParam.UserId = 0 //设为0(渲染跟用户id无关)
@ -513,6 +513,7 @@ func (w *wsConnectItem) genRenderTaskId(renderImageData websocket_data.RenderIma
"template_info": templateHashStr,
"material_image": *productTemplate.MaterialImg,
"render_element": elementHashBytes,
"combine_image": combineImage,
}
return hash.JsonHashKey(hashMap)
}