Skip to content

Commit

Permalink
๐Ÿ”— :: (#534) ๋ชจ์ง‘์˜๋ขฐ์„œ ์ƒ์„ธ์กฐํšŒ์— ๋ถ๋งˆํฌ ์—ฌ๋ถ€, ์ง€์›๊ฐ€๋Šฅ ์—ฌ๋ถ€ ์ถ”๊ฐ€ํ•˜๊ธฐ
Browse files Browse the repository at this point in the history
๐Ÿ”— :: (#534) ๋ชจ์ง‘์˜๋ขฐ์„œ ์ƒ์„ธ์กฐํšŒ์— ๋ถ๋งˆํฌ ์—ฌ๋ถ€, ์ง€์›๊ฐ€๋Šฅ ์—ฌ๋ถ€ ์ถ”๊ฐ€ํ•˜๊ธฐ
  • Loading branch information
geunoo authored Mar 4, 2024
2 parents 308ebf1 + afe4c96 commit 9bd6dba
Show file tree
Hide file tree
Showing 9 changed files with 60 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,10 @@ public class QueryRecruitmentDetailResponse {
private final LocalDate startDate;
private final LocalDate endDate;
private final String etc;
private final Boolean isApplicable;
private final boolean isBookmarked;

public static QueryRecruitmentDetailResponse of(RecruitmentDetailVO recruitmentDetail, List<RecruitAreaResponse> recruitAreas) {
public static QueryRecruitmentDetailResponse of(RecruitmentDetailVO recruitmentDetail, List<RecruitAreaResponse> recruitAreas, Boolean isApplicable) {
return QueryRecruitmentDetailResponse.builder()
.recruitmentId(recruitmentDetail.getRecruitmentId())
.companyId(recruitmentDetail.getCompanyId())
Expand All @@ -56,6 +58,8 @@ public static QueryRecruitmentDetailResponse of(RecruitmentDetailVO recruitmentD
.startDate(recruitmentDetail.getStartDate())
.endDate(recruitmentDetail.getEndDate())
.etc(recruitmentDetail.getEtc())
.isApplicable(isApplicable)
.isBookmarked(recruitmentDetail.isBookmarked())
.build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public interface QueryRecruitmentPort {

Optional<Recruitment> queryRecentRecruitmentByCompanyId(Long companyId);

RecruitmentDetailVO queryRecruitmentDetailById(Long recruitmentId);
RecruitmentDetailVO queryRecruitmentDetailById(Long recruitmentId, Long studentId);

List<StudentRecruitmentVO> queryStudentRecruitmentsByFilter(RecruitmentFilter filter);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,6 @@ public class RecruitmentDetailVO {
private final LocalDate endDate;
private final String etc;
private final String companyBizNo;
private final boolean winterIntern;
private final boolean isBookmarked;
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public QueryMyRecruitmentResponse execute() {
Recruitment recruitment = queryRecruitmentPort.queryRecentRecruitmentByCompanyId(currentUserId)
.orElseThrow(() -> RecruitmentNotFoundException.EXCEPTION);

RecruitmentDetailVO recruitmentDetail = queryRecruitmentPort.queryRecruitmentDetailById(recruitment.getId());
RecruitmentDetailVO recruitmentDetail = queryRecruitmentPort.queryRecruitmentDetailById(recruitment.getId(), currentUserId);
List<RecruitAreaResponse> recruitAreaResponses = queryRecruitmentPort.queryRecruitAreasByRecruitmentId(recruitment.getId())
.stream().map(recruitAreaResponse -> RecruitAreaResponse.builder()
.id(recruitAreaResponse.getId())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import lombok.RequiredArgsConstructor;
import team.retum.jobis.common.annotation.ReadOnlyUseCase;
import team.retum.jobis.common.spi.SecurityPort;
import team.retum.jobis.domain.auth.model.Authority;
import team.retum.jobis.domain.recruitment.dto.response.QueryRecruitmentDetailResponse;
import team.retum.jobis.domain.recruitment.dto.response.RecruitAreaResponse;
import team.retum.jobis.domain.recruitment.exception.RecruitmentNotFoundException;
Expand All @@ -14,24 +16,37 @@
@RequiredArgsConstructor
@ReadOnlyUseCase
public class QueryRecruitmentDetailUseCase {

private final QueryRecruitmentPort queryRecruitmentPort;
private final SecurityPort securityPort;

public QueryRecruitmentDetailResponse execute(Long recruitId) {
Recruitment recruitment = queryRecruitmentPort.queryRecruitmentById(recruitId)
.orElseThrow(() -> RecruitmentNotFoundException.EXCEPTION);

RecruitmentDetailVO recruitmentDetail = queryRecruitmentPort.queryRecruitmentDetailById(recruitment.getId());
List<RecruitAreaResponse> recruitAreaResponses = queryRecruitmentPort.queryRecruitAreasByRecruitmentId(recruitment.getId())
.stream().map(recruitAreaResponse -> RecruitAreaResponse.builder()
.id(recruitAreaResponse.getId())
.job(recruitAreaResponse.getJob())
.tech(recruitAreaResponse.getTech())
.hiring(recruitAreaResponse.getHiring())
.majorTask(recruitAreaResponse.getMajorTask())
.preferentialTreatment(recruitAreaResponse.getPreferentialTreatment())
.build()
RecruitmentDetailVO recruitmentDetail = queryRecruitmentPort.queryRecruitmentDetailById(recruitment.getId(), securityPort.getCurrentUserId());
List<RecruitAreaResponse> recruitAreaResponses = queryRecruitmentPort.queryRecruitAreasByRecruitmentId(
recruitment.getId()
).stream()
.map(recruitAreaResponse ->
RecruitAreaResponse.builder()
.id(recruitAreaResponse.getId())
.job(recruitAreaResponse.getJob())
.tech(recruitAreaResponse.getTech())
.hiring(recruitAreaResponse.getHiring())
.majorTask(recruitAreaResponse.getMajorTask())
.preferentialTreatment(recruitAreaResponse.getPreferentialTreatment())
.build()
).toList();

return QueryRecruitmentDetailResponse.of(recruitmentDetail, recruitAreaResponses);
return QueryRecruitmentDetailResponse.of(recruitmentDetail, recruitAreaResponses, getApplicable(recruitmentDetail.isWinterIntern()));
}

private Boolean getApplicable(boolean winterIntern) {
if (securityPort.getCurrentUserAuthority().equals(Authority.STUDENT)
|| securityPort.getCurrentUserAuthority().equals(Authority.DEVELOPER)) {
return securityPort.getCurrentStudent().getApplicable(winterIntern);
}
return null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,11 @@ private Integer getEntranceYear(Integer grade) {
default -> year;
};
}

public boolean getApplicable(boolean winterIntern) {
if (winterIntern && this.schoolNumber.getGrade().equals(2)) {
return true;
}
return !winterIntern && this.schoolNumber.getGrade().equals(3);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ public List<TeacherRecruitmentVO> queryTeacherRecruitmentsByFilter(RecruitmentFi
}

@Override
public RecruitmentDetailVO queryRecruitmentDetailById(Long recruitmentId) {
public RecruitmentDetailVO queryRecruitmentDetailById(Long recruitmentId, Long userId) {
return queryFactory
.select(
new QQueryRecruitmentDetailVO(
Expand All @@ -186,13 +186,18 @@ public RecruitmentDetailVO queryRecruitmentDetailById(Long recruitmentId) {
recruitmentEntity.recruitDate.startDate,
recruitmentEntity.recruitDate.finishDate,
recruitmentEntity.etc,
companyEntity.bizNo
companyEntity.bizNo,
recruitmentEntity.winterIntern,
bookmarkEntity.isNotNull()
)
)
.from(recruitmentEntity)
.join(recruitmentEntity.company, companyEntity)
.join(recruitAreaEntity)
.on(recruitAreaEntity.recruitment.eq(recruitmentEntity))
.leftJoin(bookmarkEntity)
.on(
recruitmentEntity.id.eq(bookmarkEntity.recruitment.id),
bookmarkEntity.student.id.eq(userId)
)
.where(recruitmentEntity.id.eq(recruitmentId))
.fetchOne();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,15 @@
public class QueryRecruitmentDetailVO extends RecruitmentDetailVO {

@QueryProjection

public QueryRecruitmentDetailVO(Long recruitmentId, Long companyId, String companyProfileUrl, String companyName,
Integer requiredGrade, LocalTime startTime, LocalTime endTime,
List<String> requiredLicenses, List<ProgressType> hiringProgress,
Integer trainPay, String pay, String benefits, Boolean military,
String submitDocument, LocalDate startDate, LocalDate endDate,
String etc, String bizNo) {
super(recruitmentId, companyId, companyProfileUrl, companyName, requiredGrade, startTime, endTime,
requiredLicenses, hiringProgress, trainPay, pay, benefits, military, submitDocument,
startDate, endDate, etc, bizNo);
Integer requiredGrade, LocalTime startTime, LocalTime endTime, List<String> requiredLicenses,
List<ProgressType> hiringProgress, Integer trainPay, String pay, String benefits,
Boolean military, String submitDocument, LocalDate startDate, LocalDate endDate,
String etc, String companyBizNo, boolean winterIntern, boolean isBookmarked) {
super(recruitmentId, companyId, companyProfileUrl, companyName,
requiredGrade, startTime, endTime, requiredLicenses,
hiringProgress, trainPay, pay, benefits, military,
submitDocument, startDate, endDate, etc, companyBizNo, winterIntern, isBookmarked);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,6 @@ public void changeRecruitStatus(@RequestBody @Valid ChangeRecruitmentStatusWebRe

}

@Cacheable
@GetMapping("/{recruitment-id}")
public QueryRecruitmentDetailResponse queryRecruitmentDetail(
@PathVariable("recruitment-id") Long recruitmentId
Expand Down

0 comments on commit 9bd6dba

Please sign in to comment.