This commit is contained in:
laodaming 2023-08-18 10:26:33 +08:00
parent 430cd22dc3
commit 37d32a26ab
3 changed files with 9 additions and 18 deletions

View File

@ -37,8 +37,8 @@ func (l *GetTemplateByPidLogic) GetTemplateByPid(req *types.GetTemplateByPidReq,
if req.Pid == "" { if req.Pid == "" {
return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "err param:pid is empty") return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "err param:pid is empty")
} }
if req.ProductTemplateTagId <= 0 { if req.TemplateTag == "" {
return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "err param:product_template_tag_id") return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "err param:template_tag")
} }
//获取产品信息(只获取id) //获取产品信息(只获取id)
productInfo, err := l.svcCtx.AllModels.FsProduct.FindOneBySn(l.ctx, req.Pid, "id") productInfo, err := l.svcCtx.AllModels.FsProduct.FindOneBySn(l.ctx, req.Pid, "id")
@ -67,15 +67,6 @@ func (l *GetTemplateByPidLogic) GetTemplateByPid(req *types.GetTemplateByPidReq,
} else { //指定物料 } else { //指定物料
sizeIds = append(sizeIds, req.ProductSizeId) sizeIds = append(sizeIds, req.ProductSizeId)
} }
//获取templatetag信息
templateTagInfo, err := l.svcCtx.AllModels.FsProductTemplateTags.FindOne(l.ctx, req.ProductTemplateTagId)
if err != nil {
if errors.Is(err, gorm.ErrRecordNotFound) {
return resp.SetStatusWithMessage(basic.CodeDbRecordNotFoundErr, "template tag is not exists")
}
logx.Error(err)
return resp.SetStatusWithMessage(basic.CodeDbRecordNotFoundErr, "failed to get template tag")
}
//根据尺寸id获取模型 //根据尺寸id获取模型
modelList, err := l.svcCtx.AllModels.FsProductModel3d.GetAllBySizeIdsTag(l.ctx, sizeIds, constants.TAG_MODEL) modelList, err := l.svcCtx.AllModels.FsProductModel3d.GetAllBySizeIdsTag(l.ctx, sizeIds, constants.TAG_MODEL)
if err != nil { if err != nil {
@ -92,7 +83,7 @@ func (l *GetTemplateByPidLogic) GetTemplateByPid(req *types.GetTemplateByPidReq,
mapModel[v.Id] = k mapModel[v.Id] = k
} }
//查询模型ids下对应tag标签的模板 //查询模型ids下对应tag标签的模板
templateList, err := l.svcCtx.AllModels.FsProductTemplateV2.FindAllByModelIdsTemplateTag(l.ctx, modelIds, *templateTagInfo.TemplateTag, "") templateList, err := l.svcCtx.AllModels.FsProductTemplateV2.FindAllByModelIdsTemplateTag(l.ctx, modelIds, req.TemplateTag, "")
if err != nil { if err != nil {
logx.Error(err) logx.Error(err)
return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "failed to get template list") return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "failed to get template list")

View File

@ -341,9 +341,9 @@ type GetSizeByPidRsp struct {
} }
type GetTemplateByPidReq struct { type GetTemplateByPidReq struct {
Pid string `form:"pid"` Pid string `form:"pid"`
ProductSizeId int64 `form:"product_size_id,optional"` ProductSizeId int64 `form:"product_size_id,optional"`
ProductTemplateTagId int64 `form:"product_template_tag_id"` TemplateTag string `form:"template_tag"`
} }
type GetFittingByPidReq struct { type GetFittingByPidReq struct {

View File

@ -386,9 +386,9 @@ type GetSizeByPidRsp {
} }
//获取产品模板 //获取产品模板
type GetTemplateByPidReq { type GetTemplateByPidReq {
Pid string `form:"pid"` Pid string `form:"pid"`
ProductSizeId int64 `form:"product_size_id,optional"` ProductSizeId int64 `form:"product_size_id,optional"`
ProductTemplateTagId int64 `form:"product_template_tag_id"` TemplateTag string `form:"template_tag"`
} }
//获取产品配件数据 //获取产品配件数据
type GetFittingByPidReq { type GetFittingByPidReq {