refactor: 工作台模版展示优化

This commit is contained in:
wangjiahao 2024-01-17 10:54:52 +08:00
parent 207abf0f6e
commit 278cee6d20

View File

@ -131,7 +131,7 @@ public class TemplateCenterManage {
}
// 模版管理使用次数推荐
List<TemplateMarketDTO> manage = searchTemplateFromManage();
return baseResponseV2TransRecommend(v2BaseResponse, templateParams.get("template.url"));
return baseResponseV2TransRecommend(v2BaseResponse, manage, templateParams.get("template.url"));
}
public MarketPreviewBaseResponse searchTemplatePreview() {
@ -165,7 +165,7 @@ public class TemplateCenterManage {
}
}
private MarketBaseResponse baseResponseV2TransRecommend(MarketTemplateV2BaseResponse v2BaseResponse, String url) {
private MarketBaseResponse baseResponseV2TransRecommend(MarketTemplateV2BaseResponse v2BaseResponse,List<TemplateMarketDTO> templateManages, String url) {
Map<String, Long> useTime = coreOptRecentManage.findTemplateRecentUseTime();
List<MarketMetaDataVO> categoryVO = getCategoriesV2().stream().filter(node -> !"全部".equalsIgnoreCase(node.getLabel())).collect(Collectors.toList());
Map<String, String> categoriesMap = categoryVO.stream()
@ -181,6 +181,22 @@ public class TemplateCenterManage {
}
// 最近使用排序
Collections.sort(contents);
Long countDataV = contents.stream().filter(item -> "PANEL".equals(item.getTemplateType())).count();
Long countDashboard = contents.stream().filter(item -> "SCREEN".equals(item.getTemplateType())).count();
List<TemplateMarketDTO> templateDataV = templateManages.stream().filter(item -> "PANEL".equals(item.getTemplateType())).collect(Collectors.toList());
List<TemplateMarketDTO> templateDashboard = templateManages.stream().filter(item -> "SCREEN".equals(item.getTemplateType())).collect(Collectors.toList());
if(countDataV<10){
Long addItemCount = 10 -countDataV;
Long addIndex = templateDataV.size()<addItemCount? templateDataV.size() :addItemCount;
contents.addAll(templateDataV.subList(0,addIndex.intValue()));
}
if(countDashboard<10){
Long addItemCount = 10 -countDashboard;
Long addIndex = templateDashboard.size()<addItemCount? templateDashboard.size() :addItemCount;
contents.addAll(templateDashboard.subList(0,addIndex.intValue()));
}
return new MarketBaseResponse(url, categoryVO, contents);
}