fix
This commit is contained in:
parent
55fa50f087
commit
3dc230495a
|
@ -114,10 +114,10 @@ func (t *FsProductTemplateV2Model) GetProductTemplateListByParams(ctx context.Co
|
|||
}
|
||||
|
||||
// 获取第一个尺寸下的模板
|
||||
func (t *FsProductTemplateV2Model) FindFirstOneByProductIdModelIdTemplateTag(ctx context.Context, productId, modelId int64, templateTag string) (resp *FsProductTemplateV2, err error) {
|
||||
func (t *FsProductTemplateV2Model) FindFirstOneCloudRenderByProductIdModelIdTemplateTag(ctx context.Context, productId, modelId int64, templateTag string) (resp *FsProductTemplateV2, err error) {
|
||||
err = t.db.WithContext(ctx).Model(&FsProductTemplateV2{}).
|
||||
Where("product_id = ? and model_id = ? and template_tag = ? ", productId, modelId, templateTag).
|
||||
Where("status = ? and is_del = ?", 1, 0).
|
||||
Where("status = ? and is_del = ? and element_model_id != ?", 1, 0, 0).
|
||||
Order("sort ASC").
|
||||
Take(&resp).Error
|
||||
return resp, err
|
||||
|
|
|
@ -8,7 +8,7 @@ func (w *wsConnectItem) incomeDataFormatErrResponse(data interface{}) {
|
|||
}
|
||||
|
||||
// 渲染错误通知
|
||||
func (w *wsConnectItem) renderErrResponse(renderId, templateTag, taskId, description string, userId, guestId, templateId, modelId, sizeId int64) {
|
||||
func (w *wsConnectItem) renderErrResponse(renderId, templateTag, taskId, description string, userId, guestId, templateId, modelId, sizeId, elementModelId int64) {
|
||||
data := make(map[string]interface{})
|
||||
data["render_id"] = renderId
|
||||
data["description"] = description
|
||||
|
@ -31,6 +31,9 @@ func (w *wsConnectItem) renderErrResponse(renderId, templateTag, taskId, descrip
|
|||
if sizeId > 0 {
|
||||
data["size_id"] = sizeId
|
||||
}
|
||||
if elementModelId > 0 {
|
||||
data["element_model_id"] = elementModelId
|
||||
}
|
||||
w.sendToOutChan(w.respondDataFormat(constants.WEBSOCKET_RENDER_IMAGE_ERR, data))
|
||||
}
|
||||
|
||||
|
|
|
@ -83,7 +83,7 @@ func (w *wsConnectItem) consumeRenderCache(data []byte) {
|
|||
userMaterial, err := w.logic.svcCtx.AllModels.FsUserMaterial.FindLatestOne(w.logic.ctx, w.userId, w.guestId)
|
||||
if err != nil {
|
||||
if !errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
w.renderErrResponse(renderImageData.RenderId, renderImageData.RenderData.TemplateTag, "", "failed to get user logo", w.userId, w.guestId, 0, 0, 0)
|
||||
w.renderErrResponse(renderImageData.RenderId, renderImageData.RenderData.TemplateTag, "", "failed to get user logo", w.userId, w.guestId, 0, 0, 0, 0)
|
||||
logx.Error("failed to get user logo")
|
||||
return
|
||||
}
|
||||
|
@ -91,10 +91,10 @@ func (w *wsConnectItem) consumeRenderCache(data []byte) {
|
|||
userMaterialDefault, err := w.logic.svcCtx.AllModels.FsUserMaterial.FindOneById(w.logic.ctx, 0)
|
||||
if err != nil {
|
||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
w.renderErrResponse(renderImageData.RenderId, renderImageData.RenderData.TemplateTag, "", "default logo is not exists", w.userId, w.guestId, 0, 0, 0)
|
||||
w.renderErrResponse(renderImageData.RenderId, renderImageData.RenderData.TemplateTag, "", "default logo is not exists", w.userId, w.guestId, 0, 0, 0, 0)
|
||||
return
|
||||
}
|
||||
w.renderErrResponse(renderImageData.RenderId, renderImageData.RenderData.TemplateTag, "", "failed to get default logo", w.userId, w.guestId, 0, 0, 0)
|
||||
w.renderErrResponse(renderImageData.RenderId, renderImageData.RenderData.TemplateTag, "", "failed to get default logo", w.userId, w.guestId, 0, 0, 0, 0)
|
||||
logx.Error("default logo is not exists")
|
||||
return
|
||||
}
|
||||
|
@ -109,11 +109,11 @@ func (w *wsConnectItem) consumeRenderCache(data []byte) {
|
|||
productFirstSize, 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, 0)
|
||||
w.renderErrResponse(renderImageData.RenderId, renderImageData.RenderData.TemplateTag, "", "product first size is not exists", w.userId, w.guestId, 0, 0, 0, 0)
|
||||
logx.Error("product first size is not found")
|
||||
return
|
||||
}
|
||||
w.renderErrResponse(renderImageData.RenderId, renderImageData.RenderData.TemplateTag, "", "failed to get product first size", w.userId, w.guestId, 0, 0, 0)
|
||||
w.renderErrResponse(renderImageData.RenderId, renderImageData.RenderData.TemplateTag, "", "failed to get product first size", w.userId, w.guestId, 0, 0, 0, 0)
|
||||
logx.Error("failed to get product first size:", err)
|
||||
return
|
||||
}
|
||||
|
@ -121,36 +121,36 @@ func (w *wsConnectItem) consumeRenderCache(data []byte) {
|
|||
model3dInfo, err := w.logic.svcCtx.AllModels.FsProductModel3d.GetOneBySizeIdTag(w.logic.ctx, productFirstSize.Id, constants.TAG_MODEL, "id")
|
||||
if err != nil {
|
||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
w.renderErrResponse(renderImageData.RenderId, renderImageData.RenderData.TemplateTag, "", "product model is not exists", w.userId, w.guestId, 0, 0, productFirstSize.Id)
|
||||
w.renderErrResponse(renderImageData.RenderId, renderImageData.RenderData.TemplateTag, "", "product model is not exists", w.userId, w.guestId, 0, 0, productFirstSize.Id, 0)
|
||||
logx.Error("product model is not found")
|
||||
return
|
||||
}
|
||||
w.renderErrResponse(renderImageData.RenderId, renderImageData.RenderData.TemplateTag, "", "failed to get product model", w.userId, w.guestId, 0, 0, productFirstSize.Id)
|
||||
w.renderErrResponse(renderImageData.RenderId, renderImageData.RenderData.TemplateTag, "", "failed to get product model", w.userId, w.guestId, 0, 0, productFirstSize.Id, 0)
|
||||
logx.Error("failed to get product model:", err)
|
||||
return
|
||||
}
|
||||
//获取模板
|
||||
productTemplate, err := w.logic.svcCtx.AllModels.FsProductTemplateV2.FindFirstOneByProductIdModelIdTemplateTag(w.logic.ctx, renderImageData.RenderData.ProductId, model3dInfo.Id, renderImageData.RenderData.TemplateTag)
|
||||
productTemplate, err := w.logic.svcCtx.AllModels.FsProductTemplateV2.FindFirstOneCloudRenderByProductIdModelIdTemplateTag(w.logic.ctx, renderImageData.RenderData.ProductId, model3dInfo.Id, renderImageData.RenderData.TemplateTag)
|
||||
if err != nil {
|
||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
w.renderErrResponse(renderImageData.RenderId, renderImageData.RenderData.TemplateTag, "", "product template is not exists", w.userId, w.guestId, 0, model3dInfo.Id, productFirstSize.Id)
|
||||
w.renderErrResponse(renderImageData.RenderId, renderImageData.RenderData.TemplateTag, "", "product template is not exists", w.userId, w.guestId, 0, model3dInfo.Id, productFirstSize.Id, *productTemplate.ElementModelId)
|
||||
logx.Error("template info is not found")
|
||||
return
|
||||
}
|
||||
w.renderErrResponse(renderImageData.RenderId, renderImageData.RenderData.TemplateTag, "", "failed to get product template", w.userId, w.guestId, 0, model3dInfo.Id, productFirstSize.Id)
|
||||
w.renderErrResponse(renderImageData.RenderId, renderImageData.RenderData.TemplateTag, "", "failed to get product template", w.userId, w.guestId, 0, model3dInfo.Id, productFirstSize.Id, *productTemplate.ElementModelId)
|
||||
logx.Error("failed to get template info:", err)
|
||||
return
|
||||
}
|
||||
//获取渲染设置信息
|
||||
element, err := w.logic.svcCtx.AllModels.FsProductTemplateElement.FindOneByModelId(w.logic.ctx, *productTemplate.ModelId)
|
||||
element, err := w.logic.svcCtx.AllModels.FsProductTemplateElement.FindOneByModelId(w.logic.ctx, *productTemplate.ElementModelId)
|
||||
if err != nil {
|
||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
w.renderErrResponse(renderImageData.RenderId, renderImageData.RenderData.TemplateTag, "", "render element is not exists", w.userId, w.guestId, productTemplate.Id, model3dInfo.Id, productFirstSize.Id)
|
||||
logx.Error("element info is not found,model_id = ", *productTemplate.ModelId)
|
||||
w.renderErrResponse(renderImageData.RenderId, renderImageData.RenderData.TemplateTag, "", "render element is not exists", w.userId, w.guestId, productTemplate.Id, model3dInfo.Id, productFirstSize.Id, *productTemplate.ElementModelId)
|
||||
logx.Error("element info is not found,element_model_id = ", *productTemplate.ElementModelId)
|
||||
return
|
||||
}
|
||||
w.renderErrResponse(renderImageData.RenderId, renderImageData.RenderData.TemplateTag, "", "failed to get render element", w.userId, w.guestId, productTemplate.Id, model3dInfo.Id, productFirstSize.Id)
|
||||
logx.Error("failed to get element list,", err)
|
||||
w.renderErrResponse(renderImageData.RenderId, renderImageData.RenderData.TemplateTag, "", "failed to get render element", w.userId, w.guestId, productTemplate.Id, model3dInfo.Id, productFirstSize.Id, *productTemplate.ElementModelId)
|
||||
logx.Error("failed to get element ,", err)
|
||||
return
|
||||
}
|
||||
//获取刀版图
|
||||
|
@ -166,7 +166,7 @@ func (w *wsConnectItem) consumeRenderCache(data []byte) {
|
|||
}
|
||||
res, err := w.logic.svcCtx.Repositories.ImageHandle.LogoCombine(w.logic.ctx, &combineReq)
|
||||
if err != nil {
|
||||
w.renderErrResponse(renderImageData.RenderId, renderImageData.RenderData.TemplateTag, "", "failed to combine image:"+err.Error(), w.userId, w.guestId, productTemplate.Id, model3dInfo.Id, productFirstSize.Id)
|
||||
w.renderErrResponse(renderImageData.RenderId, renderImageData.RenderData.TemplateTag, "", "failed to combine image:"+err.Error(), w.userId, w.guestId, productTemplate.Id, model3dInfo.Id, productFirstSize.Id, *productTemplate.ElementModelId)
|
||||
logx.Error("合成刀版图失败,合成请求数据:", combineReq, "错误信息:", err)
|
||||
return
|
||||
}
|
||||
|
@ -174,7 +174,7 @@ func (w *wsConnectItem) consumeRenderCache(data []byte) {
|
|||
if res != nil && res.ResourceUrl != nil {
|
||||
combineImage = *res.ResourceUrl
|
||||
} else {
|
||||
w.renderErrResponse(renderImageData.RenderId, renderImageData.RenderData.TemplateTag, "", "combine image is empty", w.userId, w.guestId, productTemplate.Id, model3dInfo.Id, productFirstSize.Id)
|
||||
w.renderErrResponse(renderImageData.RenderId, renderImageData.RenderData.TemplateTag, "", "combine image is empty", w.userId, w.guestId, productTemplate.Id, model3dInfo.Id, productFirstSize.Id, *productTemplate.ElementModelId)
|
||||
logx.Error("合成刀版图失败,合成的刀版图是空指针:", err)
|
||||
return
|
||||
}
|
||||
|
@ -194,7 +194,7 @@ func (w *wsConnectItem) consumeRenderCache(data []byte) {
|
|||
resource, err := w.logic.svcCtx.AllModels.FsResource.FindOneById(w.logic.ctx, taskId)
|
||||
if err != nil {
|
||||
if !errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
w.renderErrResponse(renderImageData.RenderId, renderImageData.RenderData.TemplateTag, taskId, "failed to get render cache", w.userId, w.guestId, 0, 0, 0)
|
||||
w.renderErrResponse(renderImageData.RenderId, renderImageData.RenderData.TemplateTag, taskId, "failed to get render cache", w.userId, w.guestId, productTemplate.Id, model3dInfo.Id, productFirstSize.Id, *productTemplate.ElementModelId)
|
||||
logx.Error("failed to find render resource:", err)
|
||||
return
|
||||
}
|
||||
|
@ -264,7 +264,7 @@ func (w *wsConnectItem) assembleRenderData(taskId string, combineImage string, i
|
|||
refletion, err = strconv.Atoi(*element.Refletion)
|
||||
if err != nil {
|
||||
logx.Error("err refletion:set default -1")
|
||||
w.renderErrResponse(info.RenderId, info.RenderData.TemplateTag, taskId, "parse element.Refletion from string to number err", w.userId, w.guestId, productTemplate.Id, model3dInfo.Id, productFirstSize.Id)
|
||||
w.renderErrResponse(info.RenderId, info.RenderData.TemplateTag, taskId, "parse element.Refletion from string to number err", w.userId, w.guestId, productTemplate.Id, model3dInfo.Id, productFirstSize.Id, *productTemplate.ElementModelId)
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
@ -273,7 +273,7 @@ func (w *wsConnectItem) assembleRenderData(taskId string, combineImage string, i
|
|||
if element.Mode != nil && *element.Mode != "" {
|
||||
if err = json.Unmarshal([]byte(*element.Mode), &mode); err != nil {
|
||||
logx.Error("faile to parse element mode json:", err)
|
||||
w.renderErrResponse(info.RenderId, info.RenderData.TemplateTag, taskId, "parse element.Mode err", w.userId, w.guestId, productTemplate.Id, model3dInfo.Id, productFirstSize.Id)
|
||||
w.renderErrResponse(info.RenderId, info.RenderData.TemplateTag, taskId, "parse element.Mode err", w.userId, w.guestId, productTemplate.Id, model3dInfo.Id, productFirstSize.Id, *productTemplate.ElementModelId)
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
@ -346,7 +346,7 @@ func (w *wsConnectItem) assembleRenderData(taskId string, combineImage string, i
|
|||
unityRenderBeginTime := time.Now().UTC().UnixMilli()
|
||||
_, err = curl.ApiCall(url, "POST", header, bytes.NewReader(postDataBytes), time.Second*10)
|
||||
if err != nil {
|
||||
w.renderErrResponse(info.RenderId, info.RenderData.TemplateTag, taskId, "request unity api err", w.userId, w.guestId, productTemplate.Id, model3dInfo.Id, productFirstSize.Id)
|
||||
w.renderErrResponse(info.RenderId, info.RenderData.TemplateTag, taskId, "request unity api err", w.userId, w.guestId, productTemplate.Id, model3dInfo.Id, productFirstSize.Id, *productTemplate.ElementModelId)
|
||||
logx.Error("failed to send data to unity")
|
||||
return err
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user