From 405cd68aa63f4d229a74128c26e4de0c67b79139 Mon Sep 17 00:00:00 2001 From: JeonghoPark Date: Sun, 2 Jul 2023 15:36:53 +0900 Subject: [PATCH 1/4] =?UTF-8?q?[LAS-67]=20feat:=20=EB=AA=A8=EC=A7=91?= =?UTF-8?q?=EA=B8=80=20=EC=83=81=EC=84=B8=EC=97=90=EC=84=9C=20=ED=9A=8C?= =?UTF-8?q?=EC=9B=90=EC=9D=98=20=EC=8B=A0=EC=B2=AD=20=EC=83=81=ED=83=9C=20?= =?UTF-8?q?=EC=97=AC=EB=B6=80=20=EC=B2=B4=ED=81=AC=EB=A5=BC=20=EC=9C=84?= =?UTF-8?q?=ED=95=9C=20api=20=EC=BB=A8=ED=8A=B8=EB=A1=A4=EB=9F=AC=20?= =?UTF-8?q?=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../apiserver/controller/RecruitmentController.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/api-server/src/main/java/com/lastone/apiserver/controller/RecruitmentController.java b/api-server/src/main/java/com/lastone/apiserver/controller/RecruitmentController.java index 35db72a4..8e6673af 100644 --- a/api-server/src/main/java/com/lastone/apiserver/controller/RecruitmentController.java +++ b/api-server/src/main/java/com/lastone/apiserver/controller/RecruitmentController.java @@ -47,6 +47,14 @@ public ResponseEntity getRecruitmentListInMain() { return ResponseEntity.ok().body(CommonResponse.success(SuccessCode.RECRUITMENT_LIST_FOR_MAIN, recruitmentList)); } + @PreAuthorize("isAuthenticated()") + @GetMapping("/{recruitmentId}/application") + public ResponseEntity checkApplyStatusForMember(@PathVariable Long recruitmentId, + @AuthenticationPrincipal UserDetailsImpl userDetails) { + RecruitmentApplyStatusForMember applyStatus = recruitmentService.isAlreadyApplyRecruitment(recruitmentId, userDetails.getId()); + return ResponseEntity.ok().body(CommonResponse.success(SuccessCode.RECRUITMENT_APPLY_STATUS_FOR_MEMBER, applyStatus)); + } + @PreAuthorize("isAuthenticated()") @PostMapping public ResponseEntity createRecruitment(@AuthenticationPrincipal UserDetailsImpl userDetails, From 45d096f7a471ac92655457e66165d7ae49cff505 Mon Sep 17 00:00:00 2001 From: JeonghoPark Date: Sun, 2 Jul 2023 15:37:26 +0900 Subject: [PATCH 2/4] =?UTF-8?q?[LAS-67]=20feat:=20=EB=AA=A8=EC=A7=91?= =?UTF-8?q?=EA=B8=80=20=EC=83=81=EC=84=B8=EC=97=90=EC=84=9C=20=ED=9A=8C?= =?UTF-8?q?=EC=9B=90=EC=9D=98=20=EC=8B=A0=EC=B2=AD=20=EC=83=81=ED=83=9C=20?= =?UTF-8?q?=EC=97=AC=EB=B6=80=20=EC=B2=B4=ED=81=AC=EB=A5=BC=20=EC=9C=84?= =?UTF-8?q?=ED=95=9C=20=EC=9D=91=EB=8B=B5=20dto=20=EC=83=9D=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../RecruitmentApplyStatusForMember.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 core/src/main/java/com/lastone/core/dto/recruitment/RecruitmentApplyStatusForMember.java diff --git a/core/src/main/java/com/lastone/core/dto/recruitment/RecruitmentApplyStatusForMember.java b/core/src/main/java/com/lastone/core/dto/recruitment/RecruitmentApplyStatusForMember.java new file mode 100644 index 00000000..b51b16c5 --- /dev/null +++ b/core/src/main/java/com/lastone/core/dto/recruitment/RecruitmentApplyStatusForMember.java @@ -0,0 +1,13 @@ +package com.lastone.core.dto.recruitment; + +import lombok.Getter; + +@Getter +public class RecruitmentApplyStatusForMember { + + Boolean isApply; + + public RecruitmentApplyStatusForMember(boolean isApply) { + this.isApply = isApply; + } +} From e7a6a3098a636f6b77fd5e90f4ddec0327bd6e62 Mon Sep 17 00:00:00 2001 From: JeonghoPark Date: Sun, 2 Jul 2023 15:37:51 +0900 Subject: [PATCH 3/4] =?UTF-8?q?[LAS-67]=20feat:=20=EB=AA=A8=EC=A7=91?= =?UTF-8?q?=EA=B8=80=20=EC=83=81=EC=84=B8=EC=97=90=EC=84=9C=20=ED=9A=8C?= =?UTF-8?q?=EC=9B=90=EC=9D=98=20=EC=8B=A0=EC=B2=AD=20=EC=83=81=ED=83=9C=20?= =?UTF-8?q?=EC=97=AC=EB=B6=80=20=EC=B2=B4=ED=81=AC=20=EC=9D=91=EB=8B=B5=20?= =?UTF-8?q?=EA=B4=80=EB=A0=A8=20SuccessCode=20=EC=83=9D=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/lastone/core/common/response/SuccessCode.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/core/src/main/java/com/lastone/core/common/response/SuccessCode.java b/core/src/main/java/com/lastone/core/common/response/SuccessCode.java index f3f76507..f6e63d89 100644 --- a/core/src/main/java/com/lastone/core/common/response/SuccessCode.java +++ b/core/src/main/java/com/lastone/core/common/response/SuccessCode.java @@ -25,6 +25,7 @@ public enum SuccessCode { RECRUITMENT_CREATE("모집글 작성이 완료되었습니다."), RECRUITMENT_UPDATE("모집글 수정이 완료되었습니다."), RECRUITMENT_DELETE("모집글 삭제가 완료되었습니다."), + RECRUITMENT_APPLY_STATUS_FOR_MEMBER("모집글 신청 여부 조회가 완료되었습니다."), /* 신청 */ APPLICATION_CREATE("신청 처리가 완료되었습니다."), @@ -42,7 +43,7 @@ public enum SuccessCode { NOTIFICATION_LIST("알림 목록 조회가 완료되었습니다."), NOTIFICATION_READ("알림 읽기 처리가 완료되었습니다."), NOTIFICATION_DELETE("알림 삭제 처리가 완료되었습니다."), - ; + ; private String message; From 7f0f87367a8e2d7ec48250d8dff75c30a56cd8d8 Mon Sep 17 00:00:00 2001 From: JeonghoPark Date: Sun, 2 Jul 2023 15:38:17 +0900 Subject: [PATCH 4/4] =?UTF-8?q?[LAS-67]=20feat:=20=EB=AA=A8=EC=A7=91?= =?UTF-8?q?=EA=B8=80=20=EC=83=81=EC=84=B8=EC=97=90=EC=84=9C=20=ED=9A=8C?= =?UTF-8?q?=EC=9B=90=EC=9D=98=20=EC=8B=A0=EC=B2=AD=20=EC=83=81=ED=83=9C=20?= =?UTF-8?q?=EC=97=AC=EB=B6=80=20=EC=B2=B4=ED=81=AC=EB=A5=BC=20=EC=9C=84?= =?UTF-8?q?=ED=95=9C=20=EC=84=9C=EB=B9=84=EC=8A=A4=20=EB=A0=88=EC=9D=B4?= =?UTF-8?q?=EC=96=B4=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/recruitment/RecruitmentService.java | 7 +++---- .../service/recruitment/RecruitmentServiceImpl.java | 13 +++++++++---- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/api-server/src/main/java/com/lastone/apiserver/service/recruitment/RecruitmentService.java b/api-server/src/main/java/com/lastone/apiserver/service/recruitment/RecruitmentService.java index 4bf666e8..b367b571 100644 --- a/api-server/src/main/java/com/lastone/apiserver/service/recruitment/RecruitmentService.java +++ b/api-server/src/main/java/com/lastone/apiserver/service/recruitment/RecruitmentService.java @@ -1,9 +1,6 @@ package com.lastone.apiserver.service.recruitment; -import com.lastone.core.dto.recruitment.RecruitmentRequestDto; -import com.lastone.core.dto.recruitment.RecruitmentDetailDto; -import com.lastone.core.dto.recruitment.RecruitmentListDto; -import com.lastone.core.dto.recruitment.RecruitmentSearchCondition; +import com.lastone.core.dto.recruitment.*; import org.springframework.data.domain.Slice; import org.springframework.web.multipart.MultipartFile; import java.io.IOException; @@ -22,4 +19,6 @@ public interface RecruitmentService { void updateRecruitment(Long recruitmentId, Long memberId, RecruitmentRequestDto recruitment, List imgFiles) throws IOException; void deleteRecruitment(Long recruitmentId, Long id); + + RecruitmentApplyStatusForMember isAlreadyApplyRecruitment(Long recruitmentId, Long memberId); } diff --git a/api-server/src/main/java/com/lastone/apiserver/service/recruitment/RecruitmentServiceImpl.java b/api-server/src/main/java/com/lastone/apiserver/service/recruitment/RecruitmentServiceImpl.java index 2de9e531..c1ab373f 100644 --- a/api-server/src/main/java/com/lastone/apiserver/service/recruitment/RecruitmentServiceImpl.java +++ b/api-server/src/main/java/com/lastone/apiserver/service/recruitment/RecruitmentServiceImpl.java @@ -13,10 +13,7 @@ import com.lastone.core.domain.recruitment.Recruitment; import com.lastone.core.domain.recruitment_img.RecruitmentImg; import com.lastone.core.dto.gym.GymDto; -import com.lastone.core.dto.recruitment.RecruitmentDetailDto; -import com.lastone.core.dto.recruitment.RecruitmentListDto; -import com.lastone.core.dto.recruitment.RecruitmentRequestDto; -import com.lastone.core.dto.recruitment.RecruitmentSearchCondition; +import com.lastone.core.dto.recruitment.*; import com.lastone.core.util.mapper.GymMapper; import com.lastone.core.repository.gym.GymRepository; import com.lastone.core.repository.member.MemberRepository; @@ -113,6 +110,14 @@ public void deleteRecruitment(Long recruitmentId, Long memberId) { recruitment.delete(); } + @Override + public RecruitmentApplyStatusForMember isAlreadyApplyRecruitment(Long recruitmentId, Long memberId) { + Recruitment recruitment = recruitmentRepository.findById(recruitmentId).orElseThrow(RecruitmentNotFoundException::new); + boolean result = recruitment.getApplications().stream() + .anyMatch(application -> application.getApplicant().getId().equals(memberId)); + return new RecruitmentApplyStatusForMember(result); + } + private void updateImgFiles(Recruitment recruitment, List imgFiles) throws IOException { if (imgFileIsExist(imgFiles)) { return;