From d4c86f11800e17526f310dc1a841c89d50f45cf8 Mon Sep 17 00:00:00 2001 From: yerim1ee Date: Fri, 7 Mar 2025 17:33:10 +0900 Subject: [PATCH 1/3] =?UTF-8?q?feat:=20=ED=8E=98=EC=9D=B4=EC=A7=80=20?= =?UTF-8?q?=EB=8D=B0=EC=9D=B4=ED=84=B0=20=EB=A7=A4=ED=95=91=20dto=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80=20[PRBE-29]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../global/common/DataPageMappingDto.java | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 src/main/java/com/olive/pribee/global/common/DataPageMappingDto.java diff --git a/src/main/java/com/olive/pribee/global/common/DataPageMappingDto.java b/src/main/java/com/olive/pribee/global/common/DataPageMappingDto.java new file mode 100644 index 0000000..04ffbf7 --- /dev/null +++ b/src/main/java/com/olive/pribee/global/common/DataPageMappingDto.java @@ -0,0 +1,41 @@ +package com.olive.pribee.global.common; + +import lombok.Getter; + +@Getter +public class DataPageMappingDto { + private final T data; + private final long totalElements; + private final int totalPages; + private final int size; + private final int numberOfElements; + + private DataPageMappingDto(T data, long totalElements, int totalPages, int size, + int numberOfElements) { + this.data = data; + this.totalElements = totalElements; + this.size = size; + this.numberOfElements = numberOfElements; + this.totalPages = totalPages; + } + + private DataPageMappingDto(T data, String message, long totalElements, int totalPages, int size, + int numberOfElements) { + this.data = data; + this.totalElements = totalElements; + this.size = size; + this.numberOfElements = numberOfElements; + this.totalPages = totalPages; + } + + public static DataPageMappingDto of(T data, long totalElements, int totalPages, int size, + int numberOfElements) { + return new DataPageMappingDto<>(data, totalElements, totalPages, size, numberOfElements); + } + + public static DataPageMappingDto of(T data, Integer code, String message, long totalElements, + int totalPages, int size, + int numberOfElements) { + return new DataPageMappingDto<>(data, message, totalElements, totalPages, size, numberOfElements); + } +} \ No newline at end of file From c0685269355b7b3a8c45ad5df694834ee185dfaa Mon Sep 17 00:00:00 2001 From: yerim1ee Date: Fri, 7 Mar 2025 17:33:44 +0900 Subject: [PATCH 2/3] =?UTF-8?q?fix:=20=ED=8E=98=EC=9D=B4=EC=A7=80=20?= =?UTF-8?q?=EB=8D=B0=EC=9D=B4=ED=84=B0=20=EB=A7=A4=ED=95=91=EC=9D=84=20?= =?UTF-8?q?=ED=86=B5=ED=95=9C=20paging=20=EC=A0=95=EB=B3=B4=20=EC=A4=91?= =?UTF-8?q?=EB=B3=B5=EC=9C=BC=EB=A1=9C=20=EB=82=98=EC=98=A4=EC=A7=80=20?= =?UTF-8?q?=EC=95=8A=EB=8F=84=EB=A1=9D=20=EC=B2=98=EB=A6=AC=20[PRBE-29]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pribee/module/feed/dto/res/FbPostTotalRes.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/olive/pribee/module/feed/dto/res/FbPostTotalRes.java b/src/main/java/com/olive/pribee/module/feed/dto/res/FbPostTotalRes.java index 1b63516..1ef4fe5 100644 --- a/src/main/java/com/olive/pribee/module/feed/dto/res/FbPostTotalRes.java +++ b/src/main/java/com/olive/pribee/module/feed/dto/res/FbPostTotalRes.java @@ -1,7 +1,11 @@ package com.olive.pribee.module.feed.dto.res; +import java.util.List; + import org.springframework.data.domain.Page; +import com.olive.pribee.global.common.DataPageMappingDto; + import io.swagger.v3.oas.annotations.media.Schema; import lombok.AccessLevel; import lombok.Builder; @@ -22,7 +26,7 @@ public class FbPostTotalRes { private Double averageDangerScore; @Schema(description = "게시물 정보") - private Page fbPostResPage; + private DataPageMappingDto> fbPostResPage; public static FbPostTotalRes of( long totalPostCount, @@ -30,11 +34,13 @@ public static FbPostTotalRes of( Double averageDangerScore, Page fbPostResPage ) { + return FbPostTotalRes.builder() .totalPostCount(totalPostCount) .detectPostCount(detectPostCount) .averageDangerScore(averageDangerScore) - .fbPostResPage(fbPostResPage) + .fbPostResPage(DataPageMappingDto.of(fbPostResPage.getContent(), fbPostResPage.getTotalElements(), + fbPostResPage.getTotalPages(), fbPostResPage.getSize(), fbPostResPage.getNumberOfElements())) .build(); } } From 8742f165ccdf08aaa4ba6ac9c84bf53fc5bd0dca Mon Sep 17 00:00:00 2001 From: yerim1ee Date: Fri, 7 Mar 2025 17:34:12 +0900 Subject: [PATCH 3/3] =?UTF-8?q?fix:=20=EB=8D=B0=EC=9D=B4=ED=84=B0=20?= =?UTF-8?q?=EB=A7=A4=ED=95=91=EB=90=9C=20=ED=8E=98=EC=9D=B4=EC=A7=95=20?= =?UTF-8?q?=EC=A0=95=EB=B3=B4=20=EB=B0=98=ED=99=98=ED=95=98=EB=8F=84?= =?UTF-8?q?=EB=A1=9D=20api=20=EC=88=98=EC=A0=95=20[PRBE-29]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../module/feed/controller/FbPostController.java | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/src/main/java/com/olive/pribee/module/feed/controller/FbPostController.java b/src/main/java/com/olive/pribee/module/feed/controller/FbPostController.java index 349ef1e..98a0e54 100644 --- a/src/main/java/com/olive/pribee/module/feed/controller/FbPostController.java +++ b/src/main/java/com/olive/pribee/module/feed/controller/FbPostController.java @@ -1,6 +1,5 @@ package com.olive.pribee.module.feed.controller; -import org.springframework.data.domain.Page; import org.springframework.http.ResponseEntity; import org.springframework.security.core.annotation.AuthenticationPrincipal; import org.springframework.web.bind.annotation.GetMapping; @@ -9,11 +8,10 @@ import org.springframework.web.bind.annotation.RestController; import com.mongodb.lang.Nullable; -import com.olive.pribee.global.common.DataPageResponseDto; +import com.olive.pribee.global.common.DataResponseDto; import com.olive.pribee.global.common.ResponseDto; import com.olive.pribee.global.enums.DetectKeyword; import com.olive.pribee.module.auth.domain.entity.Member; -import com.olive.pribee.module.feed.dto.res.FbPostRes; import com.olive.pribee.module.feed.dto.res.FbPostTotalRes; import com.olive.pribee.module.feed.service.FbPostService; @@ -32,14 +30,12 @@ public class FbPostController implements FbPostControllerDocs { @GetMapping public ResponseEntity getExhibitions( @AuthenticationPrincipal Member member, - @Schema(description = "필터를 의미합니다.") @RequestParam(name = "detectType") @Nullable DetectKeyword detectType, - @Schema(description = "검색어를 의미합니다.") @RequestParam(name = "keyword") @Nullable String keyword, - @Schema(description = "0번부터 시작합니다. 조회할 페이지 번호를 의미합니다.") @RequestParam(name = "page") int page, - @Schema(description = "조회할 페이지 크기를 의미합니다.") @RequestParam(name = "size") int size) { + @Schema(description = "필터를 의미합니다.") @RequestParam(name = "detectType") @Nullable DetectKeyword detectType, + @Schema(description = "검색어를 의미합니다.") @RequestParam(name = "keyword") @Nullable String keyword, + @Schema(description = "0번부터 시작합니다. 조회할 페이지 번호를 의미합니다.") @RequestParam(name = "page") int page, + @Schema(description = "조회할 페이지 크기를 의미합니다.") @RequestParam(name = "size") int size) { FbPostTotalRes resPage = fbPostService.getTotalPost(member.getId(), detectType, keyword, page, size); - return ResponseEntity.status(200).body( - DataPageResponseDto.of(resPage.getFbPostResPage().getContent(), 200, resPage.getFbPostResPage().getTotalElements(), - resPage.getFbPostResPage().getTotalPages(), resPage.getFbPostResPage().getSize(), resPage.getFbPostResPage().getNumberOfElements())); + return ResponseEntity.status(200).body(DataResponseDto.of(resPage, 200)); } // 게시물 첨부 조회