Skip to content

Commit

Permalink
Merge pull request #103 from klaus-cicd/dev
Browse files Browse the repository at this point in the history
perf: 优化待办导出排序规则(日期增序)
  • Loading branch information
xiaozzzi authored Mar 29, 2024
2 parents 682a5c8 + aa6a8d3 commit aa4bfb0
Showing 1 changed file with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,16 @@ public static String export(List<TodoEntity> todos, TodoExportReq req) {
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) {
Expand Down

0 comments on commit aa4bfb0

Please sign in to comment.