Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/add team api #389

Merged
merged 2 commits into from
Jan 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -16,6 +17,8 @@ public interface ApplicationFormRepository
boolean existsByNameLike(String name);

long countByNameLike(String name);

List<ApplicationForm> findByTeamIn(List<Team> teams);
}
/**
* applicationForm 연관관계
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,4 +141,8 @@ public List<ApplicationForm> getApplicationFormsByTeamId(Long teamId) {
public Page<ApplicationForm> getApplicationForms(Generation generation, ApplicationFormQueryVo applicationFormQueryVo) {
return applicationFormRepository.findByApplicationFormQueryVo(generation, applicationFormQueryVo);
}

public List<ApplicationForm> getApplicationFormsByTeam(List<Team> teams){
return applicationFormRepository.findByTeamIn(teams);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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<ApplicationFormResponse> getApplicationForms(final Integer generationNumber) {

final Generation generation =
generationService.getByNumberOrThrow(generationNumber);
final List<Team> teams = teamService.findAllTeamsByGeneration(generation);

return applicationFormService
.getApplicationFormsByTeam(teams)
.stream()
.map(ApplicationFormResponse::of)
.collect(Collectors.toList());


}
/**
* 각 팀의 지원서 상세페이지 접근시 빈 지원서 생성 또는 기존 지원서 조회
*/
Expand Down Expand Up @@ -166,4 +191,13 @@ public ApplicationResponse updateConfirmForTest(Long applicantId, Long applicati

return applicationAssembler.toApplicationResponse(application);
}

public List<RecruitScheduleResponse> getRecruitSchedule(Integer generationNumber) {
final Generation generation = generationService.getByNumberOrThrow(generationNumber);

return recruitmentScheduleService.getAll(generation)
.stream()
.map(RecruitScheduleResponse::of)
.collect(Collectors.toList());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -28,6 +25,18 @@ public class ApplicationController {

private final ApplicationFacadeService applicationFacadeService;

@ApiOperation("지원서 목록 조회")
@GetMapping("/generationNumber")
public ApiResponse<List<ApplicationFormResponse>> getApplications(
@PathVariable Integer generationNumber
){
final List<ApplicationFormResponse> response
= applicationFacadeService.getApplicationForms(generationNumber);

return ApiResponse.success(response);
}


/**
* 팀 id(or name) 받아서 만들기
*/
Expand Down Expand Up @@ -112,4 +121,14 @@ public ApiResponse<ApplicationResponse> updateConfirmation(

return ApiResponse.success(response);
}

@ApiOperation("기수 별 스케줄 조회")
@GetMapping("/schedule/{generationNumber")
public ApiResponse<List<RecruitScheduleResponse>> getRecruitSchedule(
@PathVariable Integer generationNumber
){
final List<RecruitScheduleResponse> response = applicationFacadeService.getRecruitSchedule(generationNumber);

return ApiResponse.success(response);
}
}
Original file line number Diff line number Diff line change
@@ -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());
}

}
Original file line number Diff line number Diff line change
@@ -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());
}
}
Loading