fix
This commit is contained in:
parent
9f4745b740
commit
1bb2e190a2
|
@ -185,6 +185,22 @@ func (t *FsProductTemplateV2Model) FindAllByProductIdsTemplateTag(ctx context.Co
|
||||||
err = db.Find(&resp).Error
|
err = db.Find(&resp).Error
|
||||||
return resp, err
|
return resp, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 获取开启云渲染的模板列表
|
||||||
|
func (t *FsProductTemplateV2Model) FindAllCloudRenderTemplateByProductIdsTemplateTag(ctx context.Context, productIds []int64, templateTag string, sort string, fields ...string) (resp []FsProductTemplateV2, err error) {
|
||||||
|
if len(productIds) == 0 {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
db := t.db.WithContext(ctx).Model(&FsProductTemplateV2{}).Where("`product_id` in (?) and `template_tag` = ? and `is_del` = ? and `status` = ? and `element_model_id` > ? ", productIds, templateTag, 0, 1, 0)
|
||||||
|
if sort != "" {
|
||||||
|
db = db.Order(sort)
|
||||||
|
}
|
||||||
|
if len(fields) != 0 {
|
||||||
|
db = db.Select(fields[0])
|
||||||
|
}
|
||||||
|
err = db.Find(&resp).Error
|
||||||
|
return resp, err
|
||||||
|
}
|
||||||
func (t *FsProductTemplateV2Model) FindAllByFittingIds(ctx context.Context, fittingIds []int64, fields ...string) (resp []FsProductTemplateV2, err error) {
|
func (t *FsProductTemplateV2Model) FindAllByFittingIds(ctx context.Context, fittingIds []int64, fields ...string) (resp []FsProductTemplateV2, err error) {
|
||||||
db := t.db.WithContext(ctx).Model(&FsProductTemplateV2{}).Where("`model_id` in(?) and `status` = ? and `is_del` = ? ", fittingIds, 1, 0)
|
db := t.db.WithContext(ctx).Model(&FsProductTemplateV2{}).Where("`model_id` in(?) and `status` = ? and `is_del` = ? ", fittingIds, 1, 0)
|
||||||
if len(fields) != 0 {
|
if len(fields) != 0 {
|
||||||
|
|
|
@ -57,12 +57,33 @@ func (l *GetProductModelsLogic) GetProductModels(req *types.GetProductModelsReq,
|
||||||
if len(productList) != len(productIds) {
|
if len(productList) != len(productIds) {
|
||||||
return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "some one product is invalid")
|
return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "some one product is invalid")
|
||||||
}
|
}
|
||||||
//获取产品所有的模型以及配件
|
//根据模板标签获取开启了云渲染的模板列表
|
||||||
modelList, err := l.svcCtx.AllModels.FsProductModel3d.GetAllByProductIdsTags(l.ctx, productIds, []int{constants.TAG_MODEL, constants.TAG_PARTS})
|
templateList, err := l.svcCtx.AllModels.FsProductTemplateV2.FindAllCloudRenderTemplateByProductIdsTemplateTag(l.ctx, productIds, req.TemplateTag, "", "id,product_id,model_id")
|
||||||
|
if err != nil {
|
||||||
|
logx.Error(err)
|
||||||
|
return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "failed to get product template list")
|
||||||
|
}
|
||||||
|
modelIds := make([]int64, 0, len(templateList))
|
||||||
|
for _, v := range templateList {
|
||||||
|
modelIds = append(modelIds, *v.ModelId)
|
||||||
|
}
|
||||||
|
//获取模型列表
|
||||||
|
modelList, err := l.svcCtx.AllModels.FsProductModel3d.GetAllByIds(l.ctx, modelIds, "")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logx.Error(err)
|
logx.Error(err)
|
||||||
return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "failed to get model list")
|
return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "failed to get model list")
|
||||||
}
|
}
|
||||||
|
partIds := make([]int64, 0, len(modelList))
|
||||||
|
for _, v := range modelList {
|
||||||
|
if *v.PartId == 0 {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
partIds = append(partIds, *v.PartId)
|
||||||
|
}
|
||||||
|
//获取配件列表
|
||||||
|
partList, err := l.svcCtx.AllModels.FsProductModel3d.GetAllByIds(l.ctx, partIds, "")
|
||||||
|
//合并模型和配件
|
||||||
|
modelList = append(modelList, partList...)
|
||||||
mapProductModels := make(map[int64][]types.ModelItem)
|
mapProductModels := make(map[int64][]types.ModelItem)
|
||||||
lightIds := make([]int64, 0, len(modelList))
|
lightIds := make([]int64, 0, len(modelList))
|
||||||
for _, v := range modelList {
|
for _, v := range modelList {
|
||||||
|
|
|
@ -172,7 +172,8 @@ type TemplateTagColorInfo struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
type GetProductModelsReq struct {
|
type GetProductModelsReq struct {
|
||||||
ProductIds string `form:"product_ids"`
|
ProductIds string `form:"product_ids"`
|
||||||
|
TemplateTag string `form:"template_tag"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type ProductItem struct {
|
type ProductItem struct {
|
||||||
|
|
|
@ -190,7 +190,8 @@ type TemplateTagColorInfo {
|
||||||
}
|
}
|
||||||
//根据产品获取模型配件列表
|
//根据产品获取模型配件列表
|
||||||
type GetProductModelsReq {
|
type GetProductModelsReq {
|
||||||
ProductIds string `form:"product_ids"`
|
ProductIds string `form:"product_ids"`
|
||||||
|
TemplateTag string `form:"template_tag"`
|
||||||
}
|
}
|
||||||
type ProductItem {
|
type ProductItem {
|
||||||
ModelList []ModelItem `json:"model_list"`
|
ModelList []ModelItem `json:"model_list"`
|
||||||
|
|
Loading…
Reference in New Issue
Block a user