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

fix: 페이지네이션 cursor 버그 수정 #265

Merged
merged 2 commits into from
Oct 19, 2023
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
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@

import com.ssafy.ssafsound.domain.auth.dto.AuthenticatedMember;
import com.ssafy.ssafsound.domain.auth.validator.Authentication;
import com.ssafy.ssafsound.domain.post.dto.GetPostDetailResDto;
import com.ssafy.ssafsound.domain.post.dto.GetPostResDto;
import com.ssafy.ssafsound.domain.post.dto.PostPostWriteReqDto;
import com.ssafy.ssafsound.domain.post.dto.*;
import com.ssafy.ssafsound.domain.post.service.PostService;
import com.ssafy.ssafsound.global.common.response.EnvelopeResponse;
Expand All @@ -23,7 +20,7 @@ public class PostController {
private final PostService postService;

@GetMapping
public EnvelopeResponse<GetPostResDto> findPosts(@Valid GetPostReqDto getPostReqDto) {
public EnvelopeResponse<GetPostResDto> findPosts(@Valid @ModelAttribute GetPostReqDto getPostReqDto) {
return EnvelopeResponse.<GetPostResDto>builder()
.data(postService.findPosts(getPostReqDto))
.build();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
package com.ssafy.ssafsound.domain.post.dto;

import lombok.Builder;
import lombok.Getter;
import lombok.Setter;
import lombok.*;

import javax.validation.constraints.Min;

@Getter
@Setter
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class GetPostReqDto {
private Long boardId;
private Long cursor;
private Long cursor = -1L;
Comment on lines +10 to +14
Copy link
Collaborator

Choose a reason for hiding this comment

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

DTO에 default value를 주기 위해서는 @ModelAttribute와 해당 어노테이션들이 추가되어야하나요?

Copy link
Member Author

Choose a reason for hiding this comment

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

  1. ModelAttribute는 가독성을 위해 명시 해준 것입니다.(안써도 동작은 합니다)

  2. 입력받지 않아도 null이 아닌 디폴트값으로 초기화 하기 위해서는 기본생성자가 필요합니다.
    추가로 테스트코드에서 dto값 세팅을 위해 Builder가 필요했습니다. 하지만 Bulider를 사용하기 위해서는 기본생성자 사용 시 매개변수가 있는 생성자가 반드시 필요하기 때문에 해당 어노테이션들을 클래스에 추가했습니다


@Min(value = 10, message = "Size가 너무 작습니다.")
private int size;

}
Loading