Skip to content

Commit

Permalink
πŸ”— :: (#598) 지원 κ°€λŠ₯ μ—¬λΆ€λ₯Ό μž…ν•™λ…„λ„λ‘œ ꡬ뢄, ν•™λ²ˆ unique 쑰건에 μž…ν•™λ…„λ„λ„ μΆ”κ°€
Browse files Browse the repository at this point in the history
πŸ”— :: (#598) 지원 κ°€λŠ₯ μ—¬λΆ€λ₯Ό μž…ν•™λ…„λ„λ‘œ ꡬ뢄, ν•™λ²ˆ unique 쑰건에 μž…ν•™λ…„λ„λ„ μΆ”κ°€
  • Loading branch information
geunoo authored Mar 21, 2024
2 parents ba00de8 + d40afde commit ce3cc9e
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ public class CreateApplicationUseCase {

public void execute(Long recruitmentId, List<AttachmentRequest> attachmentRequests) {
Student student = securityPort.getCurrentStudent();

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

recruitment.checkIsApplicable(student.getEntranceYear());

if (queryApplicationPort.existsApplicationByStudentIdAndApplicationStatusIn(
student.getId(), ApplicationStatus.DUPLICATE_CHECK
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,23 @@ public Recruitment changeStatus(RecruitStatus status) {
.build();
}

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

if (studentGrade == 1 || (!this.winterIntern && studentGrade == 2)) {
// 쑸업생이 μ§€μ›μ‹œ μ˜ˆμ™Έλ₯Ό 던짐
if (Year.now().getValue() - 3 >= entranceYear) {
throw InvalidGradeException.EXCEPTION;
}

// 1학년이 지원할 경우 μ˜ˆμ™Έλ₯Ό 던짐
if (Year.now().getValue() == entranceYear) {
throw InvalidGradeException.EXCEPTION;
}

// 2학년이 μ•„λ‹Œ 학년이 μ±„ν—˜ν˜• ν˜„μž₯μ‹€μŠ΅ μ§€μ›μ‹œ μ˜ˆμ™Έλ₯Ό 던짐
if (this.winterIntern && entranceYear != Year.now().getValue() - 1) {
throw InvalidGradeException.EXCEPTION;
}
}
Expand Down Expand Up @@ -130,5 +141,4 @@ public Recruitment update(UpdateRecruitmentRequest request) {
.etc(request.etc())
.build();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
name = "tbl_student",
uniqueConstraints = {
@UniqueConstraint(
columnNames = {"grade", "classRoom", "number"}
columnNames = {"grade", "classRoom", "number", "entranceYear"}
)
}
)
Expand Down
1 change: 1 addition & 0 deletions jobis-infrastructure/src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ spring:
flyway:
baseline-on-migrate: true
baseline-version: 0
enabled: ${FLYWAY_ENABLED:true}

jpa:
database-platform: team.retum.jobis.global.config.MysqlDialectConfig
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
alter table tbl_student drop constraint UKd3mywdtv4c22n8m41uag1osc2;
alter table tbl_student add constraint SCHOOL_NUMBER_UNIQUE unique (grade, class_room, number, entrance_year)

0 comments on commit ce3cc9e

Please sign in to comment.