Skip to content

Commit

Permalink
🔗 :: (#448) 모집의뢰 모집인원 문제
Browse files Browse the repository at this point in the history
  • Loading branch information
tedsoftj1123 authored Dec 1, 2023
2 parents d59e2b9 + 2879b97 commit 86c90d7
Show file tree
Hide file tree
Showing 13 changed files with 131 additions and 101 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public class CreateApplicationUseCase {

public void execute(CreateApplicationRequest request, Long recruitmentId) {
Student student = securityPort.getCurrentStudent();

Recruitment recruitment = queryRecruitmentPort.queryRecruitmentById(recruitmentId)
.orElseThrow(() -> RecruitmentNotFoundException.EXCEPTION);
recruitment.checkIsApplicable(student.getGrade());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,18 @@ public class StudentQueryRecruitmentsResponse {
@Getter
@Builder
public static class StudentRecruitmentResponse {
private Long recruitId;
private long id;

private String companyName;

private String companyProfileUrl;
private Integer trainPay;
private boolean military;
private Integer totalHiring;
private String jobCodeList;
private boolean isBookmarked;

private int trainPay;

private boolean militarySupport;

private String hiringJobs;

private boolean bookmarked;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,26 @@ public class TeacherQueryRecruitmentsResponse {
@Getter
@Builder
public static class TeacherRecruitmentResponse {
private Long id;
private RecruitStatus recruitmentStatus;
private long id;

private RecruitStatus status;

private String companyName;

private CompanyType companyType;
private String recruitmentJob;
private Integer recruitmentCount;
private Long applicationRequestedCount;
private Long applicationApprovedCount;
private LocalDate start;
private LocalDate end;
private Boolean militarySupport;
private Long companyId;

private String hiringJobs;

private long totalHiringCount;

private long applicationRequestedCount;

private long applicationApprovedCount;

private LocalDate startDate;

private LocalDate endDate;

private long companyId;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
import team.retum.jobis.domain.recruitment.model.RecruitArea;
import team.retum.jobis.domain.recruitment.model.Recruitment;
import team.retum.jobis.domain.recruitment.spi.vo.RecruitmentDetailVO;
import team.retum.jobis.domain.recruitment.spi.vo.RecruitmentVO;
import team.retum.jobis.domain.recruitment.spi.vo.StudentRecruitmentVO;
import team.retum.jobis.domain.recruitment.spi.vo.TeacherRecruitmentVO;

import java.util.List;
import java.util.Optional;
Expand All @@ -25,9 +26,9 @@ public interface QueryRecruitmentPort {

RecruitmentDetailVO queryRecruitmentDetailById(Long recruitmentId);

List<RecruitmentVO> queryStudentRecruitmentsByFilter(RecruitmentFilter filter);
List<StudentRecruitmentVO> queryStudentRecruitmentsByFilter(RecruitmentFilter filter);

List<RecruitmentVO> queryTeacherRecruitmentsByFilter(RecruitmentFilter filter);
List<TeacherRecruitmentVO> queryTeacherRecruitmentsByFilter(RecruitmentFilter filter);

List<Recruitment> queryRecruitmentsByIdIn(List<Long> recruitmentIds);

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package team.retum.jobis.domain.recruitment.spi.vo;

import lombok.AllArgsConstructor;
import lombok.Getter;

@Getter
@AllArgsConstructor
public class StudentRecruitmentVO {

private final long recruitmentId;
private final String companyName;
private final int trainPay;
private final boolean militarySupport;
private final String companyLogoUrl;
private final String jobCodes;
private final boolean isBookmarked;

}
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,18 @@

@Getter
@AllArgsConstructor
public class RecruitmentVO {
public class TeacherRecruitmentVO {

private final Long recruitmentId;
private final long recruitmentId;
private final RecruitStatus recruitStatus;
private final LocalDate startDate;
private final LocalDate endDate;
private final String companyName;
private final CompanyType companyType;
private final Integer trainPay;
private final boolean militarySupport;
private final String companyLogoUrl;
private final String jobCodes;
private final Integer totalHiring;
private final Long requestedApplicationCount;
private final Long approvedApplicationCount;
private final Boolean isBookmarked;
private final Long companyId;
private final long totalHiringCount;
private final long requestedApplicationCount;
private final long approvedApplicationCount;
private final long companyId;

}
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,13 @@ public StudentQueryRecruitmentsResponse execute(
queryRecruitmentPort.queryStudentRecruitmentsByFilter(recruitmentFilter).stream()
.map(
recruitment -> StudentRecruitmentResponse.builder()
.recruitId(recruitment.getRecruitmentId())
.id(recruitment.getRecruitmentId())
.companyName(recruitment.getCompanyName())
.trainPay(recruitment.getTrainPay())
.jobCodeList(recruitment.getJobCodes())
.military(recruitment.isMilitarySupport())
.hiringJobs(recruitment.getJobCodes())
.militarySupport(recruitment.isMilitarySupport())
.companyProfileUrl(recruitment.getCompanyLogoUrl())
.totalHiring(recruitment.getTotalHiring())
.isBookmarked(recruitment.getIsBookmarked())
.bookmarked(recruitment.isBookmarked())
.build()
).toList();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,15 @@ public TeacherQueryRecruitmentsResponse execute(String companyName, LocalDate st
.map(recruitment ->
TeacherRecruitmentResponse.builder()
.id(recruitment.getRecruitmentId())
.recruitmentStatus(recruitment.getRecruitStatus())
.status(recruitment.getRecruitStatus())
.companyName(recruitment.getCompanyName())
.companyType(recruitment.getCompanyType())
.start(recruitment.getStartDate())
.end(recruitment.getEndDate())
.militarySupport(recruitment.isMilitarySupport())
.startDate(recruitment.getStartDate())
.endDate(recruitment.getEndDate())
.applicationRequestedCount(recruitment.getRequestedApplicationCount())
.applicationApprovedCount(recruitment.getApprovedApplicationCount())
.recruitmentCount(recruitment.getTotalHiring())
.recruitmentJob(recruitment.getJobCodes())
.totalHiringCount(recruitment.getTotalHiringCount())
.hiringJobs(recruitment.getJobCodes())
.companyId(recruitment.getCompanyId())
.build()
).toList();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,12 @@
import team.retum.jobis.domain.recruitment.persistence.repository.RecruitmentJpaRepository;
import team.retum.jobis.domain.recruitment.persistence.repository.vo.QQueryRecruitAreaVO;
import team.retum.jobis.domain.recruitment.persistence.repository.vo.QQueryRecruitmentDetailVO;
import team.retum.jobis.domain.recruitment.persistence.repository.vo.QQueryRecruitmentsVO;
import team.retum.jobis.domain.recruitment.persistence.repository.vo.QQueryStudentRecruitmentsVO;
import team.retum.jobis.domain.recruitment.persistence.repository.vo.QQueryTeacherRecruitmentsVO;
import team.retum.jobis.domain.recruitment.spi.RecruitmentPort;
import team.retum.jobis.domain.recruitment.spi.vo.RecruitmentDetailVO;
import team.retum.jobis.domain.recruitment.spi.vo.RecruitmentVO;
import team.retum.jobis.domain.recruitment.spi.vo.StudentRecruitmentVO;
import team.retum.jobis.domain.recruitment.spi.vo.TeacherRecruitmentVO;

import java.time.LocalDate;
import java.util.List;
Expand Down Expand Up @@ -54,27 +56,19 @@ public class RecruitmentPersistenceAdapter implements RecruitmentPort {
private final RecruitAreaCodeMapper recruitAreaCodeMapper;

@Override
public List<RecruitmentVO> queryStudentRecruitmentsByFilter(RecruitmentFilter filter) {
public List<StudentRecruitmentVO> queryStudentRecruitmentsByFilter(RecruitmentFilter filter) {
StringExpression recruitJobsPath = Expressions.stringTemplate("group_concat({0})", codeEntity.keyword);

return queryFactory
.select(
new QQueryRecruitmentsVO(
new QQueryStudentRecruitmentsVO(
recruitmentEntity.id,
recruitmentEntity.status,
recruitmentEntity.recruitDate.startDate,
recruitmentEntity.recruitDate.finishDate,
companyEntity.name,
companyEntity.type,
recruitmentEntity.payInfo.trainPay,
recruitmentEntity.militarySupport,
companyEntity.companyLogoUrl,
recruitJobsPath,
recruitAreaEntity.hiredCount.sum(),
Expressions.ZERO.longValue(),
Expressions.ZERO.longValue(),
bookmarkEntity.recruitment.id.isNotNull(),
companyEntity.id
bookmarkEntity.recruitment.id.isNotNull()
)
)
.from(recruitmentEntity)
Expand All @@ -94,8 +88,6 @@ public List<RecruitmentVO> queryStudentRecruitmentsByFilter(RecruitmentFilter fi
.join(recruitAreaCodeEntity.code, codeEntity)
.where(
eqYear(filter.getYear()),
betweenRecruitDate(filter.getStartDate(), filter.getEndDate()),
eqRecruitStatus(filter.getStatus()),
containsName(filter.getCompanyName()),
containsCodes(filter.getCodes()),
eqWinterIntern(filter.getWinterIntern())
Expand All @@ -105,33 +97,29 @@ public List<RecruitmentVO> queryStudentRecruitmentsByFilter(RecruitmentFilter fi
.orderBy(recruitmentEntity.createdAt.desc())
.groupBy(recruitmentEntity.id)
.fetch().stream()
.map(RecruitmentVO.class::cast)
.map(StudentRecruitmentVO.class::cast)
.toList();
}

@Override
public List<RecruitmentVO> queryTeacherRecruitmentsByFilter(RecruitmentFilter filter) {
public List<TeacherRecruitmentVO> queryTeacherRecruitmentsByFilter(RecruitmentFilter filter) {
QApplicationEntity requestedApplication = new QApplicationEntity("requestedApplication");
QApplicationEntity approvedApplication = new QApplicationEntity("approvedApplication");

StringExpression recruitJobsPath = Expressions.stringTemplate("group_concat({0})", codeEntity.keyword);
return queryFactory
.select(
new QQueryRecruitmentsVO(
new QQueryTeacherRecruitmentsVO(
recruitmentEntity.id,
recruitmentEntity.status,
recruitmentEntity.recruitDate.startDate,
recruitmentEntity.recruitDate.finishDate,
companyEntity.name,
companyEntity.type,
recruitmentEntity.payInfo.trainPay,
recruitmentEntity.militarySupport,
companyEntity.companyLogoUrl,
recruitJobsPath,
recruitAreaEntity.hiredCount.sum(),
recruitAreaEntity.hiredCount.sum().divide(recruitAreaEntity.hiredCount.count()).longValue(),
requestedApplication.countDistinct(),
approvedApplication.countDistinct(),
Expressions.asBoolean(false),
companyEntity.id
)
)
Expand Down Expand Up @@ -167,7 +155,7 @@ public List<RecruitmentVO> queryTeacherRecruitmentsByFilter(RecruitmentFilter fi
.orderBy(recruitmentEntity.createdAt.desc())
.groupBy(recruitmentEntity.id)
.fetch().stream()
.map(RecruitmentVO.class::cast)
.map(TeacherRecruitmentVO.class::cast)
.toList();
}

Expand Down Expand Up @@ -217,8 +205,7 @@ public Long getRecruitmentCountByFilter(RecruitmentFilter filter) {
eqWinterIntern(filter.getWinterIntern())
)
.fetchOne();
}
else {
} else {
return queryFactory
.select(recruitmentEntity.count())
.from(recruitmentEntity)
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package team.retum.jobis.domain.recruitment.persistence.repository.vo;

import com.querydsl.core.annotations.QueryProjection;
import team.retum.jobis.domain.recruitment.spi.vo.StudentRecruitmentVO;

public class QueryStudentRecruitmentsVO extends StudentRecruitmentVO {

@QueryProjection
public QueryStudentRecruitmentsVO(long recruitmentId, String companyName, int trainPay,
boolean militarySupport, String companyLogoUrl, String jobCodes,
boolean isBookmarked) {
super(recruitmentId, companyName, trainPay, militarySupport, companyLogoUrl, jobCodes, isBookmarked);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package team.retum.jobis.domain.recruitment.persistence.repository.vo;

import com.querydsl.core.annotations.QueryProjection;
import lombok.Getter;
import team.retum.jobis.domain.company.model.CompanyType;
import team.retum.jobis.domain.recruitment.model.RecruitStatus;
import team.retum.jobis.domain.recruitment.spi.vo.TeacherRecruitmentVO;

import java.time.LocalDate;

@Getter
public class QueryTeacherRecruitmentsVO extends TeacherRecruitmentVO {

@QueryProjection
public QueryTeacherRecruitmentsVO(long recruitmentId, RecruitStatus recruitStatus,
LocalDate startDate, LocalDate endDate, String companyName,
CompanyType companyType, String jobCodes, long totalHiring,
long requestedApplicationCount, long approvedApplicationCount,
long companyId) {
super(recruitmentId, recruitStatus, startDate, endDate,
companyName, companyType, jobCodes, totalHiring,
requestedApplicationCount, approvedApplicationCount,
companyId);
}
}
Loading

0 comments on commit 86c90d7

Please sign in to comment.