11
This commit is contained in:
parent
7c6f8c5594
commit
97947fed6c
|
@ -140,7 +140,11 @@ func (w *wsConnectItem) renderImage(data []byte) {
|
||||||
productSize *gmodel.FsProductSize
|
productSize *gmodel.FsProductSize
|
||||||
)
|
)
|
||||||
//获取信息
|
//获取信息
|
||||||
productSize, productTemplate, model3dInfo, err = w.getProductRelateionInfo(&renderImageData)
|
if renderImageData.RenderData.ProductSizeId > 0 {
|
||||||
|
productSize, productTemplate, model3dInfo, err = w.getProductRelateionInfoWithSizeId(&renderImageData)
|
||||||
|
} else {
|
||||||
|
productSize, productTemplate, model3dInfo, err = w.getProductRelateionInfoWithNoSizeId(&renderImageData)
|
||||||
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logx.Error(err)
|
logx.Error(err)
|
||||||
return
|
return
|
||||||
|
@ -247,37 +251,19 @@ func (w *wsConnectItem) renderImage(data []byte) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取模板相关信息(指定尺寸)
|
// 获取模板相关信息(指定尺寸)(尺寸 -> 模型 ->模板)
|
||||||
func (w *wsConnectItem) getProductRelateionInfo(renderImageData *websocket_data.RenderImageReqMsg) (productSize *gmodel.FsProductSize, productTemplate *gmodel.FsProductTemplateV2, model3d *gmodel.FsProductModel3d, err error) {
|
func (w *wsConnectItem) getProductRelateionInfoWithSizeId(renderImageData *websocket_data.RenderImageReqMsg) (productSize *gmodel.FsProductSize, productTemplate *gmodel.FsProductTemplateV2, model3d *gmodel.FsProductModel3d, err error) {
|
||||||
//指定尺寸
|
productSize, err = w.logic.svcCtx.AllModels.FsProductSize.FindOneByIdProductId(w.logic.ctx, renderImageData.RenderData.ProductSizeId, renderImageData.RenderData.ProductId)
|
||||||
if renderImageData.RenderData.ProductSizeId > 0 {
|
if err != nil {
|
||||||
productSize, err = w.logic.svcCtx.AllModels.FsProductSize.FindOneByIdProductId(w.logic.ctx, renderImageData.RenderData.ProductSizeId, renderImageData.RenderData.ProductId)
|
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||||
if err != nil {
|
w.renderErrResponse(renderImageData.RenderId, renderImageData.RenderData.TemplateTag, "", "找不到产品的指定尺寸", renderImageData.RenderData.ProductId, w.userId, w.guestId, 0, 0, renderImageData.RenderData.ProductSizeId, 0)
|
||||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
logx.Error("product size is not found")
|
||||||
w.renderErrResponse(renderImageData.RenderId, renderImageData.RenderData.TemplateTag, "", "找不到产品的指定尺寸", renderImageData.RenderData.ProductId, w.userId, w.guestId, 0, 0, renderImageData.RenderData.ProductSizeId, 0)
|
return
|
||||||
logx.Error("product size is not found")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
w.renderErrResponse(renderImageData.RenderId, renderImageData.RenderData.TemplateTag, "", "获取产品的指定尺寸失败", renderImageData.RenderData.ProductId, w.userId, w.guestId, 0, 0, renderImageData.RenderData.ProductSizeId, 0)
|
|
||||||
logx.Error("failed to get product size:", err)
|
|
||||||
return nil, nil, nil, err
|
|
||||||
}
|
}
|
||||||
} else {
|
w.renderErrResponse(renderImageData.RenderId, renderImageData.RenderData.TemplateTag, "", "获取产品的指定尺寸失败", renderImageData.RenderData.ProductId, w.userId, w.guestId, 0, 0, renderImageData.RenderData.ProductSizeId, 0)
|
||||||
//没有指定尺寸则获取产品第一个尺寸
|
logx.Error("failed to get product size:", err)
|
||||||
productSize, err = w.logic.svcCtx.AllModels.FsProductSize.GetProductFirstSize(w.logic.ctx, renderImageData.RenderData.ProductId)
|
return nil, nil, nil, err
|
||||||
if err != nil {
|
|
||||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
|
||||||
w.renderErrResponse(renderImageData.RenderId, renderImageData.RenderData.TemplateTag, "", "找不到产品的第一个尺寸", renderImageData.RenderData.ProductId, w.userId, w.guestId, 0, 0, 0, 0)
|
|
||||||
logx.Error("product size is not found")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
w.renderErrResponse(renderImageData.RenderId, renderImageData.RenderData.TemplateTag, "", "获取产品的第一个尺寸失败", renderImageData.RenderData.ProductId, w.userId, w.guestId, 0, 0, 0, 0)
|
|
||||||
logx.Error("failed to get product size:", err)
|
|
||||||
return nil, nil, nil, err
|
|
||||||
}
|
|
||||||
renderImageData.RenderData.ProductSizeId = productSize.Id
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//获取模型
|
//获取模型
|
||||||
model3d, err = w.logic.svcCtx.AllModels.FsProductModel3d.GetOneBySizeIdTag(w.logic.ctx, productSize.Id, constants.TAG_MODEL)
|
model3d, err = w.logic.svcCtx.AllModels.FsProductModel3d.GetOneBySizeIdTag(w.logic.ctx, productSize.Id, constants.TAG_MODEL)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -313,6 +299,46 @@ func (w *wsConnectItem) getProductRelateionInfo(renderImageData *websocket_data.
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 获取模板相关信息(不指定尺寸)
|
||||||
|
func (w *wsConnectItem) getProductRelateionInfoWithNoSizeId(renderImageData *websocket_data.RenderImageReqMsg) (productSize *gmodel.FsProductSize, productTemplate *gmodel.FsProductTemplateV2, model3d *gmodel.FsProductModel3d, err error) {
|
||||||
|
//指定尺寸(尺寸 -> 模型 ->模板)
|
||||||
|
//获取模板
|
||||||
|
productTemplate, err = w.logic.svcCtx.AllModels.FsProductTemplateV2.FindOneCloudRenderByProductIdTemplateTag(w.logic.ctx, renderImageData.RenderData.ProductId, renderImageData.RenderData.TemplateTag)
|
||||||
|
if err != nil {
|
||||||
|
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||||
|
w.renderErrResponse(renderImageData.RenderId, renderImageData.RenderData.TemplateTag, "", "找不到对应模板", renderImageData.RenderData.ProductId, w.userId, w.guestId, 0, 0, 0, 0)
|
||||||
|
return nil, nil, nil, errors.New("找不到对应模板")
|
||||||
|
}
|
||||||
|
logx.Error(err)
|
||||||
|
w.renderErrResponse(renderImageData.RenderId, renderImageData.RenderData.TemplateTag, "", "获取对应模板失败", renderImageData.RenderData.ProductId, w.userId, w.guestId, 0, 0, 0, 0)
|
||||||
|
return nil, nil, nil, errors.New("获取对应模板失败")
|
||||||
|
}
|
||||||
|
//根据模板找到模型
|
||||||
|
model3d, err = w.logic.svcCtx.AllModels.FsProductModel3d.FindOne(w.logic.ctx, *productTemplate.ModelId)
|
||||||
|
if err != nil {
|
||||||
|
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||||
|
w.renderErrResponse(renderImageData.RenderId, renderImageData.RenderData.TemplateTag, "", "找不到对应模型", renderImageData.RenderData.ProductId, w.userId, w.guestId, productTemplate.Id, 0, 0, 0)
|
||||||
|
return nil, nil, nil, errors.New("找不到对应模型")
|
||||||
|
}
|
||||||
|
logx.Error(err)
|
||||||
|
w.renderErrResponse(renderImageData.RenderId, renderImageData.RenderData.TemplateTag, "", "获取对应模型失败", renderImageData.RenderData.ProductId, w.userId, w.guestId, productTemplate.Id, 0, 0, 0)
|
||||||
|
return nil, nil, nil, errors.New("获取对应模型失败")
|
||||||
|
}
|
||||||
|
//根据模型id获取尺寸信息
|
||||||
|
productSize, err = w.logic.svcCtx.AllModels.FsProductSize.FindOne(w.logic.ctx, *model3d.SizeId)
|
||||||
|
if err != nil {
|
||||||
|
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||||
|
w.renderErrResponse(renderImageData.RenderId, renderImageData.RenderData.TemplateTag, "", "找不到对应尺寸", renderImageData.RenderData.ProductId, w.userId, w.guestId, productTemplate.Id, model3d.Id, 0, 0)
|
||||||
|
return nil, nil, nil, errors.New("找不到对应尺寸")
|
||||||
|
}
|
||||||
|
logx.Error(err)
|
||||||
|
w.renderErrResponse(renderImageData.RenderId, renderImageData.RenderData.TemplateTag, "", "获取对应尺寸失败", renderImageData.RenderData.ProductId, w.userId, w.guestId, productTemplate.Id, model3d.Id, 0, 0)
|
||||||
|
return nil, nil, nil, errors.New("获取对应尺寸失败")
|
||||||
|
}
|
||||||
|
renderImageData.RenderData.ProductSizeId = productSize.Id
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
// 组装数据发送给unity
|
// 组装数据发送给unity
|
||||||
func (w *wsConnectItem) assembleRenderDataToUnity(taskId string, combineImage string, info websocket_data.RenderImageReqMsg, productTemplate *gmodel.FsProductTemplateV2, model3dInfo *gmodel.FsProductModel3d, element *gmodel.FsProductTemplateElement, productSize *gmodel.FsProductSize) (err error) {
|
func (w *wsConnectItem) assembleRenderDataToUnity(taskId string, combineImage string, info websocket_data.RenderImageReqMsg, productTemplate *gmodel.FsProductTemplateV2, model3dInfo *gmodel.FsProductModel3d, element *gmodel.FsProductTemplateElement, productSize *gmodel.FsProductSize) (err error) {
|
||||||
//组装数据
|
//组装数据
|
||||||
|
|
Loading…
Reference in New Issue
Block a user