Skip to content

Commit

Permalink
Merge branch 'develop' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
tedsoftj1123 committed Oct 4, 2023
2 parents 51c0461 + c996a4c commit 9b246d1
Show file tree
Hide file tree
Showing 13 changed files with 62 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
public class TeacherQueryApplicationsResponse {

private final List<TeacherQueryApplicationResponse> applications;
private final int totalPageCount;

@Getter
@Builder
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

public interface QueryApplicationPort {


List<ApplicationVO> queryApplicationByConditions(Long recruitmentId, Long studentId, ApplicationStatus applicationStatus, String studentName);

Long queryApplicationCountByCondition(ApplicationStatus applicationStatus, String studentName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import lombok.RequiredArgsConstructor;
import team.retum.jobis.common.annotation.ReadOnlyUseCase;
import team.retum.jobis.common.dto.response.TotalPageCountResponse;
import team.retum.jobis.common.util.NumberUtil;
import team.retum.jobis.domain.application.dto.response.AttachmentResponse;
import team.retum.jobis.domain.application.dto.response.TeacherQueryApplicationsResponse;
Expand All @@ -17,10 +18,6 @@ public class TeacherQueryApplicationsUseCase {
private final QueryApplicationPort applicationPersistenceAdapter;

public TeacherQueryApplicationsResponse execute(ApplicationStatus applicationStatus, String studentName, Long recruitmentId) {
int totalPageCount = NumberUtil.getTotalPageCount(
applicationPersistenceAdapter.queryApplicationCountByCondition(applicationStatus, studentName), 11
);

return new TeacherQueryApplicationsResponse(
applicationPersistenceAdapter.queryApplicationByConditions(
recruitmentId, null, applicationStatus, studentName).stream()
Expand All @@ -40,8 +37,15 @@ public TeacherQueryApplicationsResponse execute(ApplicationStatus applicationSta
.createdAt(application.getCreatedAt().toLocalDate())
.applicationStatus(application.getApplicationStatus())
.build()
).toList(),
totalPageCount
).toList()
);
}

public TotalPageCountResponse getTotalPageCount(ApplicationStatus applicationStatus, String studentName) {
return new TotalPageCountResponse(
NumberUtil.getTotalPageCount(
applicationPersistenceAdapter.queryApplicationCountByCondition(applicationStatus, studentName), 11
)
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,4 @@
public class TeacherQueryEmployCompaniesResponse {

private final List<TeacherEmployCompaniesVO> companies;
private final int totalPageCount;
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,9 @@ public StudentQueryCompaniesResponse execute(Long page, String name) {
);
}

public TotalPageCountResponse getTotalPageCount(Long page, String name) {
public TotalPageCountResponse getTotalPageCount(String name) {
CompanyFilter filter = CompanyFilter.builder()
.name(name)
.page(page)
.limit(12)
.build();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public TeacherQueryCompaniesResponse execute(
);
}

public TotalPageCountResponse getTotalPageCount(CompanyType type, String companyName, String region, Long businessArea, Long page) {
public TotalPageCountResponse getTotalPageCount(CompanyType type, String companyName, String region, Long businessArea) {
CompanyFilter filter = CompanyFilter.builder()
.type(type)
.name(companyName)
Expand All @@ -70,7 +70,6 @@ public TotalPageCountResponse getTotalPageCount(CompanyType type, String company
.orElseThrow(() -> CodeNotFoundException.EXCEPTION)
.getKeyword()
)
.page(page)
.build();

int totalPageCount = NumberUtil.getTotalPageCount(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import lombok.RequiredArgsConstructor;
import team.retum.jobis.common.annotation.ReadOnlyUseCase;
import team.retum.jobis.common.dto.response.TotalPageCountResponse;
import team.retum.jobis.common.util.NumberUtil;
import team.retum.jobis.domain.company.dto.CompanyFilter;
import team.retum.jobis.domain.company.dto.response.TeacherQueryEmployCompaniesResponse;
Expand Down Expand Up @@ -31,12 +32,27 @@ public TeacherQueryEmployCompaniesResponse execute(
.limit(13)
.build();

int totalPageCount = NumberUtil.getTotalPageCount(
queryCompanyPort.getTotalCompanyCount(filter), filter.getLimit()
);

List<TeacherEmployCompaniesVO> companies = queryCompanyPort.queryEmployCompanies(filter);

return new TeacherQueryEmployCompaniesResponse(companies, totalPageCount);
return new TeacherQueryEmployCompaniesResponse(companies);
}

public TotalPageCountResponse getTotalPageCount(
String companyName,
CompanyType type,
Integer year
) {
CompanyFilter filter = CompanyFilter.builder()
.name(companyName)
.type(type)
.year(year)
.limit(13)
.build();

return new TotalPageCountResponse(
NumberUtil.getTotalPageCount(
queryCompanyPort.getTotalCompanyCount(filter), filter.getLimit()
)
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,14 @@ public StudentQueryRecruitmentsResponse execute(
return new StudentQueryRecruitmentsResponse(recruitments);
}

public TotalPageCountResponse getTotalPageCount(String name, Long page, Long jobCode, List<Long> codeIds) {
public TotalPageCountResponse getTotalPageCount(String name, Long jobCode, List<Long> codeIds) {
Long currentStudentId = securityPort.getCurrentUserId();
String jobKeyword = validJobCode(jobCode);

RecruitmentFilter filter = RecruitmentFilter.builder()
.year(Year.now().getValue())
.status(RecruitStatus.RECRUITING)
.companyName(name)
.page(page)
.limit(12)
.codes(codeIds)
.studentId(currentStudentId)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,14 @@ public TeacherQueryRecruitmentsResponse execute(String companyName, LocalDate st
}

public TotalPageCountResponse getTotalPageCount(String companyName, LocalDate start, LocalDate end,
Integer year, RecruitStatus status, Long page) {
Integer year, RecruitStatus status) {
RecruitmentFilter filter = RecruitmentFilter.builder()
.companyName(companyName)
.status(status)
.startDate(start)
.endDate(end)
.codes(List.of())
.year(year)
.page(page)
.build();

int totalPageCount = NumberUtil.getTotalPageCount(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestController;
import team.retum.jobis.common.dto.response.TotalPageCountResponse;
import team.retum.jobis.domain.application.dto.response.CompanyQueryApplicationsResponse;
import team.retum.jobis.domain.application.dto.response.QueryEmploymentCountResponse;
import team.retum.jobis.domain.application.dto.response.QueryPassedApplicationStudentsResponse;
Expand Down Expand Up @@ -75,6 +76,14 @@ public TeacherQueryApplicationsResponse queryTeacherApplicationList(
return queryApplicationListService.execute(applicationStatus, studentName, recruitmentId);
}

@GetMapping("/count")
public TotalPageCountResponse queryApplicationCount(
@RequestParam(value = "application_status", required = false) ApplicationStatus applicationStatus,
@RequestParam(value = "student_name", required = false) String studentName
) {
return queryApplicationListService.getTotalPageCount(applicationStatus, studentName);
}

@GetMapping("/company")
public CompanyQueryApplicationsResponse queryCompanyApplicationList() {
return queryCompanyApplicationsUseCase.execute();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,9 @@ public StudentQueryCompaniesResponse studentQueryCompanies(

@GetMapping("/student/count")
public TotalPageCountResponse studentQueryCompanyCount(
@RequestParam(value = "page", required = false, defaultValue = "1") Long page,
@RequestParam(value = "name", required = false) String name
) {
return studentQueryCompaniesUseCase.getTotalPageCount(page - 1, name);
return studentQueryCompaniesUseCase.getTotalPageCount(name);
}

@GetMapping("/{company-id}")
Expand Down Expand Up @@ -118,6 +117,15 @@ public TeacherQueryEmployCompaniesResponse queryEmployCompanies(
return teacherQueryEmployCompaniesUseCase.execute(companyName, type, year, page - 1);
}

@GetMapping("/employment/count")
public TotalPageCountResponse queryEmployCompaniesCount(
@RequestParam(value = "company_name", required = false) String companyName,
@RequestParam(value = "company_type", required = false) CompanyType type,
@RequestParam(value = "year", required = false) Integer year
) {
return teacherQueryEmployCompaniesUseCase.getTotalPageCount(companyName, type, year);
}

@GetMapping("/teacher")
public TeacherQueryCompaniesResponse queryCompanies(
@RequestParam(value = "type", required = false) CompanyType type,
Expand All @@ -134,10 +142,9 @@ public TotalPageCountResponse queryCompanyCount(
@RequestParam(value = "type", required = false) CompanyType type,
@RequestParam(value = "name", required = false) String companyName,
@RequestParam(value = "region", required = false) String region,
@RequestParam(value = "business_area", required = false) Long businessArea,
@RequestParam(value = "page", defaultValue = "1") Long page
@RequestParam(value = "business_area", required = false) Long businessArea
) {
return teacherQueryCompaniesUseCase.getTotalPageCount(type, companyName, region, businessArea, page - 1);
return teacherQueryCompaniesUseCase.getTotalPageCount(type, companyName, region, businessArea);
}

@ResponseStatus(HttpStatus.NO_CONTENT)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,12 +103,11 @@ public StudentQueryRecruitmentsResponse studentQueryRecruitments(
@GetMapping("/student/count")
public TotalPageCountResponse studentQueryRecruitmentCount(
@RequestParam(value = "name", required = false) String companyName,
@RequestParam(value = "page", required = false, defaultValue = "1") Long page,
@RequestParam(value = "job_code", required = false) Long jobCode,
@RequestParam(value = "tech_code", required = false) String techCode
) {
List<Long> techCodes = StringUtil.divideString(techCode).stream().map(Long::parseLong).toList();
return studentQueryRecruitmentsUseCase.getTotalPageCount(companyName, page, jobCode, techCodes);
return studentQueryRecruitmentsUseCase.getTotalPageCount(companyName, jobCode, techCodes);
}

@GetMapping("/teacher")
Expand All @@ -129,10 +128,9 @@ public TotalPageCountResponse queryRecruitmentCount(
@RequestParam(value = "start", required = false) @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) LocalDate start,
@RequestParam(value = "end", required = false) @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) LocalDate end,
@RequestParam(value = "status", required = false) RecruitStatus status,
@RequestParam(value = "year", required = false) Integer year,
@RequestParam(value = "page", defaultValue = "1") Long page
@RequestParam(value = "year", required = false) Integer year
) {
return teacherQueryRecruitmentsUseCase.getTotalPageCount(companyName, start, end, year, status, page);
return teacherQueryRecruitmentsUseCase.getTotalPageCount(companyName, start, end, year, status);
}

@ResponseStatus(HttpStatus.NO_CONTENT)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,14 @@ protected SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
.antMatchers(HttpMethod.PATCH, "/students/password").hasAuthority(STUDENT.name())

//applications
.antMatchers(HttpMethod.GET, "/applications").hasAuthority(TEACHER.name())
.antMatchers(HttpMethod.GET, "/applications/count").hasAuthority(TEACHER.name())
.antMatchers(HttpMethod.GET, "/applications/employment/count").permitAll()
.antMatchers(HttpMethod.GET, "/applications/pass/{company-id}").hasAuthority(TEACHER.name())
.antMatchers(HttpMethod.GET, "/applications/company").hasAuthority(COMPANY.name())
.antMatchers(HttpMethod.GET, "/applications/students").hasAnyAuthority(STUDENT.name())
.antMatchers(HttpMethod.POST, "/applications/{company-id}").hasAuthority(STUDENT.name())
.antMatchers(HttpMethod.DELETE, "/applications/{application-id}").hasAuthority(STUDENT.name())
.antMatchers(HttpMethod.GET, "/applications/{company-id}").hasAuthority(TEACHER.name())
.antMatchers(HttpMethod.GET, "/applications/{recruitment-id}").hasAuthority(TEACHER.name())
.antMatchers(HttpMethod.PATCH, "/applications/status").hasAnyAuthority(TEACHER.name())
.antMatchers(HttpMethod.PATCH, "/applications/train-date").hasAuthority(TEACHER.name())
.antMatchers(HttpMethod.PATCH, "/applications/reject/{application-id}").hasAuthority(TEACHER.name())
Expand Down Expand Up @@ -109,6 +109,7 @@ protected SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
.antMatchers(HttpMethod.GET, "/companies/student").hasAnyAuthority(STUDENT.name(), DEVELOPER.name())
.antMatchers(HttpMethod.GET, "/companies/student/count").hasAnyAuthority(STUDENT.name(), DEVELOPER.name())
.antMatchers(HttpMethod.GET, "/companies/employment").hasAuthority(TEACHER.name())
.antMatchers(HttpMethod.GET, "/companies/employment/count").hasAuthority(TEACHER.name())
.antMatchers(HttpMethod.GET, "/companies/review").hasAnyAuthority(STUDENT.name(), DEVELOPER.name())

//users
Expand Down

0 comments on commit 9b246d1

Please sign in to comment.