Skip to content

Commit

Permalink
fix: 페이지네이션 cursor 버그 수정
Browse files Browse the repository at this point in the history
* refactor: ModelAttribute 명시

* fix: cursor 디폴트 -1로 수정
  • Loading branch information
jjuny0310 authored Oct 19, 2023
1 parent a6cdc15 commit 0fc757b
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,35 +73,36 @@ public EnvelopeResponse<PostIdElement> updatePost(@Valid @RequestBody PostPatchU
}

@GetMapping("/hot")
public EnvelopeResponse<GetPostResDto> findHotPosts(@Valid GetPostHotReqDto getPostHotReqDto) {
public EnvelopeResponse<GetPostResDto> findHotPosts(@Valid @ModelAttribute GetPostHotReqDto getPostHotReqDto) {
log.info(String.valueOf(getPostHotReqDto.getCursor()));
return EnvelopeResponse.<GetPostResDto>builder()
.data(postService.findHotPosts(getPostHotReqDto))
.build();
}

@GetMapping("/my")
public EnvelopeResponse<GetPostResDto> findMyPosts(@Valid GetPostMyReqDto getPostMyReqDto, @Authentication AuthenticatedMember loginMember) {
public EnvelopeResponse<GetPostResDto> findMyPosts(@Valid @ModelAttribute GetPostMyReqDto getPostMyReqDto, @Authentication AuthenticatedMember loginMember) {
return EnvelopeResponse.<GetPostResDto>builder()
.data(postService.findMyPosts(getPostMyReqDto, loginMember.getMemberId()))
.build();
}

@GetMapping("/my-scrap")
public EnvelopeResponse<GetPostResDto> findMyScrapPosts(@Valid GetPostMyReqDto getPostMyScrapReqDto, @Authentication AuthenticatedMember loginMember) {
public EnvelopeResponse<GetPostResDto> findMyScrapPosts(@Valid @ModelAttribute GetPostMyReqDto getPostMyScrapReqDto, @Authentication AuthenticatedMember loginMember) {
return EnvelopeResponse.<GetPostResDto>builder()
.data(postService.findMyScrapPosts(getPostMyScrapReqDto, loginMember.getMemberId()))
.build();
}

@GetMapping("/search")
public EnvelopeResponse<GetPostResDto> searchPosts(@Valid GetPostSearchReqDto getPostSearchReqDto) {
public EnvelopeResponse<GetPostResDto> searchPosts(@Valid @ModelAttribute GetPostSearchReqDto getPostSearchReqDto) {
return EnvelopeResponse.<GetPostResDto>builder()
.data(postService.searchPosts(getPostSearchReqDto))
.build();
}

@GetMapping("/hot/search")
public EnvelopeResponse<GetPostResDto> searchHotPosts(@Valid GetPostHotSearchReqDto getPostHotSearchReqDto) {
public EnvelopeResponse<GetPostResDto> searchHotPosts(@Valid @ModelAttribute GetPostHotSearchReqDto getPostHotSearchReqDto) {
return EnvelopeResponse.<GetPostResDto>builder()
.data(postService.searchHotPosts(getPostHotSearchReqDto))
.build();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
package com.ssafy.ssafsound.domain.post.dto;

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

import javax.validation.constraints.Min;

@Getter
@Setter
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class GetPostHotReqDto {
private Long cursor;
private Long cursor = -1L;

@Min(value = 10, message = "Size가 너무 작습니다.")
private int size;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
package com.ssafy.ssafsound.domain.post.dto;

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

import javax.validation.constraints.Min;

@Getter
@Setter
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class GetPostMyReqDto {
private Long cursor;
private Long cursor = -1L;

@Min(value = 10, message = "Size가 너무 작습니다.")
private int size;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,24 @@
package com.ssafy.ssafsound.domain.post.dto;

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

import javax.validation.constraints.Min;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Size;

@Getter
@Setter
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class GetPostSearchReqDto {
private Long boardId;

@Size(min = 2)
@NotBlank
private String keyword;

private Long cursor;
private Long cursor = -1L;

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

0 comments on commit 0fc757b

Please sign in to comment.