This commit is contained in:
laodaming 2023-08-14 14:21:14 +08:00
parent 6844142603
commit bdd9a70a2d

View File

@ -88,7 +88,7 @@ func (l *GetTemplateByPidLogic) GetTemplateByPid(req *types.GetTemplateByPidReq,
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")
} }
rsp := make(map[string][]interface{}) rsp := make(map[string]interface{})
for _, templateInfo := range templateList { for _, templateInfo := range templateList {
//没有设置模板据不要 //没有设置模板据不要
if templateInfo.TemplateInfo == nil || *templateInfo.TemplateInfo == "" { if templateInfo.TemplateInfo == nil || *templateInfo.TemplateInfo == "" {
@ -115,11 +115,11 @@ func (l *GetTemplateByPidLogic) GetTemplateByPid(req *types.GetTemplateByPidReq,
material = info["module_data"]["material"] material = info["module_data"]["material"]
} }
mapKey := fmt.Sprintf("_%d", *modelInfo.SizeId) mapKey := fmt.Sprintf("_%d", *modelInfo.SizeId)
rsp[mapKey] = append(rsp[mapKey], map[string]interface{}{ rsp[mapKey] = map[string]interface{}{
"id": templateInfo.Id, "id": templateInfo.Id,
"material": material, "material": material,
"material_data": switchInfo, "material_data": switchInfo,
}) }
} }
return resp.SetStatusWithMessage(basic.CodeOK, "success", rsp) return resp.SetStatusWithMessage(basic.CodeOK, "success", rsp)
} }