fix
This commit is contained in:
parent
43b45a5461
commit
e21b0b337f
|
@ -78,6 +78,40 @@ func (l *GetProductModelsLogic) GetProductModels(req *types.GetProductModelsReq,
|
|||
for k, v := range lightList {
|
||||
mapLight[v.Id] = k
|
||||
}
|
||||
//获取配件默认贴图
|
||||
fittingPublicTemplateIds := make([]int64, 0, len(modelList)) //绑定了公共模板
|
||||
fittingNotPublicIds := make([]int64, 0, len(modelList)) //没绑定公共模板
|
||||
for _, v := range modelList {
|
||||
if *v.Tag != constants.TAG_PARTS {
|
||||
continue
|
||||
}
|
||||
//配件绑定公共模板
|
||||
if *v.OptionTemplate > 0 {
|
||||
fittingPublicTemplateIds = append(fittingPublicTemplateIds, *v.OptionTemplate)
|
||||
} else {
|
||||
fittingNotPublicIds = append(fittingNotPublicIds, v.Id)
|
||||
}
|
||||
}
|
||||
//公共模板配件的模板列表
|
||||
fittingPublicTemplateList, err := l.svcCtx.AllModels.FsProductTemplateV2.FindAllByIds(l.ctx, fittingPublicTemplateIds, "id,model_id,material_img")
|
||||
if err != nil {
|
||||
logx.Error(err)
|
||||
return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "failed to get fitting templates!")
|
||||
}
|
||||
mapFittingPublicTemplate := make(map[int64]int)
|
||||
for k, v := range fittingPublicTemplateList {
|
||||
mapFittingPublicTemplate[v.Id] = k
|
||||
}
|
||||
//非公共模板配件的模板列表
|
||||
fittingNotPublicTemplateList, err := l.svcCtx.AllModels.FsProductTemplateV2.FindAllByFittingIds(l.ctx, fittingNotPublicIds)
|
||||
if err != nil {
|
||||
logx.Error(err)
|
||||
return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "failed to get fitting templates!!")
|
||||
}
|
||||
mapFittingNotPublicTemplate := make(map[int64]int)
|
||||
for k, v := range fittingNotPublicTemplateList {
|
||||
mapFittingNotPublicTemplate[*v.ModelId] = k
|
||||
}
|
||||
for _, v := range modelList {
|
||||
//模型设计信息
|
||||
var modelDesignInfo interface{}
|
||||
|
@ -98,11 +132,26 @@ func (l *GetProductModelsLogic) GetProductModels(req *types.GetProductModelsReq,
|
|||
}
|
||||
}
|
||||
}
|
||||
fittingMaterialImage := ""
|
||||
//配件有默认贴图
|
||||
if *v.Tag == constants.TAG_PARTS {
|
||||
switch *v.OptionTemplate {
|
||||
case 0: //没有绑定公共模板的配件
|
||||
if index, ok := mapFittingNotPublicTemplate[v.Id]; ok {
|
||||
fittingMaterialImage = *fittingNotPublicTemplateList[index].MaterialImg
|
||||
}
|
||||
default:
|
||||
if index, ok := mapFittingPublicTemplate[*v.OptionTemplate]; ok {
|
||||
fittingMaterialImage = *fittingPublicTemplateList[index].MaterialImg
|
||||
}
|
||||
}
|
||||
}
|
||||
mapProductModels[*v.ProductId] = append(mapProductModels[*v.ProductId], types.ModelItem{
|
||||
Id: v.Id,
|
||||
Type: *v.Tag,
|
||||
Title: *v.Title,
|
||||
Name: *v.Name,
|
||||
MaterialImage: fittingMaterialImage,
|
||||
DesignInfo: modelDesignInfo,
|
||||
LightInfo: lightDesignInfo,
|
||||
})
|
||||
|
|
|
@ -185,6 +185,7 @@ type ModelItem struct {
|
|||
Type int64 `json:"type"` //1模型 2配件 3场景
|
||||
Title string `json:"title"`
|
||||
Name string `json:"name"`
|
||||
MaterialImage string `json:"material_image"` //默认贴图
|
||||
DesignInfo interface{} `json:"design_info"`
|
||||
LightInfo interface{} `json:"light_info"`
|
||||
}
|
||||
|
|
|
@ -201,6 +201,7 @@ type ModelItem {
|
|||
Type int64 `json:"type"` //1模型 2配件 3场景
|
||||
Title string `json:"title"`
|
||||
Name string `json:"name"`
|
||||
MaterialImage string `json:"material_image"` //默认贴图
|
||||
DesignInfo interface{} `json:"design_info"`
|
||||
LightInfo interface{} `json:"light_info"`
|
||||
}
|
Loading…
Reference in New Issue
Block a user