Merge pull request #103 from klaus-cicd/dev

perf: 优化待办导出排序规则(日期增序)
This commit is contained in:
xiaozzzi 2024-03-29 13:03:57 +08:00 committed by GitHub
commit aa4bfb0c7d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -58,9 +58,16 @@ public class TodoUtil {
if (CollUtil.isEmpty(todos)) {
return "无内容";
}
Map<String, List<TodoEntity>> maps = todos.stream().collect(Collectors.groupingBy(TodoEntity::getTodoName));
List<Map.Entry<String, List<TodoEntity>>> entryList = todos.stream()
.collect(Collectors.groupingBy(TodoEntity::getTodoName))
// 增加根据Todo name的排序
.entrySet().stream().sorted(Map.Entry.comparingByKey()).collect(Collectors.toList());
StringBuilder sb = new StringBuilder();
maps.forEach((todoName, tasks) -> {
entryList.forEach(entry -> {
String todoName = entry.getKey();
List<TodoEntity> tasks = entry.getValue();
sb.append(String.format("# %s \n\n", todoName));
for (TodoEntity task : tasks) {