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 Nov 21, 2023
2 parents be070a5 + e5f9601 commit 3db7aa0
Show file tree
Hide file tree
Showing 63 changed files with 488 additions and 331 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import lombok.NoArgsConstructor;
import net.bytebuddy.utility.RandomString;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

@NoArgsConstructor(access = AccessLevel.PRIVATE)
Expand All @@ -13,15 +15,14 @@ public static <E> String joinStringList(List<E> request, String key) {
return request == null ? null : String.join(key, request.stream().map(Object::toString).toList());
}

public static String mergeString(String str1, String str2) {
return str1 + " " + str2;
}

public static List<String> divideString(String content, String key) {
if (content == null || content.isEmpty()) {
if (content == null || content.isEmpty() || content.isBlank()) {
return List.of();
}
return List.of(content.split(key));

List<String> dividedList = Arrays.asList(content.split(key));

return new ArrayList<>(dividedList);
}

public static String generateRandomCode(int size) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,13 @@ public class Acceptance {

private final Integer year;

private final String studentName;

private final String businessArea;

private final List<String> tech;

private final String studentGcn;

private final LocalDate contractDate;

private final Long companyId;

private final Long studentId;
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package team.retum.jobis.domain.acceptance.spi;

import team.retum.jobis.domain.acceptance.model.Acceptance;
import team.retum.jobis.domain.acceptance.spi.vo.AcceptanceVO;

import java.util.List;

public interface QueryAcceptancePort {

List<Acceptance> queryAcceptancesByCompanyIdAndYear(Long companyId, Integer year);
List<AcceptanceVO> queryAcceptancesByCompanyIdAndYear(Long companyId, Integer year);

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

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.time.LocalDate;

@Getter
@AllArgsConstructor
public class AcceptanceVO {

private final Long acceptanceId;
private final Integer grade;
private final Integer classRoom;
private final Integer number;
private final String studentName;
private final LocalDate contractDate;
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import team.retum.jobis.domain.application.spi.CommandApplicationPort;
import team.retum.jobis.domain.application.spi.QueryApplicationPort;
import team.retum.jobis.domain.application.spi.vo.ApplicationDetailVO;
import team.retum.jobis.domain.student.model.Student;

import java.time.LocalDate;
import java.time.Year;
Expand Down Expand Up @@ -39,23 +38,19 @@ public void execute(RegisterEmploymentContractRequest request) {
}

return Acceptance.builder()
.studentName(application.getStudentName())
.companyId(application.getId())
.studentGcn(Student.processGcn(
application.getStudentGrade(),
application.getStudentClassNumber(),
application.getStudentNumber()
))
.companyId(application.getCompanyId())
.contractDate(LocalDate.now())
.year(Year.now().getValue())
.tech(request.getCodeKeywords())
.businessArea(application.getBusinessArea())
.studentId(application.getStudentId())
.build();
}
).toList();

commandAcceptancePort.saveAllAcceptance(acceptances);
commandApplicationPort.deleteApplicationByIds(
commandApplicationPort.changeApplicationStatus(
ApplicationStatus.ACCEPTANCE,
applications.stream().map(ApplicationDetailVO::getId).toList()
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
import team.retum.jobis.domain.acceptance.dto.response.TeacherQueryFieldTraineesAndContractWorkersResponse;
import team.retum.jobis.domain.acceptance.dto.response.TeacherQueryFieldTraineesAndContractWorkersResponse.TeacherQueryContractWorkersResponse;
import team.retum.jobis.domain.acceptance.dto.response.TeacherQueryFieldTraineesAndContractWorkersResponse.TeacherQueryFieldTraineesResponse;
import team.retum.jobis.domain.acceptance.model.Acceptance;
import team.retum.jobis.domain.acceptance.spi.QueryAcceptancePort;
import team.retum.jobis.domain.acceptance.spi.vo.AcceptanceVO;
import team.retum.jobis.domain.application.spi.QueryApplicationPort;
import team.retum.jobis.domain.application.spi.vo.FieldTraineesVO;
import team.retum.jobis.domain.student.model.Student;
Expand All @@ -22,54 +22,54 @@ public class TeacherQueryFieldTraineesAndContractWorkersUseCase {
private final QueryAcceptancePort queryAcceptancePort;

public TeacherQueryFieldTraineesAndContractWorkersResponse execute(Long companyId) {

List<FieldTraineesVO> queryFieldTraineesVOs =
queryApplicationPort.queryApplicationsFieldTraineesByCompanyId(companyId);

List<Acceptance> acceptanceEntities =
queryAcceptancePort.queryAcceptancesByCompanyIdAndYear(companyId, Year.now().getValue());
List<FieldTraineesVO> fieldTrainees = queryApplicationPort.queryApplicationsFieldTraineesByCompanyId(companyId);
List<AcceptanceVO> acceptances = queryAcceptancePort.queryAcceptancesByCompanyIdAndYear(companyId, Year.now().getValue());

return new TeacherQueryFieldTraineesAndContractWorkersResponse(
buildFieldTrainees(queryFieldTraineesVOs),
buildContractWorkers(acceptanceEntities)
buildFieldTrainees(fieldTrainees),
buildContractWorkers(acceptances)
);
}

private List<TeacherQueryFieldTraineesResponse> buildFieldTrainees(
List<FieldTraineesVO> queryFieldTraineesVOs
List<FieldTraineesVO> fieldTrainees
) {
return queryFieldTraineesVOs.stream()
.map(vo -> TeacherQueryFieldTraineesResponse
.builder()
.applicationId(vo.getApplicationId())
.studentGcn(
Student.processGcn(
vo.getGrade(),
vo.getClassRoom(),
vo.getNumber()
return fieldTrainees.stream()
.map(
fieldTrainee -> TeacherQueryFieldTraineesResponse
.builder()
.applicationId(fieldTrainee.getApplicationId())
.studentGcn(
Student.processGcn(
fieldTrainee.getGrade(),
fieldTrainee.getClassRoom(),
fieldTrainee.getNumber()
)
)
)
.studentName(vo.getStudentName())
.startDate(vo.getStartDate())
.endDate(vo.getEndDate())
.build())
.toList();
.studentName(fieldTrainee.getStudentName())
.startDate(fieldTrainee.getStartDate())
.endDate(fieldTrainee.getEndDate())
.build()
).toList();
}

private List<TeacherQueryContractWorkersResponse> buildContractWorkers(
List<Acceptance> acceptanceEntities
List<AcceptanceVO> acceptances
) {
return acceptanceEntities
.stream()
return acceptances.stream()
.map(
acceptance -> TeacherQueryContractWorkersResponse
.builder()
.acceptanceId(acceptance.getId())
.studentGcn(acceptance.getStudentGcn())
.acceptanceId(acceptance.getAcceptanceId())
.studentGcn(
Student.processGcn(
acceptance.getGrade(),
acceptance.getClassRoom(),
acceptance.getNumber()
))
.studentName(acceptance.getStudentName())
.contractDate(acceptance.getContractDate())
.build()
)
.toList();
).toList();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,6 @@ public Application toFieldTrain(LocalDate startDate, LocalDate endDate) {
}

public Application rejectApplication(String reason) {
if (applicationStatus != ApplicationStatus.REQUESTED) {
throw ApplicationStatusCannotChangeException.EXCEPTION;
}

return this.toBuilder()
.applicationStatus(ApplicationStatus.REJECTED)
.rejectionReason(reason)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ public enum ApplicationStatus {
APPROVED, // 승인
FAILED, // 탈락
PASS, // 통과
FIELD_TRAIN, // 현장실습,
FIELD_TRAIN, // 현장실습
ACCEPTANCE, // 근로계약
REJECTED; // 거부

public static final List<ApplicationStatus> DUPLICATE_CHECK = List.of(APPROVED, PASS, FIELD_TRAIN);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,7 @@ public class ApplicationDetailVO {

private final Long id;

private final String studentName;

private final int studentGrade;

private final int studentClassNumber;

private final int studentNumber;
private final Long studentId;

private final Long companyId;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,9 @@ public class CreateApplicationUseCase {

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

Recruitment recruitment = queryRecruitmentPort.queryRecruitmentById(recruitmentId)
.orElseThrow(() -> RecruitmentNotFoundException.EXCEPTION);
recruitment.checkIsApplicable();
recruitment.checkIsApplicable(student.getGrade());

if (queryApplicationPort.existsApplicationByStudentIdAndApplicationStatusIn(
student.getId(), ApplicationStatus.DUPLICATE_CHECK
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ public class RecruitAreaCode {

private final Long recruitAreaId;

private final Long codeId;
private final Long code;

private final CodeType type;

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package team.retum.jobis.domain.code.service;

import lombok.RequiredArgsConstructor;
import team.retum.jobis.common.annotation.Service;
import team.retum.jobis.common.util.StringUtil;
import team.retum.jobis.domain.code.exception.CodeNotFoundException;
import team.retum.jobis.domain.code.model.Code;
import team.retum.jobis.domain.code.spi.QueryCodePort;

import java.util.List;

@RequiredArgsConstructor
@Service
public class GetKeywordsService {

private final QueryCodePort queryCodePort;

public String getKeywordsAsJoinedString(String jobCodes) {
return StringUtil.joinStringList(
queryCodePort.queryCodesByIdIn(
StringUtil.divideString(jobCodes, ",").stream().map(Long::parseLong).toList()
).stream().map(Code::getKeyword).toList(),
"/"
);
}

public List<String> getKeywordsAsList(List<String> jobCodes) {
return queryCodePort.queryCodesByIdIn(
jobCodes.stream().map(Long::parseLong).toList()
).stream().map(Code::getKeyword).toList();
}

public String getCodeKeyword(Long code) {
return queryCodePort.queryCodeById(code)
.orElseThrow(() -> CodeNotFoundException.EXCEPTION)
.getKeyword();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ public class RecruitmentFilter {

private final Long studentId;

private final Long jobCode;

private final Boolean winterIntern;
@Builder.Default
private int limit = 11;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,7 @@ public class ApplyRecruitmentRequest {

private LocalDate endDate;

private boolean winterIntern;

private String etc;
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
package team.retum.jobis.domain.recruitment.dto.response;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;

import java.util.List;

@Getter
@AllArgsConstructor
@Builder
public class RecruitAreaResponse {

private final Long id;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
import lombok.Getter;
import team.retum.jobis.common.annotation.Aggregate;

import java.util.List;

@Getter
@Builder
@Aggregate
Expand All @@ -17,8 +15,6 @@ public class RecruitArea {

private final String majorTask;

private final List<String> jobCodes;

private final String preferentialTreatment;

private final Long recruitmentId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import lombok.Builder;
import lombok.Getter;
import team.retum.jobis.common.annotation.Aggregate;
import team.retum.jobis.domain.application.exception.InvalidGradeException;
import team.retum.jobis.domain.recruitment.exception.CompanyMismatchException;
import team.retum.jobis.domain.recruitment.exception.InvalidRecruitmentStatusException;

Expand Down Expand Up @@ -49,6 +50,8 @@ public class Recruitment {

private final boolean personalContract;

private final boolean winterIntern;

private final Long companyId;

public Recruitment update(Integer trainPay, String pay, LocalTime startTime, LocalTime endTime, String submitDocument,
Expand Down Expand Up @@ -84,9 +87,13 @@ public void checkCompany(Long companyId) {
}
}

public void checkIsApplicable() {
public void checkIsApplicable(Integer studentGrade) {
if (this.status != RecruitStatus.RECRUITING) {
throw InvalidRecruitmentStatusException.EXCEPTION;
}

if (studentGrade == 1 || (!this.winterIntern && studentGrade == 2)) {
throw InvalidGradeException.EXCEPTION;
}
}
}
Loading

0 comments on commit 3db7aa0

Please sign in to comment.