From 3dba168610164d28342ffc50061dd24f5a873d2a Mon Sep 17 00:00:00 2001 From: hd0rable Date: Sun, 4 Aug 2024 18:07:17 +0900 Subject: [PATCH 1/5] =?UTF-8?q?fix=20:=20=EC=BB=A8=ED=8A=B8=EB=A1=A4?= =?UTF-8?q?=EB=9F=AC=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/example/likelion12/controller/CrewController.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/example/likelion12/controller/CrewController.java b/src/main/java/com/example/likelion12/controller/CrewController.java index d053b22..ff2be70 100644 --- a/src/main/java/com/example/likelion12/controller/CrewController.java +++ b/src/main/java/com/example/likelion12/controller/CrewController.java @@ -1,6 +1,7 @@ package com.example.likelion12.controller; import com.example.likelion12.common.response.BaseResponse; +import com.example.likelion12.dto.SearchRequest; import com.example.likelion12.dto.crew.*; import com.example.likelion12.service.CrewService; import com.example.likelion12.util.*; @@ -34,10 +35,10 @@ public BaseResponse createCrew(@RequestHeader("Authorization") */ @GetMapping("/inquiry") public BaseResponse> getCrewInquiries(@RequestHeader("Authorization") String authorization, - @RequestParam List crewId){ + @RequestBody SearchRequest searchRequest){ log.info("[CrewController.getCrewInquiries]"); Long memberId = jwtProvider.extractIdFromHeader(authorization); - return new BaseResponse<>(crewService.getCrewInquiries(memberId, crewId)); + return new BaseResponse<>(crewService.getCrewInquiries(memberId,searchRequest)); } From a184c733d9b996e5eeb065a1d611718fde1f72f4 Mon Sep 17 00:00:00 2001 From: hd0rable Date: Sun, 4 Aug 2024 18:07:30 +0900 Subject: [PATCH 2/5] =?UTF-8?q?fix=20:=20=ED=8E=98=EC=9D=B4=EC=A7=95=20?= =?UTF-8?q?=EA=B8=B0=EB=8A=A5=20=EC=B6=94=EA=B0=80=EC=97=90=EB=94=B0?= =?UTF-8?q?=EB=A5=B8=20=EC=84=9C=EB=B9=84=EC=8A=A4=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../example/likelion12/service/CrewService.java | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/example/likelion12/service/CrewService.java b/src/main/java/com/example/likelion12/service/CrewService.java index 2d7c060..4885b97 100644 --- a/src/main/java/com/example/likelion12/service/CrewService.java +++ b/src/main/java/com/example/likelion12/service/CrewService.java @@ -5,6 +5,7 @@ import com.example.likelion12.domain.base.BaseGender; import com.example.likelion12.domain.base.BaseLevel; import com.example.likelion12.domain.base.BaseStatus; +import com.example.likelion12.dto.SearchRequest; import com.example.likelion12.dto.crew.*; import com.example.likelion12.repository.*; import lombok.RequiredArgsConstructor; @@ -76,16 +77,20 @@ public PostCrewResponse createCrew(Long memberId, PostCrewRequest postCrewReques /** * 크루 조회 */ - public List getCrewInquiries(Long memberId, List crewIds) { + public List getCrewInquiries(Long memberId, SearchRequest searchRequest) { log.info("[CrewService.getCrewInquiries]"); + List allCrews = crewRepository.findAllByStatus(BaseStatus.ACTIVE); List getCrewInquiryResponses = new ArrayList<>(); - for (Long crewId : crewIds) { + // offset과 limit 계산 + int offset = searchRequest.getOffset(); + int recordSize = searchRequest.getRecordSize(); + + // 페이징 처리된 크루 목록 생성 + for (int i = offset; i < Math.min(offset + recordSize, allCrews.size()); i++) { - //조회하고자 하는 크루 - Crew crew = crewRepository.findByCrewIdAndStatus(crewId, BaseStatus.ACTIVE) - .orElseThrow(() -> new CrewException(CANNOT_FOUND_CREW)); + Crew crew = allCrews.get(i); GetCrewInquiryResponse response = new GetCrewInquiryResponse( crew.getCrewName(), From b88cef2656f628fd98f36a40331d6f46a9317a85 Mon Sep 17 00:00:00 2001 From: hd0rable Date: Sun, 4 Aug 2024 18:07:48 +0900 Subject: [PATCH 3/5] =?UTF-8?q?feat=20:=20=ED=8E=98=EC=9D=B4=EC=A7=95=20?= =?UTF-8?q?=EC=B2=98=EB=A6=AC=EB=A5=BC=20=EC=9C=84=ED=95=9C=20dto=20?= =?UTF-8?q?=EC=9E=91=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../example/likelion12/dto/SearchRequest.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 src/main/java/com/example/likelion12/dto/SearchRequest.java diff --git a/src/main/java/com/example/likelion12/dto/SearchRequest.java b/src/main/java/com/example/likelion12/dto/SearchRequest.java new file mode 100644 index 0000000..af104c5 --- /dev/null +++ b/src/main/java/com/example/likelion12/dto/SearchRequest.java @@ -0,0 +1,17 @@ +package com.example.likelion12.dto; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +@Getter +@AllArgsConstructor +public class SearchRequest { + + private int page; // 현재 페이지 번호 + private int recordSize; // 페이지당 출력할 데이터 개수 + private int pageSize; // 화면 하단에 출력할 페이지 사이즈 + + public int getOffset() { + return (page - 1) * recordSize; + } +} From 1e85f248dafae461fd704f3766b726903f2969d9 Mon Sep 17 00:00:00 2001 From: hd0rable Date: Mon, 5 Aug 2024 19:57:27 +0900 Subject: [PATCH 4/5] =?UTF-8?q?fix=20:=20=ED=8E=98=EC=9D=B4=EC=A7=95?= =?UTF-8?q?=EC=B2=98=EB=A6=AC=20request=20dto=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/example/likelion12/dto/SearchRequest.java | 4 +--- src/main/java/com/example/likelion12/service/CrewService.java | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/example/likelion12/dto/SearchRequest.java b/src/main/java/com/example/likelion12/dto/SearchRequest.java index af104c5..ed43c36 100644 --- a/src/main/java/com/example/likelion12/dto/SearchRequest.java +++ b/src/main/java/com/example/likelion12/dto/SearchRequest.java @@ -8,10 +8,8 @@ public class SearchRequest { private int page; // 현재 페이지 번호 - private int recordSize; // 페이지당 출력할 데이터 개수 - private int pageSize; // 화면 하단에 출력할 페이지 사이즈 public int getOffset() { - return (page - 1) * recordSize; + return (page - 1) * 9; } } diff --git a/src/main/java/com/example/likelion12/service/CrewService.java b/src/main/java/com/example/likelion12/service/CrewService.java index 4885b97..5194d04 100644 --- a/src/main/java/com/example/likelion12/service/CrewService.java +++ b/src/main/java/com/example/likelion12/service/CrewService.java @@ -85,7 +85,7 @@ public List getCrewInquiries(Long memberId, SearchReques // offset과 limit 계산 int offset = searchRequest.getOffset(); - int recordSize = searchRequest.getRecordSize(); + int recordSize = 9 ; // 페이징 처리된 크루 목록 생성 for (int i = offset; i < Math.min(offset + recordSize, allCrews.size()); i++) { From 91aacad0ddedac082f9831ea196287812cb8fa7b Mon Sep 17 00:00:00 2001 From: hd0rable Date: Tue, 6 Aug 2024 01:13:32 +0900 Subject: [PATCH 5/5] =?UTF-8?q?fix=20:=20=ED=81=AC=EB=A3=A8=20=EC=A1=B0?= =?UTF-8?q?=ED=9A=8C=20dto=EC=88=98=EC=A0=95=EC=97=90=EB=94=B0=EB=A5=B8=20?= =?UTF-8?q?=EC=84=9C=EB=B9=84=EC=8A=A4,=20=EC=BB=A8=ED=8A=B8=EB=A1=A4?= =?UTF-8?q?=EB=9F=AC=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../likelion12/controller/CrewController.java | 5 ++--- .../com/example/likelion12/dto/SearchRequest.java | 15 --------------- .../example/likelion12/service/CrewService.java | 5 ++--- 3 files changed, 4 insertions(+), 21 deletions(-) delete mode 100644 src/main/java/com/example/likelion12/dto/SearchRequest.java diff --git a/src/main/java/com/example/likelion12/controller/CrewController.java b/src/main/java/com/example/likelion12/controller/CrewController.java index dca7c7e..a892a48 100644 --- a/src/main/java/com/example/likelion12/controller/CrewController.java +++ b/src/main/java/com/example/likelion12/controller/CrewController.java @@ -1,7 +1,6 @@ package com.example.likelion12.controller; import com.example.likelion12.common.response.BaseResponse; -import com.example.likelion12.dto.SearchRequest; import com.example.likelion12.dto.crew.*; import com.example.likelion12.dto.crew.GetCrewDetailResponse; import com.example.likelion12.dto.crew.GetCrewInquiryResponse; @@ -39,10 +38,10 @@ public BaseResponse createCrew(@RequestHeader("Authorization") */ @GetMapping("/inquiry") public BaseResponse> getCrewInquiries(@RequestHeader("Authorization") String authorization, - @RequestBody SearchRequest searchRequest){ + @RequestParam int page){ log.info("[CrewController.getCrewInquiries]"); Long memberId = jwtProvider.extractIdFromHeader(authorization); - return new BaseResponse<>(crewService.getCrewInquiries(memberId,searchRequest)); + return new BaseResponse<>(crewService.getCrewInquiries(memberId,page)); } diff --git a/src/main/java/com/example/likelion12/dto/SearchRequest.java b/src/main/java/com/example/likelion12/dto/SearchRequest.java deleted file mode 100644 index ed43c36..0000000 --- a/src/main/java/com/example/likelion12/dto/SearchRequest.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.example.likelion12.dto; - -import lombok.AllArgsConstructor; -import lombok.Getter; - -@Getter -@AllArgsConstructor -public class SearchRequest { - - private int page; // 현재 페이지 번호 - - public int getOffset() { - return (page - 1) * 9; - } -} diff --git a/src/main/java/com/example/likelion12/service/CrewService.java b/src/main/java/com/example/likelion12/service/CrewService.java index 629ff4c..490ce7a 100644 --- a/src/main/java/com/example/likelion12/service/CrewService.java +++ b/src/main/java/com/example/likelion12/service/CrewService.java @@ -5,7 +5,6 @@ import com.example.likelion12.domain.base.BaseGender; import com.example.likelion12.domain.base.BaseLevel; import com.example.likelion12.domain.base.BaseStatus; -import com.example.likelion12.dto.SearchRequest; import com.example.likelion12.dto.crew.*; import com.example.likelion12.repository.*; import lombok.RequiredArgsConstructor; @@ -77,14 +76,14 @@ public PostCrewResponse createCrew(Long memberId, PostCrewRequest postCrewReques /** * 크루 조회 */ - public List getCrewInquiries(Long memberId, SearchRequest searchRequest) { + public List getCrewInquiries(Long memberId, int page) { log.info("[CrewService.getCrewInquiries]"); List allCrews = crewRepository.findAllByStatus(BaseStatus.ACTIVE); List getCrewInquiryResponses = new ArrayList<>(); // offset과 limit 계산 - int offset = searchRequest.getOffset(); + int offset = (page - 1) * 9; int recordSize = 9 ; // 페이징 처리된 크루 목록 생성