Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

게시글 다중 조회 정렬 기준 id 로 변경 #499

Merged
merged 3 commits into from
Sep 18, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public ResponseEntity<Void> deleteByRunnerPostId(@AuthRunnerPrincipal final Runn

@GetMapping
public ResponseEntity<PageResponse<RunnerPostResponse.Simple>> readRunnerPostsByReviewStatus(
@PageableDefault(sort = {"createdAt", "id"}, direction = DESC) final Pageable pageable,
@PageableDefault(sort = {"id"}, direction = DESC) final Pageable pageable,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

{}로 다 빼는게 어떨까요?

@RequestParam("reviewStatus") final ReviewStatus reviewStatus
) {
final Page<RunnerPost> pageRunnerPosts = runnerPostService.readRunnerPostsByReviewStatus(pageable, reviewStatus);
Expand All @@ -111,7 +111,7 @@ public ResponseEntity<PageResponse<RunnerPostResponse.Simple>> readRunnerPostsBy

@GetMapping("/search")
public ResponseEntity<PageResponse<RunnerPostResponse.ReferencedBySupporter>> readReferencedBySupporter(
@PageableDefault(sort = {"createdAt", "id"}, direction = DESC) final Pageable pageable,
@PageableDefault(sort = {"id"}, direction = DESC) final Pageable pageable,
@RequestParam("supporterId") final Long supporterId,
@RequestParam("reviewStatus") final ReviewStatus reviewStatus
) {
Expand Down Expand Up @@ -146,7 +146,7 @@ public ResponseEntity<SupporterRunnerPostResponses.Detail> readSupporterRunnerPo

@GetMapping("/me/supporter")
public ResponseEntity<PageResponse<RunnerPostResponse.ReferencedBySupporter>> readRunnerPostsByLoginedSupporterAndReviewStatus(
@PageableDefault(sort = {"createdAt", "id"}, direction = DESC) final Pageable pageable,
@PageableDefault(sort = {"id"}, direction = DESC) final Pageable pageable,
@AuthSupporterPrincipal final Supporter supporter,
@RequestParam("reviewStatus") final ReviewStatus reviewStatus
) {
Expand All @@ -169,7 +169,7 @@ public ResponseEntity<PageResponse<RunnerPostResponse.ReferencedBySupporter>> re

@GetMapping("/me/runner")
public ResponseEntity<PageResponse<RunnerPostResponse.SimpleInMyPage>> readRunnerMyPage(
@PageableDefault(sort = {"createdAt", "id"}, direction = DESC) final Pageable pageable,
@PageableDefault(sort = {"id"}, direction = DESC) final Pageable pageable,
@AuthRunnerPrincipal final Runner runner,
@RequestParam("reviewStatus") final ReviewStatus reviewStatus
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public class RunnerPostReadController {

@GetMapping("/tags/search")
public ResponseEntity<PageResponse<RunnerPostResponse.Simple>> readRunnerPostsByTagNamesAndReviewStatus(
@PageableDefault(sort = "createdAt", direction = DESC) final Pageable pageable,
@PageableDefault(sort = "id", direction = DESC) final Pageable pageable,
@RequestParam final String tagName,
@RequestParam final ReviewStatus reviewStatus
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,10 +144,8 @@ void findByReviewStatus_when_createAt_is_same() {
insertRunnerPostByNativeQuery(2L, createdAt, runnerId);

// when
final PageRequest pageable = PageRequest.of(0, 10, Sort.by(
Sort.Order.desc("createdAt"),
Sort.Order.desc("id")
));
final PageRequest pageable = PageRequest.of(0, 10, Sort.by(Sort.Order.desc("id")));

Comment on lines +147 to +148
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

createdAt이 정렬 조건에서 빠지면서 repository 테스트 명도 변경되어야 할 거 같아요!

final Page<RunnerPost> actual = runnerPostRepository.findByReviewStatus(pageable, NOT_STARTED);

// then
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ void readRunnerPostByTagNameAndReviewStatus() {
));

// when
final PageRequest pageOne = PageRequest.of(0, 10, Sort.by(Sort.Order.desc("createdAt")));
final PageRequest pageOne = PageRequest.of(0, 10, Sort.by(Sort.Order.desc("id")));
final Page<RunnerPost> actual = runnerPostReadService.readRunnerPostByTagNameAndReviewStatus(
pageOne,
javaTag.getTagName().getValue(),
Expand Down