fix
This commit is contained in:
@@ -1,9 +1,11 @@
|
||||
package logic
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fusenapi/model/gmodel"
|
||||
"fusenapi/utils/auth"
|
||||
"fusenapi/utils/basic"
|
||||
"gorm.io/gorm"
|
||||
|
||||
"context"
|
||||
|
||||
@@ -38,42 +40,42 @@ func (l *GetProductDesignLogic) GetProductDesign(req *types.GetProductDesignReq,
|
||||
productDesignModel := gmodel.NewFsProductDesignModel(l.svcCtx.MysqlConn)
|
||||
designInfo, err := productDesignModel.FindOneBySn(l.ctx, req.Sn, userinfo.UserId)
|
||||
if err != nil {
|
||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
return resp.SetStatusWithMessage(basic.CodeDbRecordNotFoundErr, "design info is not exists")
|
||||
}
|
||||
logx.Error(err)
|
||||
return resp.SetStatusWithMessage(basic.CodeServiceErr, "failed to get design info")
|
||||
}
|
||||
if designInfo.Id == 0 {
|
||||
return resp.SetStatusWithMessage(basic.CodeDbRecordNotFoundErr, "design info is not exists")
|
||||
}
|
||||
//获取产品尺寸信息
|
||||
productSizeModel := gmodel.NewFsProductSizeModel(l.svcCtx.MysqlConn)
|
||||
sizeInfo, err := productSizeModel.FindOne(l.ctx, *designInfo.SizeId)
|
||||
if err != nil {
|
||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
return resp.SetStatusWithMessage(basic.CodeServiceErr, "product size info is not exists")
|
||||
}
|
||||
logx.Error(err)
|
||||
return resp.SetStatusWithMessage(basic.CodeServiceErr, "failed to get product size info")
|
||||
}
|
||||
if sizeInfo.Id == 0 {
|
||||
return resp.SetStatusWithMessage(basic.CodeServiceErr, "product size info is not exists")
|
||||
}
|
||||
//获取模板信息
|
||||
productTemplateV2Model := gmodel.NewFsProductTemplateV2Model(l.svcCtx.MysqlConn)
|
||||
productTemplateV2Info, err := productTemplateV2Model.FindOne(l.ctx, *designInfo.TemplateId)
|
||||
if err != nil {
|
||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
return resp.SetStatusWithMessage(basic.CodeDbRecordNotFoundErr, "template info is not exists")
|
||||
}
|
||||
logx.Error(err)
|
||||
return resp.SetStatusWithMessage(basic.CodeServiceErr, "failed to get template info")
|
||||
}
|
||||
if productTemplateV2Info.Id == 0 {
|
||||
return resp.SetStatusWithMessage(basic.CodeDbRecordNotFoundErr, "template info is not exists")
|
||||
}
|
||||
//获取产品模型信息
|
||||
productModel3dModel := gmodel.NewFsProductModel3dModel(l.svcCtx.MysqlConn)
|
||||
model3dInfo, err := productModel3dModel.FindOne(l.ctx, *designInfo.OptionalId)
|
||||
if err != nil {
|
||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
return resp.SetStatusWithMessage(basic.CodeDbRecordNotFoundErr, "product 3D model info is not exists")
|
||||
}
|
||||
logx.Error(err)
|
||||
return resp.SetStatusWithMessage(basic.CodeServiceErr, "failed to get product 3D model info")
|
||||
}
|
||||
if model3dInfo.Id == 0 {
|
||||
return resp.SetStatusWithMessage(basic.CodeDbRecordNotFoundErr, "product 3D model info is not exists")
|
||||
}
|
||||
optionalId := *designInfo.OptionalId
|
||||
if *model3dInfo.Status == 0 && *sizeInfo.Status == 1 && *productTemplateV2Info.Status == 1 && *productTemplateV2Info.IsDel == 0 {
|
||||
optionalId = 0
|
||||
|
||||
@@ -14,6 +14,7 @@ import (
|
||||
"fusenapi/utils/image"
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
"github.com/zeromicro/go-zero/core/stores/sqlc"
|
||||
"gorm.io/gorm"
|
||||
"sort"
|
||||
"strings"
|
||||
)
|
||||
@@ -115,12 +116,12 @@ func (l *GetProductListLogic) GetProductList(req *types.GetProductListReq, useri
|
||||
tagsModel := gmodel.NewFsTagsModel(l.svcCtx.MysqlConn)
|
||||
tagInfo, err := tagsModel.FindOne(l.ctx, req.Cid)
|
||||
if err != nil && !errors.Is(err, sqlc.ErrNotFound) {
|
||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
return resp.SetStatusWithMessage(basic.CodeServiceErr, "tag is not exists")
|
||||
}
|
||||
logx.Error(err)
|
||||
return resp.SetStatusWithMessage(basic.CodeServiceErr, "get tag err")
|
||||
}
|
||||
if tagInfo.Id == 0 {
|
||||
return resp.SetStatusWithMessage(basic.CodeServiceErr, "tag is not exists")
|
||||
}
|
||||
//获取产品尺寸数量
|
||||
productSizeModel := gmodel.NewFsProductSizeModel(l.svcCtx.MysqlConn)
|
||||
productSizeCount, err := productSizeModel.CountByStatus(l.ctx, 1)
|
||||
|
||||
Reference in New Issue
Block a user