From 5cb1d6f5d684ff3fc58eb7a21f2f074fbaa3e9ba Mon Sep 17 00:00:00 2001 From: KyungHwanKim Date: Sun, 21 Jan 2024 12:05:25 +0900 Subject: [PATCH 1/2] add team and schedule api --- .../form/ApplicationFormRepository.java | 3 ++ .../application/ApplicationFormService.java | 4 +++ .../application/ApplicationFacadeService.java | 34 +++++++++++++++++++ .../ui/application/ApplicationController.java | 29 +++++++++++++--- .../vo/ApplicationFormResponse.java | 17 ++++++++++ .../vo/RecruitScheduleResponse.java | 23 +++++++++++++ 6 files changed, 105 insertions(+), 5 deletions(-) create mode 100644 mashup-recruit/src/main/java/kr/mashup/branding/ui/application/vo/ApplicationFormResponse.java create mode 100644 mashup-recruit/src/main/java/kr/mashup/branding/ui/application/vo/RecruitScheduleResponse.java diff --git a/mashup-domain/src/main/java/kr/mashup/branding/repository/application/form/ApplicationFormRepository.java b/mashup-domain/src/main/java/kr/mashup/branding/repository/application/form/ApplicationFormRepository.java index 477964aa..f0b25b8c 100644 --- a/mashup-domain/src/main/java/kr/mashup/branding/repository/application/form/ApplicationFormRepository.java +++ b/mashup-domain/src/main/java/kr/mashup/branding/repository/application/form/ApplicationFormRepository.java @@ -4,6 +4,7 @@ import java.util.Optional; import kr.mashup.branding.domain.application.form.ApplicationForm; +import kr.mashup.branding.domain.team.Team; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.data.jpa.repository.JpaRepository; @@ -16,6 +17,8 @@ public interface ApplicationFormRepository boolean existsByNameLike(String name); long countByNameLike(String name); + + List findByTeamIn(List teams); } /** * applicationForm 연관관계 diff --git a/mashup-domain/src/main/java/kr/mashup/branding/service/application/ApplicationFormService.java b/mashup-domain/src/main/java/kr/mashup/branding/service/application/ApplicationFormService.java index 7dcfbfe4..afc4470d 100644 --- a/mashup-domain/src/main/java/kr/mashup/branding/service/application/ApplicationFormService.java +++ b/mashup-domain/src/main/java/kr/mashup/branding/service/application/ApplicationFormService.java @@ -141,4 +141,8 @@ public List getApplicationFormsByTeamId(Long teamId) { public Page getApplicationForms(Generation generation, ApplicationFormQueryVo applicationFormQueryVo) { return applicationFormRepository.findByApplicationFormQueryVo(generation, applicationFormQueryVo); } + + public List getApplicationFormsByTeam(List teams){ + return applicationFormRepository.findByTeamIn(teams); + } } diff --git a/mashup-recruit/src/main/java/kr/mashup/branding/facade/application/ApplicationFacadeService.java b/mashup-recruit/src/main/java/kr/mashup/branding/facade/application/ApplicationFacadeService.java index a2a66a1e..4762f3bd 100644 --- a/mashup-recruit/src/main/java/kr/mashup/branding/facade/application/ApplicationFacadeService.java +++ b/mashup-recruit/src/main/java/kr/mashup/branding/facade/application/ApplicationFacadeService.java @@ -12,10 +12,17 @@ import kr.mashup.branding.domain.application.form.ApplicationForm; import kr.mashup.branding.domain.application.form.ApplicationFormNotFoundException; import kr.mashup.branding.domain.email.EmailTemplateName; +import kr.mashup.branding.domain.generation.Generation; +import kr.mashup.branding.domain.recruitmentschedule.RecruitmentSchedule; +import kr.mashup.branding.domain.team.Team; import kr.mashup.branding.service.applicant.ApplicantService; import kr.mashup.branding.service.application.ApplicationFormService; +import kr.mashup.branding.service.generation.GenerationService; +import kr.mashup.branding.service.recruitmentschedule.RecruitmentScheduleService; import kr.mashup.branding.service.team.TeamService; +import kr.mashup.branding.ui.application.vo.ApplicationFormResponse; import kr.mashup.branding.ui.application.vo.ApplicationResponse; +import kr.mashup.branding.ui.application.vo.RecruitScheduleResponse; import org.springframework.context.ApplicationEventPublisher; import org.springframework.stereotype.Service; @@ -38,8 +45,26 @@ public class ApplicationFacadeService { private final ApplicationFormService applicationFormService; private final ApplicationEventPublisher eventPublisher; private final ApplicationAssembler applicationAssembler; + private final GenerationService generationService; + private final RecruitmentScheduleService recruitmentScheduleService; + + /** + * 지원서 목록 조회 + */ + public List getApplicationForms(final Integer generationNumber) { + + final Generation generation = + generationService.getByNumberOrThrow(generationNumber); + final List teams = teamService.findAllTeamsByGeneration(generation); + + return applicationFormService + .getApplicationFormsByTeam(teams) + .stream() + .map(ApplicationFormResponse::of) + .collect(Collectors.toList()); + } /** * 각 팀의 지원서 상세페이지 접근시 빈 지원서 생성 또는 기존 지원서 조회 */ @@ -166,4 +191,13 @@ public ApplicationResponse updateConfirmForTest(Long applicantId, Long applicati return applicationAssembler.toApplicationResponse(application); } + + public List getRecruitSchedule(Long generationNumber) { + final Generation generation = generationService.getByNumberOrThrow(generationNumber); + + return recruitmentScheduleService.getAll(generation) + .stream() + .map(RecruitScheduleResponse::of) + .collect(Collectors.toList()); + } } diff --git a/mashup-recruit/src/main/java/kr/mashup/branding/ui/application/ApplicationController.java b/mashup-recruit/src/main/java/kr/mashup/branding/ui/application/ApplicationController.java index 0735ef7b..fdbb1300 100644 --- a/mashup-recruit/src/main/java/kr/mashup/branding/ui/application/ApplicationController.java +++ b/mashup-recruit/src/main/java/kr/mashup/branding/ui/application/ApplicationController.java @@ -3,11 +3,8 @@ import io.swagger.annotations.ApiOperation; import kr.mashup.branding.facade.application.ApplicationFacadeService; import kr.mashup.branding.ui.ApiResponse; -import kr.mashup.branding.ui.application.vo.ApplicationResponse; -import kr.mashup.branding.ui.application.vo.ApplicationSubmitRequest; -import kr.mashup.branding.ui.application.vo.CreateApplicationRequest; -import kr.mashup.branding.ui.application.vo.UpdateApplicationRequest; -import kr.mashup.branding.ui.application.vo.UpdateConfirmationRequest; +import kr.mashup.branding.ui.application.vo.*; +import lombok.Getter; import lombok.RequiredArgsConstructor; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.ModelAttribute; @@ -28,6 +25,18 @@ public class ApplicationController { private final ApplicationFacadeService applicationFacadeService; + @ApiOperation("지원서 목록 조회") + @GetMapping("/generationNumber") + public ApiResponse> getApplications( + @PathVariable Integer generationNumber + ){ + final List response + = applicationFacadeService.getApplicationForms(generationNumber); + + return ApiResponse.success(response); + } + + /** * 팀 id(or name) 받아서 만들기 */ @@ -112,4 +121,14 @@ public ApiResponse updateConfirmation( return ApiResponse.success(response); } + + @ApiOperation("기수 별 스케줄 조회") + @GetMapping("/schedule/{generationNumber") + public ApiResponse> getRecruitSchedule( + @PathVariable Long generationNumber + ){ + final List response = applicationFacadeService.getRecruitSchedule(generationNumber); + + return ApiResponse.success(response); + } } diff --git a/mashup-recruit/src/main/java/kr/mashup/branding/ui/application/vo/ApplicationFormResponse.java b/mashup-recruit/src/main/java/kr/mashup/branding/ui/application/vo/ApplicationFormResponse.java new file mode 100644 index 00000000..19af3cf5 --- /dev/null +++ b/mashup-recruit/src/main/java/kr/mashup/branding/ui/application/vo/ApplicationFormResponse.java @@ -0,0 +1,17 @@ +package kr.mashup.branding.ui.application.vo; + +import kr.mashup.branding.domain.application.form.ApplicationForm; +import lombok.*; + +@Getter +@AllArgsConstructor(access = AccessLevel.PRIVATE) +public class ApplicationFormResponse { + + private Long teamId; + private Long applicationFormId; + + public static ApplicationFormResponse of(final ApplicationForm applicationForm){ + return new ApplicationFormResponse(applicationForm.getTeam().getTeamId(), applicationForm.getApplicationFormId()); + } + +} diff --git a/mashup-recruit/src/main/java/kr/mashup/branding/ui/application/vo/RecruitScheduleResponse.java b/mashup-recruit/src/main/java/kr/mashup/branding/ui/application/vo/RecruitScheduleResponse.java new file mode 100644 index 00000000..a7f56374 --- /dev/null +++ b/mashup-recruit/src/main/java/kr/mashup/branding/ui/application/vo/RecruitScheduleResponse.java @@ -0,0 +1,23 @@ +package kr.mashup.branding.ui.application.vo; + +import kr.mashup.branding.domain.recruitmentschedule.RecruitmentSchedule; +import kr.mashup.branding.domain.recruitmentschedule.RecruitmentScheduleEventName; +import lombok.AccessLevel; +import lombok.AllArgsConstructor; +import lombok.Getter; + +import java.time.LocalDateTime; + +@Getter +@AllArgsConstructor(access = AccessLevel.PRIVATE) +public class RecruitScheduleResponse { + + private Long recruitScheduleId; + private RecruitmentScheduleEventName eventName; + + private LocalDateTime eventOccurredAt; + + public static RecruitScheduleResponse of(final RecruitmentSchedule schedule){ + return new RecruitScheduleResponse(schedule.getRecruitmentScheduleId(), schedule.getEventName(), schedule.getEventOccurredAt()); + } +} From 8ce9952201f33542cbd685050d75821fc597de2f Mon Sep 17 00:00:00 2001 From: KyungHwanKim Date: Sun, 21 Jan 2024 12:28:35 +0900 Subject: [PATCH 2/2] add team api --- .../branding/facade/application/ApplicationFacadeService.java | 2 +- .../mashup/branding/ui/application/ApplicationController.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/mashup-recruit/src/main/java/kr/mashup/branding/facade/application/ApplicationFacadeService.java b/mashup-recruit/src/main/java/kr/mashup/branding/facade/application/ApplicationFacadeService.java index 4762f3bd..88814a22 100644 --- a/mashup-recruit/src/main/java/kr/mashup/branding/facade/application/ApplicationFacadeService.java +++ b/mashup-recruit/src/main/java/kr/mashup/branding/facade/application/ApplicationFacadeService.java @@ -192,7 +192,7 @@ public ApplicationResponse updateConfirmForTest(Long applicantId, Long applicati return applicationAssembler.toApplicationResponse(application); } - public List getRecruitSchedule(Long generationNumber) { + public List getRecruitSchedule(Integer generationNumber) { final Generation generation = generationService.getByNumberOrThrow(generationNumber); return recruitmentScheduleService.getAll(generation) diff --git a/mashup-recruit/src/main/java/kr/mashup/branding/ui/application/ApplicationController.java b/mashup-recruit/src/main/java/kr/mashup/branding/ui/application/ApplicationController.java index fdbb1300..17a32dc7 100644 --- a/mashup-recruit/src/main/java/kr/mashup/branding/ui/application/ApplicationController.java +++ b/mashup-recruit/src/main/java/kr/mashup/branding/ui/application/ApplicationController.java @@ -125,7 +125,7 @@ public ApiResponse updateConfirmation( @ApiOperation("기수 별 스케줄 조회") @GetMapping("/schedule/{generationNumber") public ApiResponse> getRecruitSchedule( - @PathVariable Long generationNumber + @PathVariable Integer generationNumber ){ final List response = applicationFacadeService.getRecruitSchedule(generationNumber);