From 95878b3bb8b832c9aae55b15c5d2ff20600d2089 Mon Sep 17 00:00:00 2001 From: Ryan Wang Date: Mon, 22 Jan 2024 15:20:10 +0800 Subject: [PATCH 1/3] refactor: update chinese display name of post editor role (#5224) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit #### What type of PR is this? /area core /milestone 2.12.x #### What this PR does / why we need it: 修改文章编辑角色的显示名称为**文章管理员**,这样会更加直观。 #### Which issue(s) this PR fixes: Fixes #5221 #### Does this PR introduce a user-facing change? ```release-note 修改文章编辑角色的显示名称为**文章管理员**。 ``` --- .../src/main/resources/extensions/role-template-uc-content.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/application/src/main/resources/extensions/role-template-uc-content.yaml b/application/src/main/resources/extensions/role-template-uc-content.yaml index 7b9b42a2e0..eca495a96f 100644 --- a/application/src/main/resources/extensions/role-template-uc-content.yaml +++ b/application/src/main/resources/extensions/role-template-uc-content.yaml @@ -6,7 +6,7 @@ metadata: rbac.authorization.halo.run/system-reserved: "true" annotations: # Currently, yaml definition does not support i18n, please see https://github.com/halo-dev/halo/issues/3573 - rbac.authorization.halo.run/display-name: "编辑者" + rbac.authorization.halo.run/display-name: "文章管理员" rbac.authorization.halo.run/dependencies: | ["role-template-post-editor"] rules: [ ] From 9d9b1527bc0e4416f50eb4966e8b76ad7fcb193b Mon Sep 17 00:00:00 2001 From: John Niang Date: Tue, 23 Jan 2024 13:11:41 +0800 Subject: [PATCH 2/3] Upgrade Spring Boot to 3.2.2 (#5232) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit #### What type of PR is this? /kind improvement /area core #### What this PR does / why we need it: See https://github.com/spring-projects/spring-boot/releases/tag/v3.2.2 for more. #### Does this PR introduce a user-facing change? ```release-note 升级依赖 Spring Boot 至 3.2.2 ``` --- application/build.gradle | 2 +- .../main/java/run/halo/app/content/comment/ReplyService.java | 2 +- .../infra/exception/handlers/ProblemDetailErrorAttributes.java | 1 - .../app/theme/finders/impl/CommentPublicQueryServiceImpl.java | 2 +- gradle.properties | 1 - platform/application/build.gradle | 2 +- 6 files changed, 4 insertions(+), 6 deletions(-) diff --git a/application/build.gradle b/application/build.gradle index 2fefdcf388..1f46efff7d 100644 --- a/application/build.gradle +++ b/application/build.gradle @@ -2,7 +2,7 @@ import de.undercouch.gradle.tasks.download.Download import org.gradle.crypto.checksum.Checksum plugins { - id 'org.springframework.boot' version '3.2.0' + id 'org.springframework.boot' version '3.2.2' id 'io.spring.dependency-management' version '1.1.0' id "com.gorylenko.gradle-git-properties" version "2.3.2" id "checkstyle" diff --git a/application/src/main/java/run/halo/app/content/comment/ReplyService.java b/application/src/main/java/run/halo/app/content/comment/ReplyService.java index 56962e8704..2010f229ee 100644 --- a/application/src/main/java/run/halo/app/content/comment/ReplyService.java +++ b/application/src/main/java/run/halo/app/content/comment/ReplyService.java @@ -31,7 +31,7 @@ static Comparator creationTimeAscComparator() { reply -> reply.getMetadata().getCreationTimestamp(); // ascending order by creation time // asc nulls high will be placed at the end - return Comparator.comparing(creationTime, Comparators.nullsLow()) + return Comparator.comparing(creationTime, Comparators.nullsHigh()) .thenComparing(metadataCreationTime) .thenComparing(reply -> reply.getMetadata().getName()); } diff --git a/application/src/main/java/run/halo/app/infra/exception/handlers/ProblemDetailErrorAttributes.java b/application/src/main/java/run/halo/app/infra/exception/handlers/ProblemDetailErrorAttributes.java index c3a401be44..e65c36d435 100644 --- a/application/src/main/java/run/halo/app/infra/exception/handlers/ProblemDetailErrorAttributes.java +++ b/application/src/main/java/run/halo/app/infra/exception/handlers/ProblemDetailErrorAttributes.java @@ -40,7 +40,6 @@ public Map getErrorAttributes(ServerRequest request, @Override public Throwable getError(ServerRequest request) { return (Throwable) request.attribute(ERROR_INTERNAL_ATTRIBUTE).stream() - .peek(error -> request.attributes().putIfAbsent(ERROR_ATTRIBUTE, error)) .findFirst() .orElseThrow(() -> new IllegalStateException( "Missing exception attribute in ServerWebExchange")); diff --git a/application/src/main/java/run/halo/app/theme/finders/impl/CommentPublicQueryServiceImpl.java b/application/src/main/java/run/halo/app/theme/finders/impl/CommentPublicQueryServiceImpl.java index 29eb383db0..8336ee93c1 100644 --- a/application/src/main/java/run/halo/app/theme/finders/impl/CommentPublicQueryServiceImpl.java +++ b/application/src/main/java/run/halo/app/theme/finders/impl/CommentPublicQueryServiceImpl.java @@ -272,7 +272,7 @@ public int compare(Comment c1, Comment c2) { var creationTimeComparator = Comparator.comparing( comment -> comment.getSpec().getCreationTime(), - Comparators.nullsLow(Comparator.reverseOrder())); + Comparators.nullsHigh(Comparator.reverseOrder())); var nameComparator = Comparator.comparing( comment -> comment.getMetadata().getName()); diff --git a/gradle.properties b/gradle.properties index 910803e42c..c7eda50352 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,2 +1 @@ version=2.12.0-SNAPSHOT -snakeyaml.version=2.2 diff --git a/platform/application/build.gradle b/platform/application/build.gradle index 7905d86503..6ee5551e21 100644 --- a/platform/application/build.gradle +++ b/platform/application/build.gradle @@ -1,7 +1,7 @@ import org.springframework.boot.gradle.plugin.SpringBootPlugin plugins { - id 'org.springframework.boot' version '3.2.0' apply false + id 'org.springframework.boot' version '3.2.2' apply false id 'java-platform' id 'halo.publish' id 'signing' From 8523a67e06ac042446ba4a4c6f45786fd9cc058e Mon Sep 17 00:00:00 2001 From: guqing <38999863+guqing@users.noreply.github.com> Date: Tue, 23 Jan 2024 16:19:19 +0800 Subject: [PATCH 3/3] refactor: logic for subList method when retrieving all data (#5235) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit #### What type of PR is this? /kind improvement /area core /milestone 2.12.x #### What this PR does / why we need it: 重构 ListResult.subList 方法在获取所有数据时的处理逻辑,只要 size 为 0 就返回所有数据 #### Does this PR introduce a user-facing change? ```release-note None ``` --- .../run/halo/app/extension/ListResult.java | 3 +++ .../halo/app/extension/ListResultTest.java | 22 +++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/api/src/main/java/run/halo/app/extension/ListResult.java b/api/src/main/java/run/halo/app/extension/ListResult.java index 3a487959f3..cc64ef9170 100644 --- a/api/src/main/java/run/halo/app/extension/ListResult.java +++ b/api/src/main/java/run/halo/app/extension/ListResult.java @@ -129,6 +129,9 @@ public static ListResult emptyResult() { */ public static List subList(List list, int page, int size) { if (page < 1) { + page = 1; + } + if (size < 1) { return list; } List listSort = new ArrayList<>(); diff --git a/application/src/test/java/run/halo/app/extension/ListResultTest.java b/application/src/test/java/run/halo/app/extension/ListResultTest.java index f707dc8b0b..98a118ec5d 100644 --- a/application/src/test/java/run/halo/app/extension/ListResultTest.java +++ b/application/src/test/java/run/halo/app/extension/ListResultTest.java @@ -43,4 +43,26 @@ void totalPages() { listResult = new ListResult<>(1, 0, 100, List.of()); assertEquals(1, listResult.getTotalPages()); } + + @Test + void subListWhenSizeIsZero() { + var list = List.of(1, 2, 3, 4, 5); + assertSubList(list); + + list = List.of(1); + assertSubList(list); + } + + private void assertSubList(List list) { + var result = ListResult.subList(list, 0, 0); + assertEquals(list, result); + + result = ListResult.subList(list, 0, 1); + assertEquals(list.subList(0, 1), result); + + result = ListResult.subList(list, 1, 0); + assertEquals(list, result); + + assertEquals(list.subList(0, 1), ListResult.subList(list, -1, 1)); + } } \ No newline at end of file