From f940f05cdf3a5320dfafe1c3b2bfa94c34eda9c8 Mon Sep 17 00:00:00 2001 From: dl-00-e8 Date: Mon, 20 May 2024 18:21:20 +0900 Subject: [PATCH 1/2] =?UTF-8?q?[#128]=20fix:=20=EB=82=B4=EA=B0=80=20?= =?UTF-8?q?=EC=A7=80=EC=9B=90=ED=95=9C=20=ED=8C=80=20=ED=8E=98=EC=9D=B4?= =?UTF-8?q?=EC=A7=80=EB=84=A4=EC=9D=B4=EC=85=98=EC=9C=BC=EB=A1=9C=20?= =?UTF-8?q?=EA=B5=AC=EC=A1=B0=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../apply/controller/ApplyController.java | 13 +++++++---- .../apply/repository/ApplyRepository.java | 2 +- .../domain/apply/service/ApplyService.java | 23 ++++++++----------- 3 files changed, 19 insertions(+), 19 deletions(-) diff --git a/src/main/java/com/gongjakso/server/domain/apply/controller/ApplyController.java b/src/main/java/com/gongjakso/server/domain/apply/controller/ApplyController.java index 9d5c43ba..08d120b9 100644 --- a/src/main/java/com/gongjakso/server/domain/apply/controller/ApplyController.java +++ b/src/main/java/com/gongjakso/server/domain/apply/controller/ApplyController.java @@ -9,6 +9,9 @@ import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; import lombok.RequiredArgsConstructor; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import org.springframework.data.web.PageableDefault; import org.springframework.security.core.annotation.AuthenticationPrincipal; import org.springframework.web.bind.annotation.*; @@ -30,19 +33,19 @@ public ApplicationResponse createApply(@AuthenticationPrincipal PrincipalD //팀 공고 요청 api @Operation(summary = "내가 모집 중인 팀 정보 API", description = "내가 모집 중인 팀 페이지에서 필요한 팀 정보 요청") @GetMapping("/{post_id}") - public ApplicationResponse getApply(@AuthenticationPrincipal PrincipalDetails principalDetails,@PathVariable("post_id") Long postId){ + public ApplicationResponse getApply(@AuthenticationPrincipal PrincipalDetails principalDetails, @PathVariable("post_id") Long postId){ return ApplicationResponse.ok(applyService.findApply(principalDetails.getMember(),postId)); } //내가 모집 중인 팀 지원자 정보 요청 api @Operation(summary = "내가 모집 중인 팀 지원자 정보 API", description = "내가 모집 중인 팀 페이지에서 필요한 지원자 정보 요청") @GetMapping("/{post_id}/applylist") - public ApplicationResponse getApplyList(@AuthenticationPrincipal PrincipalDetails principalDetails,@PathVariable("post_id") Long postId,@RequestParam(name = "page", defaultValue = "0") int page,@RequestParam(name = "size", defaultValue = "11") int size){ + public ApplicationResponse getApplyList(@AuthenticationPrincipal PrincipalDetails principalDetails, @PathVariable("post_id") Long postId, @RequestParam(name = "page", defaultValue = "0") int page, @RequestParam(name = "size", defaultValue = "11") int size){ return ApplicationResponse.ok(applyService.applyListPage(principalDetails.getMember(),postId,page,size)); } //내가 참여한 공고 정보 요청 api @Operation(summary = "내가 참여한 공고 정보 API", description = "내가 참여한 공고 정보") @GetMapping("/my-participation-post") - public ApplicationResponse getMyParticipationPostList(@AuthenticationPrincipal PrincipalDetails principalDetails,@RequestParam(name = "page", defaultValue = "0") int page,@RequestParam(name = "size", defaultValue = "6") int size){ + public ApplicationResponse getMyParticipationPostList(@AuthenticationPrincipal PrincipalDetails principalDetails, @RequestParam(name = "page", defaultValue = "0") int page, @RequestParam(name = "size", defaultValue = "6") int size){ return ApplicationResponse.ok(applyService.myParticipationPostListPage(principalDetails.getMember(),page,size)); } //지원서 열람 요청 api @@ -102,8 +105,8 @@ public ApplicationResponse updatePostPeriod(@AuthenticationPrincipal Princ @Operation(summary = "내가 지원한 팀 리스트 API", description = "현재 지원 중인 상태의 팀 정보 반환") @GetMapping("/my") - public ApplicationResponse> getMyApplyList(@AuthenticationPrincipal PrincipalDetails principalDetails) { - return ApplicationResponse.ok(applyService.getMyApplyList(principalDetails.getMember())); + public ApplicationResponse> getMyApplyList(@AuthenticationPrincipal PrincipalDetails principalDetails, @PageableDefault(size = 6) Pageable pageable) { + return ApplicationResponse.ok(applyService.getMyApplyList(principalDetails.getMember(), pageable)); } @Operation(summary = "지원서 열람 API", description = "해당 공고에 대한 사용자의 지원서 정보 반환") diff --git a/src/main/java/com/gongjakso/server/domain/apply/repository/ApplyRepository.java b/src/main/java/com/gongjakso/server/domain/apply/repository/ApplyRepository.java index 40bf1299..69d3158b 100644 --- a/src/main/java/com/gongjakso/server/domain/apply/repository/ApplyRepository.java +++ b/src/main/java/com/gongjakso/server/domain/apply/repository/ApplyRepository.java @@ -23,7 +23,7 @@ public interface ApplyRepository extends JpaRepository { List findApplyByApplyTypeAndMemberAndIsCanceledFalse(ApplyType applyType, Member member); - List findAllByMemberAndDeletedAtIsNullOrderByCreatedAtDesc(Member member); + Page findAllByMemberAndDeletedAtIsNullOrderByCreatedAtDesc(Member member, Pageable pageable); Apply findApplyByMemberAndPost(Member member,Post post); diff --git a/src/main/java/com/gongjakso/server/domain/apply/service/ApplyService.java b/src/main/java/com/gongjakso/server/domain/apply/service/ApplyService.java index 7b158016..2c2eee52 100644 --- a/src/main/java/com/gongjakso/server/domain/apply/service/ApplyService.java +++ b/src/main/java/com/gongjakso/server/domain/apply/service/ApplyService.java @@ -18,12 +18,9 @@ import com.gongjakso.server.domain.post.repository.StackNameRepository; import com.gongjakso.server.global.exception.ApplicationException; import com.gongjakso.server.global.exception.ErrorCode; -import com.gongjakso.server.global.util.email.EmailClient; +// import com.gongjakso.server.global.util.email.EmailClient; import lombok.RequiredArgsConstructor; -import org.springframework.data.domain.Page; -import org.springframework.data.domain.PageRequest; -import org.springframework.data.domain.Pageable; -import org.springframework.data.domain.Sort; +import org.springframework.data.domain.*; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -48,7 +45,7 @@ public class ApplyService { private final CategoryRepository categoryRepository; private final StackNameRepository stackNameRepository; private final ApplyStackRepository applyStackRepository; - private final EmailClient emailClient; +// private final EmailClient emailClient; @Transactional public void save(Member member, Long postId, ApplyReq req) { @@ -263,15 +260,12 @@ public void updatePostPeriod(Member member,Long postId, PeriodReq req) { } - public List getMyApplyList(Member member) { + public Page getMyApplyList(Member member, Pageable pageable) { // Validation // Business Logic - List applyList = applyRepository.findAllByMemberAndDeletedAtIsNullOrderByCreatedAtDesc(member); - - - // Response - return applyList.stream() + Page applyPage = applyRepository.findAllByMemberAndDeletedAtIsNullOrderByCreatedAtDesc(member, pageable); + List applyList = applyPage.stream() .filter(apply -> apply.getPost().getStatus() == PostStatus.RECRUITING || apply.getPost().getStatus() == PostStatus.EXTENSION || apply.getPost().getStatus() == PostStatus.CANCEL || @@ -284,7 +278,10 @@ public List getMyApplyList(Member member) { return MyPageRes.of(post, apply, categoryList); }) - .collect(Collectors.toList()); + .toList(); + + // Response + return new PageImpl<>(applyList, pageable, applyPage.getTotalElements()); } public ApplicationRes getMyApplication(Member member, Long postId){ From a6bd0077799ffdfc015686814336536f702d9717 Mon Sep 17 00:00:00 2001 From: dl-00-e8 Date: Mon, 20 May 2024 18:22:11 +0900 Subject: [PATCH 2/2] =?UTF-8?q?[#128]=20fix:=20=EB=82=B4=EA=B0=80=20?= =?UTF-8?q?=EC=B0=B8=EC=97=AC=ED=95=9C=20=ED=8C=80=20API=20=EB=B0=98?= =?UTF-8?q?=ED=99=98=EA=B0=92=EC=97=90=20postId=20=EC=A0=95=EB=B3=B4=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gongjakso/server/domain/apply/dto/ParticipationList.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/com/gongjakso/server/domain/apply/dto/ParticipationList.java b/src/main/java/com/gongjakso/server/domain/apply/dto/ParticipationList.java index edd215a9..634e48a4 100644 --- a/src/main/java/com/gongjakso/server/domain/apply/dto/ParticipationList.java +++ b/src/main/java/com/gongjakso/server/domain/apply/dto/ParticipationList.java @@ -8,6 +8,7 @@ @Builder public record ParticipationList( + Long postId, String title, String leaderName, LocalDateTime startDate, @@ -17,6 +18,7 @@ public record ParticipationList( ) { public static ParticipationList of(Post post) { return ParticipationList.builder() + .postId(post.getPostId()) .title(post.getTitle()) .leaderName(post.getMember().getName()) .startDate(post.getStartDate())