Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/unit-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
build:
runs-on: ubuntu-latest
env:
SPRING_BASE_COMMONS_VERSION: 2.4.1
SPRING_BASE_COMMONS_VERSION: 2.4.2
steps:
- uses: actions/checkout@v4
- name: Set up JDK 25
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ ENV APP_NAME=app.jar
ENV DEPS_FILE=deps.info

# Change this when there is an update
ENV SPRING_BASE_COMMONS_VERSION=2.4.1
ENV SPRING_BASE_COMMONS_VERSION=2.4.2

# Clone the spring-base-commons repository
RUN git clone --depth 1 --branch ${SPRING_BASE_COMMONS_VERSION} https://github.com/vulinh64/spring-base-commons.git
Expand Down
2 changes: 1 addition & 1 deletion create-data-classes.cmd
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
@echo off

SET SPRING_BASE_COMMONS_VERSION=2.4.1
SET SPRING_BASE_COMMONS_VERSION=2.4.2

IF EXIST .\build\spring-base-commons rmdir /s /q .\build\spring-base-commons

Expand Down
2 changes: 1 addition & 1 deletion create-data-classes.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

set -e

SPRING_BASE_COMMONS_VERSION=2.4.1
SPRING_BASE_COMMONS_VERSION=2.4.2

if [ -d "./build/spring-base-commons" ]; then
rm -rf ./build/spring-base-commons
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
<!-- this should be fixed by Spring in the future -->
<netty.version>4.2.9.Final</netty.version>

<spring-base-commons.version>2.4.1</spring-base-commons.version>
<spring-base-commons.version>2.4.2</spring-base-commons.version>
</properties>

<dependencies>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@

@Repository
public interface CommentRevisionRepository
extends org.springframework.data.jpa.repository.JpaRepository<CommentRevision, CommentRevisionId>, org.springframework.data.jpa.repository.JpaSpecificationExecutor<CommentRevision>, org.springframework.data.querydsl.ListQuerydslPredicateExecutor<CommentRevision>, org.springframework.data.repository.query.QueryByExampleExecutor<CommentRevision> {}
extends BaseRepository<CommentRevision, CommentRevisionId> {}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import org.springframework.stereotype.Repository;

@Repository
public interface PostRepository extends org.springframework.data.jpa.repository.JpaRepository<Post, UUID>, org.springframework.data.jpa.repository.JpaSpecificationExecutor<Post>, org.springframework.data.querydsl.ListQuerydslPredicateExecutor<Post>, org.springframework.data.repository.query.QueryByExampleExecutor<Post> {
public interface PostRepository extends BaseRepository<Post, UUID> {

@Query(
"""
Expand Down
21 changes: 9 additions & 12 deletions src/main/java/com/vulinh/service/post/PostRevisionService.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,14 @@
import com.vulinh.locale.ServiceErrorCode;
import com.vulinh.service.category.CategoryService;
import com.vulinh.service.tag.TagService;
import com.vulinh.utils.DslOrderBuilder;
import com.vulinh.utils.SecurityUtils;
import jakarta.persistence.EntityManager;
import jakarta.persistence.PersistenceContext;
import lombok.RequiredArgsConstructor;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.data.domain.Sort.Order;
import org.springframework.data.querydsl.QPageRequest;
import org.springframework.data.repository.query.FluentQuery;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
Expand All @@ -50,16 +49,14 @@ public Page<PostRevisionResponse> getPostRevisions(UUID postId, Pageable pageabl
throw NotFound404Exception.postNotFound(postId);
}

var actualPageable =
PageRequest.of(
pageable.getPageNumber(),
pageable.getPageSize(),
Sort.by(
Order.desc(
QPostRevision.postRevision.revisionCreatedDateTime.getMetadata().getName())));

return postRevisionRepository
.findByPostIdOrPostSlug(postId, actualPageable)
.findByPostIdOrPostSlug(
postId,
QPageRequest.of(
pageable.getPageNumber(),
pageable.getPageSize(),
DslOrderBuilder.fromField(QPostRevision.postRevision.revisionCreatedDateTime)
.withDesc()))
.map(POST_MAPPER::toPostRevisionResponse);
}

Expand Down