From fe8a8c014c53179f5a701f279d4f526e39579356 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B8=B8=EA=B7=BC=EC=9A=B0?= Date: Thu, 21 Mar 2024 22:10:18 +0900 Subject: [PATCH 1/4] =?UTF-8?q?=F0=9F=A7=A9=20::=20(#598)=20=ED=95=99?= =?UTF-8?q?=EB=B2=88=20unique=20=EC=A1=B0=EA=B1=B4=EC=97=90=20=EC=9E=85?= =?UTF-8?q?=ED=95=99=EB=85=84=EB=8F=84=EB=8F=84=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../jobis/domain/student/persistence/entity/StudentEntity.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jobis-infrastructure/src/main/java/team/retum/jobis/domain/student/persistence/entity/StudentEntity.java b/jobis-infrastructure/src/main/java/team/retum/jobis/domain/student/persistence/entity/StudentEntity.java index 777c4a87f..3ca402bca 100644 --- a/jobis-infrastructure/src/main/java/team/retum/jobis/domain/student/persistence/entity/StudentEntity.java +++ b/jobis-infrastructure/src/main/java/team/retum/jobis/domain/student/persistence/entity/StudentEntity.java @@ -32,7 +32,7 @@ name = "tbl_student", uniqueConstraints = { @UniqueConstraint( - columnNames = {"grade", "classRoom", "number"} + columnNames = {"grade", "classRoom", "number", "entranceYear"} ) } ) From a386e65eacbd8965b0e017802e0dc32aefdeb381 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B8=B8=EA=B7=BC=EC=9A=B0?= Date: Thu, 21 Mar 2024 22:10:40 +0900 Subject: [PATCH 2/4] =?UTF-8?q?=F0=9F=A7=A9=20::=20(#598)=20=EC=A7=80?= =?UTF-8?q?=EC=9B=90=20=EA=B0=80=EB=8A=A5=20=EC=97=AC=EB=B6=80=EB=A5=BC=20?= =?UTF-8?q?=EC=9E=85=ED=95=99=EB=85=84=EB=8F=84=EB=A1=9C=20=EA=B5=AC?= =?UTF-8?q?=EB=B6=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../usecase/CreateApplicationUseCase.java | 4 ++-- .../domain/recruitment/model/Recruitment.java | 19 +++++++++++++++++-- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/jobis-application/src/main/java/team/retum/jobis/domain/application/usecase/CreateApplicationUseCase.java b/jobis-application/src/main/java/team/retum/jobis/domain/application/usecase/CreateApplicationUseCase.java index 661934487..d6054a2a9 100644 --- a/jobis-application/src/main/java/team/retum/jobis/domain/application/usecase/CreateApplicationUseCase.java +++ b/jobis-application/src/main/java/team/retum/jobis/domain/application/usecase/CreateApplicationUseCase.java @@ -28,10 +28,10 @@ public class CreateApplicationUseCase { public void execute(Long recruitmentId, List 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 diff --git a/jobis-application/src/main/java/team/retum/jobis/domain/recruitment/model/Recruitment.java b/jobis-application/src/main/java/team/retum/jobis/domain/recruitment/model/Recruitment.java index a1ac7af8a..f83c82daa 100644 --- a/jobis-application/src/main/java/team/retum/jobis/domain/recruitment/model/Recruitment.java +++ b/jobis-application/src/main/java/team/retum/jobis/domain/recruitment/model/Recruitment.java @@ -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; } } @@ -131,4 +142,8 @@ public Recruitment update(UpdateRecruitmentRequest request) { .build(); } + private boolean v(Integer entranceYear) { + return entranceYear == Year.now().getValue() - 2; + } + } From fcb0dbacd777ac1f9c70f934042ad7accdd5e3a1 Mon Sep 17 00:00:00 2001 From: gilgeunwoo Date: Thu, 21 Mar 2024 22:31:33 +0900 Subject: [PATCH 3/4] =?UTF-8?q?=F0=9F=A7=A9=20::=20(#598)=20db=20=EB=A7=88?= =?UTF-8?q?=EC=9D=B4=EA=B7=B8=EB=A0=88=EC=9D=B4=EC=85=98=20sql?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- jobis-infrastructure/src/main/resources/application.yml | 1 + .../db/migration/V4__modify_school_number_unique_constraint.sql | 2 ++ 2 files changed, 3 insertions(+) create mode 100644 jobis-infrastructure/src/main/resources/db/migration/V4__modify_school_number_unique_constraint.sql diff --git a/jobis-infrastructure/src/main/resources/application.yml b/jobis-infrastructure/src/main/resources/application.yml index 72330a351..f9ed7945c 100644 --- a/jobis-infrastructure/src/main/resources/application.yml +++ b/jobis-infrastructure/src/main/resources/application.yml @@ -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 diff --git a/jobis-infrastructure/src/main/resources/db/migration/V4__modify_school_number_unique_constraint.sql b/jobis-infrastructure/src/main/resources/db/migration/V4__modify_school_number_unique_constraint.sql new file mode 100644 index 000000000..93be74886 --- /dev/null +++ b/jobis-infrastructure/src/main/resources/db/migration/V4__modify_school_number_unique_constraint.sql @@ -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) \ No newline at end of file From d40afde47c03c39eb1b9c52fb0e8a93324526573 Mon Sep 17 00:00:00 2001 From: gilgeunwoo Date: Thu, 21 Mar 2024 22:58:27 +0900 Subject: [PATCH 4/4] =?UTF-8?q?=E2=9A=99=EF=B8=8F=20::=20(#598)=20?= =?UTF-8?q?=EC=A1=B0=EA=B1=B4=20=EC=98=A4=EB=A5=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../jobis/domain/recruitment/model/Recruitment.java | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/jobis-application/src/main/java/team/retum/jobis/domain/recruitment/model/Recruitment.java b/jobis-application/src/main/java/team/retum/jobis/domain/recruitment/model/Recruitment.java index f83c82daa..932d65418 100644 --- a/jobis-application/src/main/java/team/retum/jobis/domain/recruitment/model/Recruitment.java +++ b/jobis-application/src/main/java/team/retum/jobis/domain/recruitment/model/Recruitment.java @@ -86,7 +86,7 @@ public void checkIsApplicable(Integer entranceYear) { } // 졸업생이 지원시 예외를 던짐 - if (Year.now().getValue() - 3 <= entranceYear) { + if (Year.now().getValue() - 3 >= entranceYear) { throw InvalidGradeException.EXCEPTION; } @@ -96,7 +96,7 @@ public void checkIsApplicable(Integer entranceYear) { } // 2학년이 아닌 학년이 채험형 현장실습 지원시 예외를 던짐 - if (!(this.winterIntern && entranceYear == Year.now().getValue() - 1)) { + if (this.winterIntern && entranceYear != Year.now().getValue() - 1) { throw InvalidGradeException.EXCEPTION; } } @@ -141,9 +141,4 @@ public Recruitment update(UpdateRecruitmentRequest request) { .etc(request.etc()) .build(); } - - private boolean v(Integer entranceYear) { - return entranceYear == Year.now().getValue() - 2; - } - }