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/banner/model/BannerType.java b/jobis-application/src/main/java/team/retum/jobis/domain/banner/model/BannerType.java index bb2fc100f..5fc2acb7d 100644 --- a/jobis-application/src/main/java/team/retum/jobis/domain/banner/model/BannerType.java +++ b/jobis-application/src/main/java/team/retum/jobis/domain/banner/model/BannerType.java @@ -2,7 +2,7 @@ public enum BannerType { - RECRRUITMENT, + RECRUITMENT, BOOKMARK, NONE, INTERNSHIP, diff --git a/jobis-application/src/main/java/team/retum/jobis/domain/banner/spi/vo/TeacherBannersVO.java b/jobis-application/src/main/java/team/retum/jobis/domain/banner/spi/vo/TeacherBannersVO.java index 0f181e3e0..3ae750712 100644 --- a/jobis-application/src/main/java/team/retum/jobis/domain/banner/spi/vo/TeacherBannersVO.java +++ b/jobis-application/src/main/java/team/retum/jobis/domain/banner/spi/vo/TeacherBannersVO.java @@ -9,7 +9,7 @@ @Getter @AllArgsConstructor public class TeacherBannersVO { - private final Long bannerId; + private final Long id; private final String bannerUrl; private final BannerType bannerType; private final LocalDate startDate; diff --git a/jobis-application/src/main/java/team/retum/jobis/domain/code/model/CodeResponse.java b/jobis-application/src/main/java/team/retum/jobis/domain/code/model/CodeResponse.java new file mode 100644 index 000000000..f79e5b24a --- /dev/null +++ b/jobis-application/src/main/java/team/retum/jobis/domain/code/model/CodeResponse.java @@ -0,0 +1,15 @@ +package team.retum.jobis.domain.code.model; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; + +@Getter +@NoArgsConstructor(force = true) +@AllArgsConstructor +@Builder +public class CodeResponse { + private final Long id; + private final String name; +} \ No newline at end of file diff --git a/jobis-application/src/main/java/team/retum/jobis/domain/recruitment/dto/response/RecruitAreaResponse.java b/jobis-application/src/main/java/team/retum/jobis/domain/recruitment/dto/response/RecruitAreaResponse.java index abcfff928..88a9d46dc 100644 --- a/jobis-application/src/main/java/team/retum/jobis/domain/recruitment/dto/response/RecruitAreaResponse.java +++ b/jobis-application/src/main/java/team/retum/jobis/domain/recruitment/dto/response/RecruitAreaResponse.java @@ -4,6 +4,7 @@ import lombok.Builder; import lombok.Getter; import lombok.NoArgsConstructor; +import team.retum.jobis.domain.code.model.CodeResponse; import java.util.List; @@ -15,9 +16,9 @@ public class RecruitAreaResponse { private final Long id; - private final List job; + private final List job; - private final List tech; + private final List tech; private final int hiring; 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..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 @@ -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; } } @@ -130,5 +141,4 @@ public Recruitment update(UpdateRecruitmentRequest request) { .etc(request.etc()) .build(); } - } diff --git a/jobis-application/src/main/java/team/retum/jobis/domain/recruitment/usecase/QueryRecruitmentDetailUseCase.java b/jobis-application/src/main/java/team/retum/jobis/domain/recruitment/usecase/QueryRecruitmentDetailUseCase.java index 1ef8dbef9..68e34978b 100644 --- a/jobis-application/src/main/java/team/retum/jobis/domain/recruitment/usecase/QueryRecruitmentDetailUseCase.java +++ b/jobis-application/src/main/java/team/retum/jobis/domain/recruitment/usecase/QueryRecruitmentDetailUseCase.java @@ -4,6 +4,7 @@ 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.code.model.CodeResponse; 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; @@ -31,8 +32,12 @@ public QueryRecruitmentDetailResponse execute(Long recruitId) { .map(recruitAreaResponse -> RecruitAreaResponse.builder() .id(recruitAreaResponse.getId()) - .job(recruitAreaResponse.getJob()) - .tech(recruitAreaResponse.getTech()) + .job(recruitAreaResponse.getJob().stream() + .map(job -> new CodeResponse(job.getId(), job.getName())) + .toList()) + .tech(recruitAreaResponse.getTech().stream() + .map(tech -> new CodeResponse(tech.getId(), tech.getName())) + .toList()) .hiring(recruitAreaResponse.getHiring()) .majorTask(recruitAreaResponse.getMajorTask()) .preferentialTreatment(recruitAreaResponse.getPreferentialTreatment()) @@ -49,4 +54,4 @@ private Boolean getApplicable(boolean winterIntern) { } return null; } -} +} \ No newline at end of file diff --git a/jobis-infrastructure/src/main/java/team/retum/jobis/domain/recruitment/persistence/repository/vo/QueryRecruitAreaVO.java b/jobis-infrastructure/src/main/java/team/retum/jobis/domain/recruitment/persistence/repository/vo/QueryRecruitAreaVO.java index 4862218b1..fcb22fb0c 100644 --- a/jobis-infrastructure/src/main/java/team/retum/jobis/domain/recruitment/persistence/repository/vo/QueryRecruitAreaVO.java +++ b/jobis-infrastructure/src/main/java/team/retum/jobis/domain/recruitment/persistence/repository/vo/QueryRecruitAreaVO.java @@ -2,6 +2,7 @@ import com.querydsl.core.annotations.QueryProjection; import lombok.Getter; +import team.retum.jobis.domain.code.model.CodeResponse; import team.retum.jobis.domain.code.model.CodeType; import team.retum.jobis.domain.code.persistence.entity.CodeEntity; import team.retum.jobis.domain.recruitment.dto.response.RecruitAreaResponse; @@ -12,17 +13,16 @@ public class QueryRecruitAreaVO extends RecruitAreaResponse { @QueryProjection - public QueryRecruitAreaVO(Long id, Integer hiredCount, String majorTask, - String preferentialTreatment, List codes) { + public QueryRecruitAreaVO(Long id, Integer hiredCount, String majorTask, String preferentialTreatment, List codes) { super( id, codes.stream() .filter(code -> code.getType().equals(CodeType.JOB)) - .map(CodeEntity::getKeyword) + .map(code -> new CodeResponse(code.getCode(), code.getKeyword())) .toList(), codes.stream() .filter(code -> code.getType().equals(CodeType.TECH)) - .map(CodeEntity::getKeyword) + .map(code -> new CodeResponse(code.getCode(), code.getKeyword())) .toList(), hiredCount, majorTask, 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"} ) } ) 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