This commit is contained in:
laodaming 2023-10-17 16:19:44 +08:00
parent 0c5a5a466f
commit c79a1aab49
4 changed files with 37 additions and 8 deletions

View File

@ -159,6 +159,12 @@ func (l *GetProductDetailLogic) GetProductDetail(req *types.GetProductDetailReq,
logx.Error(err)
return resp.SetStatusWithMessage(basic.CodeServiceErr, "failed to get product min price")
}
//获取默认渲染的尺寸
defaultSize, err := l.getRenderDefaultSize(req.ProductId, req.TemplateTag)
if err != nil {
logx.Error(err)
return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "failed to get default size")
}
//整理返回
rspSizeList := make([]types.SizeInfo, 0, len(sizeList))
for _, sizeInfo := range sizeList {
@ -266,8 +272,13 @@ func (l *GetProductDetailLogic) GetProductDetail(req *types.GetProductDetailReq,
}
}
isDefaultSize := int64(0)
if sizeInfo.Id == defaultSize {
isDefaultSize = 1
}
rspSizeList = append(rspSizeList, types.SizeInfo{
Id: sizeInfo.Id,
IsDefault: isDefaultSize,
Title: sizeTitle,
Capacity: *sizeInfo.Capacity,
PartsCanDeleted: *sizeInfo.PartsCanDeleted,
@ -294,10 +305,30 @@ func (l *GetProductDetailLogic) GetProductDetail(req *types.GetProductDetailReq,
})
}
// 处理逻辑后 w,r 如:重定向, resp 必须重新处理
// func (l *GetProductDetailLogic) AfterLogic(w http.ResponseWriter, r *http.Request, resp *basic.Response) {
// // httpx.OkJsonCtx(r.Context(), w, resp)
// }
// 获取列表页默认渲染的尺寸(同列表页)
func (l *GetProductDetailLogic) getRenderDefaultSize(productId int64, templateTag string) (sizeId int64, err error) {
//获取模板
productTemplate, err := l.svcCtx.AllModels.FsProductTemplateV2.FindOneCloudRenderByProductIdTemplateTag(l.ctx, productId, templateTag, "sort ASC", "model_id")
if err != nil {
if errors.Is(err, gorm.ErrRecordNotFound) {
return 0, errors.New("找不到对应开启云渲染模板")
}
logx.Error(err)
return 0, errors.New("获取对应开启云渲染模板失败")
}
//根据模板找到模型
model3d, err := l.svcCtx.AllModels.FsProductModel3d.FindOne(l.ctx, *productTemplate.ModelId, "size_id")
if err != nil {
if errors.Is(err, gorm.ErrRecordNotFound) {
return 0, errors.New("找不到对应模型")
}
logx.Error(err)
return 0, errors.New("获取对应模型失败")
}
return *model3d.SizeId, nil
}
// 获取对应模板标签颜色信息
func (l *GetProductDetailLogic) GetTemplateTagColor(req *types.GetProductDetailReq, userinfo *auth.UserInfo) (resp types.TemplateTagColorInfo, err error) {
if req.SelectColorIndex < 0 {
return types.TemplateTagColorInfo{}, errors.New("param selected_color_index is invalid")

View File

@ -207,6 +207,7 @@ type GetProductDetailRsp struct {
type SizeInfo struct {
Id int64 `json:"id"` //尺寸id
IsDefault int64 `json:"is_default"` //是否默认显示
Title interface{} `json:"title"` //尺寸标题信息
Capacity string `json:"capacity"` //尺寸名称
PartsCanDeleted int64 `json:"parts_can_deleted"` //配件是否可删除

View File

@ -145,10 +145,6 @@ func (w *wsConnectItem) consumeRenderImageData() {
// 执行渲染任务
func (w *wsConnectItem) renderImage(renderImageData websocket_data.RenderImageReqMsg) {
/* if renderImageData.RenderData.Logo == "" {
w.renderErrResponse(renderImageData.RenderId, renderImageData.RequestId, renderImageData.RenderData.TemplateTag, "", "请传入logo", renderImageData.RenderData.ProductId, w.userId, w.guestId, 0, 0, 0, 0)
return
}*/
if !strings.Contains(renderImageData.RenderData.Logo, "storage.fusenpack.com") {
w.renderErrResponse(renderImageData.RenderId, renderImageData.RequestId, renderImageData.RenderData.TemplateTag, "", "非法的logo", renderImageData.RenderData.ProductId, w.userId, w.guestId, 0, 0, 0, 0)
return

View File

@ -241,6 +241,7 @@ type GetProductDetailRsp {
}
type SizeInfo {
Id int64 `json:"id"` //尺寸id
IsDefault int64 `json:"is_default"` //是否默认显示
Title interface{} `json:"title"` //尺寸标题信息
Capacity string `json:"capacity"` //尺寸名称
PartsCanDeleted int64 `json:"parts_can_deleted"` //配件是否可删除