fix
This commit is contained in:
parent
dab3dd7d85
commit
0001ea89f2
@ -99,3 +99,13 @@ func (s *FsProductSizeModel) GetAllByStatus(ctx context.Context, status int64, s
|
|||||||
err = db.Find(&resp).Error
|
err = db.Find(&resp).Error
|
||||||
return resp, err
|
return resp, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 获取第一个尺寸
|
||||||
|
func (s *FsProductSizeModel) GetProductFirstSize(ctx context.Context, productId int64) (resp *FsProductTemplateV2, err error) {
|
||||||
|
err = s.db.WithContext(ctx).Model(&FsProductSize{}).
|
||||||
|
Select("product_id,count(*) as num").
|
||||||
|
Where("`product_id` = ? and `status` = ?", productId, 1).
|
||||||
|
Order("sort ASC").
|
||||||
|
Take(&resp).Error
|
||||||
|
return resp, err
|
||||||
|
}
|
||||||
|
@ -114,14 +114,11 @@ func (t *FsProductTemplateV2Model) GetProductTemplateListByParams(ctx context.Co
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 获取第一个尺寸下的模板
|
// 获取第一个尺寸下的模板
|
||||||
func (t *FsProductTemplateV2Model) FindOneByProductIdTagIdWithSizeTable(ctx context.Context, productId int64, templateTag string) (resp *FsProductTemplateV2, err error) {
|
func (t *FsProductTemplateV2Model) FindFirstOneByProductIdModelIdTemplateTag(ctx context.Context, productId, modelId int64, templateTag string) (resp *FsProductTemplateV2, err error) {
|
||||||
err = t.db.WithContext(ctx).Table(t.name+" as t").
|
err = t.db.WithContext(ctx).Model(&FsProductTemplateV2{}).
|
||||||
Joins("inner join fs_product_size as s on t.product_id = s.product_id").
|
Where("product_id = ? and model_id = ? and template_tag = ? ", productId, modelId, templateTag).
|
||||||
Select("t.*").
|
Where("status = ? and is_del = ?", 1, 0).
|
||||||
Where("t.product_id = ? and t.template_tag = ? ", productId, templateTag).
|
Order("sort ASC").
|
||||||
Where("t.status = ? and t.is_del = ?", 1, 0).
|
|
||||||
Where("s.status = ?", 1).
|
|
||||||
Order("t.sort ASC,s.sort ASC").
|
|
||||||
Take(&resp).Error
|
Take(&resp).Error
|
||||||
return resp, err
|
return resp, err
|
||||||
}
|
}
|
||||||
|
@ -169,13 +169,39 @@ func (w *wsConnectItem) assembleRenderData(taskId string, info websocket_data.Re
|
|||||||
logx.Error("assembleRenderData panic:", err)
|
logx.Error("assembleRenderData panic:", err)
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
//获取模板
|
//获取产品第一个尺寸
|
||||||
productTemplate, err := w.logic.svcCtx.AllModels.FsProductTemplateV2.FindOneByProductIdTagIdWithSizeTable(w.logic.ctx, info.RenderData.ProductId, info.RenderData.TemplateTag)
|
productFirstSize, err := w.logic.svcCtx.AllModels.FsProductSize.GetProductFirstSize(w.logic.ctx, info.RenderData.ProductId)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||||
|
w.sendToOutChan(w.respondDataFormat(constants.WEBSOCKET_RENDER_IMAGE_ERR, fmt.Sprintf("没有尺寸 product_id:%d ", info.RenderData.ProductId)))
|
||||||
|
logx.Error("product first size is not found")
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
w.sendToOutChan(w.respondDataFormat(constants.WEBSOCKET_RENDER_IMAGE_ERR, fmt.Sprintf("获取尺寸错误 product_id:%d ", info.RenderData.ProductId)))
|
||||||
|
logx.Error("failed to get product first size:", err)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
//获取模型(只是获取id)
|
||||||
|
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.sendToOutChan(w.respondDataFormat(constants.WEBSOCKET_RENDER_IMAGE_ERR, fmt.Sprintf("没有模型 product_id:%d , size_id:%d ", info.RenderData.ProductId, model3dInfo.Id)))
|
||||||
|
logx.Error("product model is not found")
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
w.sendToOutChan(w.respondDataFormat(constants.WEBSOCKET_RENDER_IMAGE_ERR, fmt.Sprintf("获取模型错误 product_id:%d , size_id:%d ", info.RenderData.ProductId, model3dInfo.Id)))
|
||||||
|
logx.Error("failed to get product model:", err)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
//获取模板
|
||||||
|
productTemplate, err := w.logic.svcCtx.AllModels.FsProductTemplateV2.FindFirstOneByProductIdModelIdTemplateTag(w.logic.ctx, info.RenderData.ProductId, model3dInfo.Id, info.RenderData.TemplateTag)
|
||||||
|
if err != nil {
|
||||||
|
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||||
|
w.sendToOutChan(w.respondDataFormat(constants.WEBSOCKET_RENDER_IMAGE_ERR, fmt.Sprintf("模板未找到 product_id:%d , model_id:%d ,template_tag:%s", info.RenderData.ProductId, model3dInfo.Id, info.RenderData.TemplateTag)))
|
||||||
logx.Error("template info is not found")
|
logx.Error("template info is not found")
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
w.sendToOutChan(w.respondDataFormat(constants.WEBSOCKET_RENDER_IMAGE_ERR, fmt.Sprintf("获取模板错误 product_id:%d , model_id:%d ,template_tag:%s", info.RenderData.ProductId, model3dInfo.Id, info.RenderData.TemplateTag)))
|
||||||
logx.Error("failed to get template info:", err)
|
logx.Error("failed to get template info:", err)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user