提交 1629d205 作者: zgz

资讯分页列表标题加句号

上级 dcfc0b57
...@@ -196,16 +196,21 @@ public class InformationServiceImpl implements InformationService { ...@@ -196,16 +196,21 @@ public class InformationServiceImpl implements InformationService {
formatLabel(modelVoList, info); formatLabel(modelVoList, info);
dataList.add(info); dataList.add(info);
} }
Map<String, List<DisplayInfo>> mapList = groupedByLabelMark(dataList); Map<String, List<DisplayInfo>> mapList = groupedByLabelMark(dataList,searchCondition);
mapList.forEach((relationName, displayInfos) -> { mapList.forEach((relationName, displayInfos) -> {
List<DisplayInfo> listN = new ArrayList<>();
Integer num = 0; Integer num = 0;
for (DisplayInfo obj : displayInfos) { for (DisplayInfo obj : displayInfos) {
DisplayInfo copy = new DisplayInfo();
BeanUtils.copyProperties(obj,copy);
num++; num++;
obj.setIndex(num + "."); copy.setIndex(num + ".");
copy.setTitle(StringUtils.isNotEmpty(copy.getTitle())?copy.getTitle() + "。":"");
listN.add(copy);
} }
HashMap map = new HashMap(); HashMap map = new HashMap();
map.put("relationName",relationName); map.put("relationName",relationName);
map.put("infoList",displayInfos); map.put("infoList",listN);
list.add(map); list.add(map);
}); });
}else{ }else{
...@@ -239,13 +244,18 @@ public class InformationServiceImpl implements InformationService { ...@@ -239,13 +244,18 @@ public class InformationServiceImpl implements InformationService {
return Result.OK(list); return Result.OK(list);
} }
public Map<String, List<DisplayInfo>> groupedByLabelMark(List<DisplayInfo> dataList) { public Map<String, List<DisplayInfo>> groupedByLabelMark(List<DisplayInfo> dataList,InfoDataSearchCondition searchCondition) {
// 使用 Stream API 对 dataList 进行分组 // 使用 Stream API 对 dataList 进行分组
Map<String, List<DisplayInfo>> groupedByLabelMark = dataList.stream() Map<String, List<DisplayInfo>> groupedByLabelMark = dataList.stream()
// 将每个 DisplayInfo 对象映射到一个或多个 labelMark // 将每个 DisplayInfo 对象映射到一个或多个 labelMark
.flatMap(displayInfo -> displayInfo.getLabels().stream() .flatMap(displayInfo -> displayInfo.getLabels().stream()
// 映射每个 Label 到其 labelMark // 映射每个 Label 到其 labelMark
.filter(label -> label.getRelationName() != null) .filter(label -> label.getRelationName() != null)
// .filter(label -> Optional.ofNullable(searchCondition.getLabelMark())
// // 如果 searchCondition.getLabelMark() 非空,则应用过滤条件
// .map(labelMark -> labelMark.equals(label.getLabelMark()))
// // 如果 searchCondition.getLabelMark() 为空,则默认为 true(不应用过滤条件)
// .orElse(true))
.map(label -> new AbstractMap.SimpleEntry<>(label.getRelationName(), displayInfo))) .map(label -> new AbstractMap.SimpleEntry<>(label.getRelationName(), displayInfo)))
// 根据 labelMark 进行分组 // 根据 labelMark 进行分组
.collect(Collectors.groupingBy(AbstractMap.SimpleEntry::getKey, .collect(Collectors.groupingBy(AbstractMap.SimpleEntry::getKey,
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论