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;