diff --git a/src/main/java/slvtwn/khu/toyouserver/persistance/RollingPaperRepository.java b/src/main/java/slvtwn/khu/toyouserver/persistance/RollingPaperRepository.java index 84236ea..c08a4dc 100644 --- a/src/main/java/slvtwn/khu/toyouserver/persistance/RollingPaperRepository.java +++ b/src/main/java/slvtwn/khu/toyouserver/persistance/RollingPaperRepository.java @@ -9,7 +9,7 @@ public interface RollingPaperRepository extends JpaRepository { - @Query("SELECT r FROM RollingPaper r WHERE r.member.id IN :memberIds AND r.id < :targetId ORDER BY r.id DESC") + @Query("SELECT r FROM RollingPaper r WHERE r.member.id IN :memberIds AND r.id >= :targetId ORDER BY r.id DESC") List findAllByMembersAfterCursor(@Param("memberIds") List memberIds, @Param("targetId") Long targetId, Pageable pageable); diff --git a/src/main/java/slvtwn/khu/toyouserver/presentation/RollingPaperController.java b/src/main/java/slvtwn/khu/toyouserver/presentation/RollingPaperController.java index e3f7a02..0479c52 100644 --- a/src/main/java/slvtwn/khu/toyouserver/presentation/RollingPaperController.java +++ b/src/main/java/slvtwn/khu/toyouserver/presentation/RollingPaperController.java @@ -29,8 +29,8 @@ public ToyouResponse findById(@UserAuthentication Long use @GetMapping("/rollingpapers") public ToyouResponse> findReceivedRollingPapers(@UserAuthentication Long userId, - @RequestParam Long groupId, - @RequestParam Long targetId, + @RequestParam(required = false) Long groupId, + @RequestParam(defaultValue = "0") Long targetId, @RequestParam(defaultValue = "10") int limit) { return ToyouResponse.from(rollingPaperService.findReceivedRollingPapers(userId, groupId, targetId, limit)); } diff --git a/src/test/java/slvtwn/khu/toyouserver/application/RollingPaperServiceTest.java b/src/test/java/slvtwn/khu/toyouserver/application/RollingPaperServiceTest.java index 74b6ce0..75e0a97 100644 --- a/src/test/java/slvtwn/khu/toyouserver/application/RollingPaperServiceTest.java +++ b/src/test/java/slvtwn/khu/toyouserver/application/RollingPaperServiceTest.java @@ -2,8 +2,6 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatCode; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.BDDMockito.given; import jakarta.persistence.EntityManager; import jakarta.persistence.PersistenceContext; @@ -14,13 +12,11 @@ import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.transaction.annotation.Transactional; import slvtwn.khu.toyouserver.domain.Group; import slvtwn.khu.toyouserver.domain.Member; import slvtwn.khu.toyouserver.domain.RollingPaper; import slvtwn.khu.toyouserver.domain.User; -import slvtwn.khu.toyouserver.dto.CoverRequest; import slvtwn.khu.toyouserver.dto.RollingPaperRequest; import slvtwn.khu.toyouserver.dto.RollingPaperResponse; @@ -125,7 +121,7 @@ class RollingPaperServiceTest { // when List response = rollingPaperService.findReceivedRollingPapers(user.getId(), group.getId(), - rollingPaper.getId() + 1, 10); + 0L, 10); // then assertThat(response).usingRecursiveComparison() @@ -155,7 +151,7 @@ class RollingPaperServiceTest { List responseWithoutGroupId = rollingPaperService.findReceivedRollingPapers( user.getId(), null, - anotherRollingPaper.getId() + 1, 10); + 0L, 10); // then assertThat(responseWithoutGroupId).usingRecursiveComparison() @@ -188,7 +184,7 @@ class RollingPaperServiceTest { List responseWithGroupId = rollingPaperService.findReceivedRollingPapers( user.getId(), group1.getId(), - rollingPaper.getId() + 1, 10); + 0L, 10); // then assertThat(responseWithGroupId).usingRecursiveComparison() @@ -217,13 +213,11 @@ class RollingPaperServiceTest { entityManager.persist(rollingPaper2); entityManager.persist(rollingPaper3); - long totalRollingPapersCount = rollingPaper3.getId() + 1; - // when List response = rollingPaperService.findReceivedRollingPapers( user.getId(), group1.getId(), - totalRollingPapersCount, 10); + 0L, 10); // then List expectedResponse = List.of( @@ -257,7 +251,7 @@ class RollingPaperServiceTest { List response = rollingPaperService.findReceivedRollingPapers( user.getId(), group.getId(), - rollingPaper3.getId() + 1, 10); + 0L, 10); // then List expectedResponse = List.of(