diff --git a/src/main/java/cotato/growingpain/log/controller/JobPostController.java b/src/main/java/cotato/growingpain/log/controller/JobPostController.java index 436061b..ba16c42 100644 --- a/src/main/java/cotato/growingpain/log/controller/JobPostController.java +++ b/src/main/java/cotato/growingpain/log/controller/JobPostController.java @@ -4,6 +4,7 @@ import cotato.growingpain.log.domain.entity.JobPost; import cotato.growingpain.log.dto.request.JobPostRequestDTO; import cotato.growingpain.log.dto.request.JobPostRetrieveDTO; +import cotato.growingpain.log.dto.response.JobApplicationListResponse; import cotato.growingpain.log.dto.retrieve.JobPostListRetrieveDTO; import cotato.growingpain.log.service.JobService; import io.swagger.v3.oas.annotations.Operation; @@ -89,4 +90,13 @@ public Response updateJobPost( return Response.createSuccess("지원 현황 삭제 완료", null); } + @Operation(summary = "일정 기간이 남은 지원 현황 조회", description = "일정 기간이 남은 지원 현황을 조회하여 반환하는 메소드") + @ApiResponse(content = @Content(schema = @Schema(implementation = JobApplicationListResponse.class))) + @GetMapping("/days-left/{days}") + @ResponseStatus(HttpStatus.OK) + public Response getJobApplicationsByDaysLeft( @AuthenticationPrincipal Long memberId, + @PathVariable int days) { + JobApplicationListResponse jobApplications = jobService.getJobApplicationsByDaysLeft(memberId, days); + return Response.createSuccess(days + "일 남은 지원 현황 조회 완료", jobApplications); + } } diff --git a/src/main/java/cotato/growingpain/log/dto/response/JobApplicationListResponse.java b/src/main/java/cotato/growingpain/log/dto/response/JobApplicationListResponse.java new file mode 100644 index 0000000..b764253 --- /dev/null +++ b/src/main/java/cotato/growingpain/log/dto/response/JobApplicationListResponse.java @@ -0,0 +1,8 @@ +package cotato.growingpain.log.dto.response; + +import java.util.List; + +public record JobApplicationListResponse( + List jobApplicaionList +) { +} diff --git a/src/main/java/cotato/growingpain/log/dto/response/JobApplicationResponse.java b/src/main/java/cotato/growingpain/log/dto/response/JobApplicationResponse.java new file mode 100644 index 0000000..0a0db00 --- /dev/null +++ b/src/main/java/cotato/growingpain/log/dto/response/JobApplicationResponse.java @@ -0,0 +1,22 @@ +package cotato.growingpain.log.dto.response; + +import cotato.growingpain.log.domain.entity.JobApplication; + +public record JobApplicationResponse( + + Long jobPostId, + Long jobApplicationId, + String companyName, + String applicationType, + String applicationCloseDate +) { + public JobApplicationResponse(JobApplication jobApplication) { + this( + jobApplication.getJobPost().getId(), + jobApplication.getId(), + jobApplication.getJobPost().getCompanyName(), + jobApplication.getApplicationType().name(), + jobApplication.getApplicationCloseDate() + ); + } +} diff --git a/src/main/java/cotato/growingpain/log/repository/JobApplicationRepository.java b/src/main/java/cotato/growingpain/log/repository/JobApplicationRepository.java index 26d4dfe..d8cd3f3 100644 --- a/src/main/java/cotato/growingpain/log/repository/JobApplicationRepository.java +++ b/src/main/java/cotato/growingpain/log/repository/JobApplicationRepository.java @@ -6,4 +6,5 @@ public interface JobApplicationRepository extends JpaRepository { List findByJobPostId(Long jobPostId); + List findByMemberIdAndApplicationCloseDate(Long memberId, String applicationCloseDate); } diff --git a/src/main/java/cotato/growingpain/log/service/JobService.java b/src/main/java/cotato/growingpain/log/service/JobService.java index 0c1e5b2..e7c52d1 100644 --- a/src/main/java/cotato/growingpain/log/service/JobService.java +++ b/src/main/java/cotato/growingpain/log/service/JobService.java @@ -4,12 +4,16 @@ import cotato.growingpain.log.domain.entity.JobPost; import cotato.growingpain.log.dto.request.JobPostRequestDTO; import cotato.growingpain.log.dto.request.JobPostRetrieveDTO; +import cotato.growingpain.log.dto.response.JobApplicationListResponse; +import cotato.growingpain.log.dto.response.JobApplicationResponse; import cotato.growingpain.log.dto.retrieve.JobPostListRetrieveDTO; import cotato.growingpain.log.repository.ApplicationDetailRepository; import cotato.growingpain.log.repository.JobApplicationRepository; import cotato.growingpain.log.repository.JobPostRepository; import cotato.growingpain.member.domain.entity.Member; import cotato.growingpain.member.repository.MemberRepository; +import java.time.LocalDate; +import java.time.format.DateTimeFormatter; import java.util.List; import java.util.stream.Collectors; import lombok.RequiredArgsConstructor; @@ -88,4 +92,18 @@ public void deleteJobPost(Long jobPostId, Long memberId) { jobPostRepository.delete(jobPost); } + public JobApplicationListResponse getJobApplicationsByDaysLeft(Long memberId, int daysLeft) { + // 현재 날짜에서 daysLeft를 더한 날짜 계산 + LocalDate targetDate = LocalDate.now().plusDays(daysLeft); + String formattedDate = targetDate.format(DateTimeFormatter.ISO_DATE); + + // 해당 날짜에 해당하는 JobApplication을 조회 + List applications = jobApplicationRepository.findByMemberIdAndApplicationCloseDate(memberId, formattedDate) + .stream() + .map(JobApplicationResponse::new) // 매핑 로직 간소화 + .collect(Collectors.toList()); + + // JobApplicationListResponse로 반환 + return new JobApplicationListResponse(applications); + } }