From 444386b8d6d8a89c675848eca41af597a0b82e54 Mon Sep 17 00:00:00 2001 From: "chosw1002@naver.com" Date: Fri, 17 May 2024 12:26:56 +0900 Subject: [PATCH 01/20] =?UTF-8?q?test:=20=EB=AA=A8=EC=A7=91=EA=B8=B0?= =?UTF-8?q?=EA=B0=84=EC=9D=B4=20=EC=A4=91=EB=B3=B5=EB=90=98=EB=8A=94=20?= =?UTF-8?q?=EC=BC=80=EC=9D=B4=EC=8A=A4=EC=97=90=20=EB=8C=80=ED=95=9C=20?= =?UTF-8?q?=EA=B2=80=EC=A6=9D=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gdsc/global/exception/ErrorCode.java | 3 +- .../AdminRecruitmentServiceTest.java | 38 +++++++++++++++++++ 2 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 src/test/java/com/gdschongik/gdsc/domain/recruitment/application/AdminRecruitmentServiceTest.java diff --git a/src/main/java/com/gdschongik/gdsc/global/exception/ErrorCode.java b/src/main/java/com/gdschongik/gdsc/global/exception/ErrorCode.java index 0a99fc558..fc61ef2f2 100644 --- a/src/main/java/com/gdschongik/gdsc/global/exception/ErrorCode.java +++ b/src/main/java/com/gdschongik/gdsc/global/exception/ErrorCode.java @@ -61,7 +61,8 @@ public enum ErrorCode { PAYMENT_NOT_VERIFIED(HttpStatus.CONFLICT, "회비 납부가 완료되지 않았습니다."), // Recruitment - DATE_PRECEDENCE_INVALID(HttpStatus.BAD_REQUEST, "종료일이 시작일과 같거나 앞설 수 없습니다."); + DATE_PRECEDENCE_INVALID(HttpStatus.BAD_REQUEST, "종료일이 시작일과 같거나 앞설 수 없습니다."), + PERIOD_DUPLICATE(HttpStatus.BAD_REQUEST, "모집 기간이 중복됩니다."); private final HttpStatus status; private final String message; diff --git a/src/test/java/com/gdschongik/gdsc/domain/recruitment/application/AdminRecruitmentServiceTest.java b/src/test/java/com/gdschongik/gdsc/domain/recruitment/application/AdminRecruitmentServiceTest.java new file mode 100644 index 000000000..3f1028a35 --- /dev/null +++ b/src/test/java/com/gdschongik/gdsc/domain/recruitment/application/AdminRecruitmentServiceTest.java @@ -0,0 +1,38 @@ +package com.gdschongik.gdsc.domain.recruitment.application; + +import static com.gdschongik.gdsc.global.common.constant.RecruitmentConstant.*; +import static com.gdschongik.gdsc.global.exception.ErrorCode.*; +import static org.assertj.core.api.Assertions.*; + +import com.gdschongik.gdsc.domain.recruitment.dao.RecruitmentRepository; +import com.gdschongik.gdsc.domain.recruitment.domain.Recruitment; +import com.gdschongik.gdsc.global.exception.CustomException; +import com.gdschongik.gdsc.integration.IntegrationTest; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; + +class AdminRecruitmentServiceTest extends IntegrationTest { + + @Autowired + private RecruitmentRepository recruitmentRepository; + + @Nested + class 모집기간_생성시 { + @Test + void 기간이_중복되는_Recruitment가_있다면_실패한다() { + // given + Recruitment recruitment = Recruitment.createRecruitment(RECRUITMENT_NAME, START_DATE, END_DATE); + recruitmentRepository.save(recruitment); + + // when & then + assertThatThrownBy(() -> { + Recruitment duplicatedRecruitment = + Recruitment.createRecruitment(RECRUITMENT_NAME, START_DATE, END_DATE); + recruitmentRepository.save(duplicatedRecruitment); + }) + .isInstanceOf(CustomException.class) + .hasMessage(PERIOD_DUPLICATE.getMessage()); + } + } +} From 157743b42fa50947b7faedcbd39972170bd038bd Mon Sep 17 00:00:00 2001 From: "chosw1002@naver.com" Date: Tue, 21 May 2024 21:02:11 +0900 Subject: [PATCH 02/20] =?UTF-8?q?test:=20=EC=84=9C=EB=B9=84=EC=8A=A4?= =?UTF-8?q?=EB=A5=BC=20=ED=85=8C=EC=8A=A4=ED=8A=B8=20=ED=95=98=EB=8F=84?= =?UTF-8?q?=EB=A1=9D=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../application/AdminRecruitmentServiceTest.java | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/src/test/java/com/gdschongik/gdsc/domain/recruitment/application/AdminRecruitmentServiceTest.java b/src/test/java/com/gdschongik/gdsc/domain/recruitment/application/AdminRecruitmentServiceTest.java index 3f1028a35..58e649235 100644 --- a/src/test/java/com/gdschongik/gdsc/domain/recruitment/application/AdminRecruitmentServiceTest.java +++ b/src/test/java/com/gdschongik/gdsc/domain/recruitment/application/AdminRecruitmentServiceTest.java @@ -4,8 +4,7 @@ import static com.gdschongik.gdsc.global.exception.ErrorCode.*; import static org.assertj.core.api.Assertions.*; -import com.gdschongik.gdsc.domain.recruitment.dao.RecruitmentRepository; -import com.gdschongik.gdsc.domain.recruitment.domain.Recruitment; +import com.gdschongik.gdsc.domain.recruitment.dto.request.RecruitmentCreateRequest; import com.gdschongik.gdsc.global.exception.CustomException; import com.gdschongik.gdsc.integration.IntegrationTest; import org.junit.jupiter.api.Nested; @@ -15,22 +14,18 @@ class AdminRecruitmentServiceTest extends IntegrationTest { @Autowired - private RecruitmentRepository recruitmentRepository; + private AdminRecruitmentService adminRecruitmentService; @Nested class 모집기간_생성시 { @Test void 기간이_중복되는_Recruitment가_있다면_실패한다() { // given - Recruitment recruitment = Recruitment.createRecruitment(RECRUITMENT_NAME, START_DATE, END_DATE); - recruitmentRepository.save(recruitment); + RecruitmentCreateRequest request = new RecruitmentCreateRequest(RECRUITMENT_NAME, START_DATE, END_DATE); + adminRecruitmentService.createRecruitment(request); // when & then - assertThatThrownBy(() -> { - Recruitment duplicatedRecruitment = - Recruitment.createRecruitment(RECRUITMENT_NAME, START_DATE, END_DATE); - recruitmentRepository.save(duplicatedRecruitment); - }) + assertThatThrownBy(() -> adminRecruitmentService.createRecruitment(request)) .isInstanceOf(CustomException.class) .hasMessage(PERIOD_DUPLICATE.getMessage()); } From 823db4cf49f0a59ec06abbb0c59ca31fa9908d64 Mon Sep 17 00:00:00 2001 From: "chosw1002@naver.com" Date: Tue, 21 May 2024 21:24:03 +0900 Subject: [PATCH 03/20] =?UTF-8?q?rename:=20ErrorCode=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/gdschongik/gdsc/global/exception/ErrorCode.java | 2 +- .../recruitment/application/AdminRecruitmentServiceTest.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/gdschongik/gdsc/global/exception/ErrorCode.java b/src/main/java/com/gdschongik/gdsc/global/exception/ErrorCode.java index fc61ef2f2..429c4e660 100644 --- a/src/main/java/com/gdschongik/gdsc/global/exception/ErrorCode.java +++ b/src/main/java/com/gdschongik/gdsc/global/exception/ErrorCode.java @@ -62,7 +62,7 @@ public enum ErrorCode { // Recruitment DATE_PRECEDENCE_INVALID(HttpStatus.BAD_REQUEST, "종료일이 시작일과 같거나 앞설 수 없습니다."), - PERIOD_DUPLICATE(HttpStatus.BAD_REQUEST, "모집 기간이 중복됩니다."); + RECRUITMENT_PERIOD_OVERLAP(HttpStatus.BAD_REQUEST, "모집 기간이 중복됩니다."); private final HttpStatus status; private final String message; diff --git a/src/test/java/com/gdschongik/gdsc/domain/recruitment/application/AdminRecruitmentServiceTest.java b/src/test/java/com/gdschongik/gdsc/domain/recruitment/application/AdminRecruitmentServiceTest.java index 58e649235..461703c3e 100644 --- a/src/test/java/com/gdschongik/gdsc/domain/recruitment/application/AdminRecruitmentServiceTest.java +++ b/src/test/java/com/gdschongik/gdsc/domain/recruitment/application/AdminRecruitmentServiceTest.java @@ -27,7 +27,7 @@ class 모집기간_생성시 { // when & then assertThatThrownBy(() -> adminRecruitmentService.createRecruitment(request)) .isInstanceOf(CustomException.class) - .hasMessage(PERIOD_DUPLICATE.getMessage()); + .hasMessage(RECRUITMENT_PERIOD_OVERLAP.getMessage()); } } } From e688ec2acca10a94498d187e38b8469209e99330 Mon Sep 17 00:00:00 2001 From: "chosw1002@naver.com" Date: Wed, 22 May 2024 11:54:21 +0900 Subject: [PATCH 04/20] style: spotless apply --- .../java/com/gdschongik/gdsc/global/exception/ErrorCode.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/gdschongik/gdsc/global/exception/ErrorCode.java b/src/main/java/com/gdschongik/gdsc/global/exception/ErrorCode.java index fca501a73..2c88fa8f5 100644 --- a/src/main/java/com/gdschongik/gdsc/global/exception/ErrorCode.java +++ b/src/main/java/com/gdschongik/gdsc/global/exception/ErrorCode.java @@ -67,7 +67,7 @@ public enum ErrorCode { DATE_PRECEDENCE_INVALID(HttpStatus.BAD_REQUEST, "종료일이 시작일과 같거나 앞설 수 없습니다."), RECRUITMENT_NOT_OPEN(HttpStatus.CONFLICT, "리크루트먼트 모집기간이 아닙니다."), RECRUITMENT_NOT_FOUND(HttpStatus.NOT_FOUND, "열려있는 리크루트먼트가 없습니다."), - RECRUITMENT_PERIOD_OVERLAP(HttpStatus.BAD_REQUEST, "모집 기간이 중복됩니다."); + RECRUITMENT_PERIOD_OVERLAP(HttpStatus.BAD_REQUEST, "모집 기간이 중복됩니다."); private final HttpStatus status; private final String message; From 11604e9257576a32990c192b0dbc254e6afd78b8 Mon Sep 17 00:00:00 2001 From: "chosw1002@naver.com" Date: Wed, 22 May 2024 15:48:35 +0900 Subject: [PATCH 05/20] =?UTF-8?q?test:=20=EB=AA=A8=EC=A7=91=20=EA=B8=B0?= =?UTF-8?q?=EA=B0=84=20=EC=A4=91=EB=B3=B5=EC=9D=84=20=EA=B2=80=EC=A6=9D?= =?UTF-8?q?=ED=95=98=EA=B8=B0=20=EC=9C=84=ED=95=9C=20=ED=85=8C=EC=8A=A4?= =?UTF-8?q?=ED=8A=B8=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../application/AdminRecruitmentServiceTest.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/test/java/com/gdschongik/gdsc/domain/recruitment/application/AdminRecruitmentServiceTest.java b/src/test/java/com/gdschongik/gdsc/domain/recruitment/application/AdminRecruitmentServiceTest.java index 461703c3e..337c20adc 100644 --- a/src/test/java/com/gdschongik/gdsc/domain/recruitment/application/AdminRecruitmentServiceTest.java +++ b/src/test/java/com/gdschongik/gdsc/domain/recruitment/application/AdminRecruitmentServiceTest.java @@ -4,6 +4,8 @@ import static com.gdschongik.gdsc.global.exception.ErrorCode.*; import static org.assertj.core.api.Assertions.*; +import com.gdschongik.gdsc.domain.recruitment.dao.RecruitmentRepository; +import com.gdschongik.gdsc.domain.recruitment.domain.Recruitment; import com.gdschongik.gdsc.domain.recruitment.dto.request.RecruitmentCreateRequest; import com.gdschongik.gdsc.global.exception.CustomException; import com.gdschongik.gdsc.integration.IntegrationTest; @@ -16,13 +18,22 @@ class AdminRecruitmentServiceTest extends IntegrationTest { @Autowired private AdminRecruitmentService adminRecruitmentService; + @Autowired + private RecruitmentRepository recruitmentRepository; + + private void createRecruitment() { + Recruitment recruitment = + Recruitment.createRecruitment(RECRUITMENT_NAME, START_DATE, END_DATE, ACADEMIC_YEAR, SEMESTER_TYPE); + recruitmentRepository.save(recruitment); + } + @Nested class 모집기간_생성시 { @Test void 기간이_중복되는_Recruitment가_있다면_실패한다() { // given + createRecruitment(); RecruitmentCreateRequest request = new RecruitmentCreateRequest(RECRUITMENT_NAME, START_DATE, END_DATE); - adminRecruitmentService.createRecruitment(request); // when & then assertThatThrownBy(() -> adminRecruitmentService.createRecruitment(request)) From 3ab5f5a01487840ef54bbf88307895abc75e263f Mon Sep 17 00:00:00 2001 From: "chosw1002@naver.com" Date: Wed, 22 May 2024 21:24:07 +0900 Subject: [PATCH 06/20] =?UTF-8?q?feat:=20Recruitment=20=EC=83=9D=EC=84=B1?= =?UTF-8?q?=20api=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/common/model/SemesterType.java | 8 ++++ .../api/AdminRecruitmentController.java | 29 ++++++++++++++ .../application/AdminRecruitmentService.java | 40 +++++++++++++++++++ .../dao/RecruitmentRepository.java | 7 +++- .../recruitment/domain/Recruitment.java | 4 ++ .../domain/recruitment/domain/vo/Period.java | 12 +++++- .../dto/request/RecruitmentCreateRequest.java | 13 ++++++ .../global/common/constant/RegexConstant.java | 1 + 8 files changed, 111 insertions(+), 3 deletions(-) create mode 100644 src/main/java/com/gdschongik/gdsc/domain/recruitment/api/AdminRecruitmentController.java create mode 100644 src/main/java/com/gdschongik/gdsc/domain/recruitment/application/AdminRecruitmentService.java create mode 100644 src/main/java/com/gdschongik/gdsc/domain/recruitment/dto/request/RecruitmentCreateRequest.java diff --git a/src/main/java/com/gdschongik/gdsc/domain/common/model/SemesterType.java b/src/main/java/com/gdschongik/gdsc/domain/common/model/SemesterType.java index d3f655560..0672c3ff5 100644 --- a/src/main/java/com/gdschongik/gdsc/domain/common/model/SemesterType.java +++ b/src/main/java/com/gdschongik/gdsc/domain/common/model/SemesterType.java @@ -1,5 +1,6 @@ package com.gdschongik.gdsc.domain.common.model; +import java.time.LocalDateTime; import lombok.AllArgsConstructor; import lombok.Getter; @@ -10,4 +11,11 @@ public enum SemesterType { SECOND("2학기"); private final String value; + + public static SemesterType from(LocalDateTime dateTime) { + if (dateTime.getMonthValue() < 7) { + return FIRST; + } + return SECOND; + } } diff --git a/src/main/java/com/gdschongik/gdsc/domain/recruitment/api/AdminRecruitmentController.java b/src/main/java/com/gdschongik/gdsc/domain/recruitment/api/AdminRecruitmentController.java new file mode 100644 index 000000000..0096969c4 --- /dev/null +++ b/src/main/java/com/gdschongik/gdsc/domain/recruitment/api/AdminRecruitmentController.java @@ -0,0 +1,29 @@ +package com.gdschongik.gdsc.domain.recruitment.api; + +import com.gdschongik.gdsc.domain.recruitment.application.AdminRecruitmentService; +import com.gdschongik.gdsc.domain.recruitment.dto.request.RecruitmentCreateRequest; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.tags.Tag; +import jakarta.validation.Valid; +import lombok.RequiredArgsConstructor; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@Tag(name = "Admin Recruitment", description = "어드민 리쿠르트먼트 관리 API입니다.") +@RestController +@RequestMapping("/admin/recruitment") +@RequiredArgsConstructor +public class AdminRecruitmentController { + + private final AdminRecruitmentService adminRecruitmentService; + + @Operation(summary = "리쿠르트먼트 생성", description = "새로운 리쿠르트먼트(모집 기간)를 생성합니다.") + @PostMapping + public ResponseEntity createRecruitment(@Valid @RequestBody RecruitmentCreateRequest request) { + adminRecruitmentService.createRecruitment(request); + return ResponseEntity.ok().build(); + } +} diff --git a/src/main/java/com/gdschongik/gdsc/domain/recruitment/application/AdminRecruitmentService.java b/src/main/java/com/gdschongik/gdsc/domain/recruitment/application/AdminRecruitmentService.java new file mode 100644 index 000000000..9b62a2bea --- /dev/null +++ b/src/main/java/com/gdschongik/gdsc/domain/recruitment/application/AdminRecruitmentService.java @@ -0,0 +1,40 @@ +package com.gdschongik.gdsc.domain.recruitment.application; + +import com.gdschongik.gdsc.domain.common.model.SemesterType; +import com.gdschongik.gdsc.domain.recruitment.dao.RecruitmentRepository; +import com.gdschongik.gdsc.domain.recruitment.domain.Recruitment; +import com.gdschongik.gdsc.domain.recruitment.dto.request.RecruitmentCreateRequest; +import java.time.LocalDateTime; +import java.util.List; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +@Service +@RequiredArgsConstructor +@Transactional(readOnly = true) +public class AdminRecruitmentService { + + private final RecruitmentRepository recruitmentRepository; + + @Transactional + public void createRecruitment(RecruitmentCreateRequest request) { + LocalDateTime startDate = request.startDate(); + int academicYear = startDate.getYear(); + SemesterType semesterType = SemesterType.from(startDate); + + validatePeriodOverlap(academicYear, semesterType, request.startDate(), request.endDate()); + + Recruitment recruitment = Recruitment.createRecruitment( + request.name(), request.startDate(), request.endDate(), academicYear, semesterType); + recruitmentRepository.save(recruitment); + } + + private void validatePeriodOverlap( + Integer academicYear, SemesterType semesterType, LocalDateTime startDate, LocalDateTime endDate) { + List recruitments = + recruitmentRepository.findAllByAcademicYearAndSemesterType(academicYear, semesterType); + + recruitments.forEach(recruitment -> recruitment.validatePeriodOverlap(startDate, endDate)); + } +} diff --git a/src/main/java/com/gdschongik/gdsc/domain/recruitment/dao/RecruitmentRepository.java b/src/main/java/com/gdschongik/gdsc/domain/recruitment/dao/RecruitmentRepository.java index ac0a587b6..dae4297d6 100644 --- a/src/main/java/com/gdschongik/gdsc/domain/recruitment/dao/RecruitmentRepository.java +++ b/src/main/java/com/gdschongik/gdsc/domain/recruitment/dao/RecruitmentRepository.java @@ -1,6 +1,11 @@ package com.gdschongik.gdsc.domain.recruitment.dao; +import com.gdschongik.gdsc.domain.common.model.SemesterType; import com.gdschongik.gdsc.domain.recruitment.domain.Recruitment; +import java.util.List; import org.springframework.data.jpa.repository.JpaRepository; -public interface RecruitmentRepository extends JpaRepository, RecruitmentCustomRepository {} +public interface RecruitmentRepository extends JpaRepository, RecruitmentCustomRepository { + + List findAllByAcademicYearAndSemesterType(Integer academicYear, SemesterType semesterType); +} diff --git a/src/main/java/com/gdschongik/gdsc/domain/recruitment/domain/Recruitment.java b/src/main/java/com/gdschongik/gdsc/domain/recruitment/domain/Recruitment.java index fd9ca147f..7d6d9f3c5 100644 --- a/src/main/java/com/gdschongik/gdsc/domain/recruitment/domain/Recruitment.java +++ b/src/main/java/com/gdschongik/gdsc/domain/recruitment/domain/Recruitment.java @@ -50,4 +50,8 @@ public static Recruitment createRecruitment( public boolean isOpen() { return this.period.isOpen(); } + + public void validatePeriodOverlap(LocalDateTime startDate, LocalDateTime endDate) { + this.period.validatePeriodOverlap(startDate, endDate); + } } diff --git a/src/main/java/com/gdschongik/gdsc/domain/recruitment/domain/vo/Period.java b/src/main/java/com/gdschongik/gdsc/domain/recruitment/domain/vo/Period.java index 568181153..80ab407b2 100644 --- a/src/main/java/com/gdschongik/gdsc/domain/recruitment/domain/vo/Period.java +++ b/src/main/java/com/gdschongik/gdsc/domain/recruitment/domain/vo/Period.java @@ -1,7 +1,8 @@ package com.gdschongik.gdsc.domain.recruitment.domain.vo; +import static com.gdschongik.gdsc.global.exception.ErrorCode.*; + import com.gdschongik.gdsc.global.exception.CustomException; -import com.gdschongik.gdsc.global.exception.ErrorCode; import jakarta.persistence.Embeddable; import java.time.LocalDateTime; import java.util.Objects; @@ -31,7 +32,7 @@ public static Period createPeriod(LocalDateTime startDate, LocalDateTime endDate private static void validatePeriod(LocalDateTime startDate, LocalDateTime endDate) { if (startDate.isAfter(endDate) || startDate.isEqual(endDate)) { - throw new CustomException(ErrorCode.DATE_PRECEDENCE_INVALID); + throw new CustomException(DATE_PRECEDENCE_INVALID); } } @@ -41,6 +42,13 @@ public boolean isOpen() { && (now.isBefore(this.endDate) || now.isEqual(startDate)); } + public void validatePeriodOverlap(LocalDateTime startDate, LocalDateTime endDate) { + if (this.endDate.isBefore(startDate) || this.startDate.isAfter(endDate)) { + return; + } + throw new CustomException(RECRUITMENT_PERIOD_OVERLAP); + } + @Override public boolean equals(Object o) { if (this == o) return true; diff --git a/src/main/java/com/gdschongik/gdsc/domain/recruitment/dto/request/RecruitmentCreateRequest.java b/src/main/java/com/gdschongik/gdsc/domain/recruitment/dto/request/RecruitmentCreateRequest.java new file mode 100644 index 000000000..20a594676 --- /dev/null +++ b/src/main/java/com/gdschongik/gdsc/domain/recruitment/dto/request/RecruitmentCreateRequest.java @@ -0,0 +1,13 @@ +package com.gdschongik.gdsc.domain.recruitment.dto.request; + +import static com.gdschongik.gdsc.global.common.constant.RegexConstant.*; + +import io.swagger.v3.oas.annotations.media.Schema; +import jakarta.validation.constraints.Future; +import jakarta.validation.constraints.NotBlank; +import java.time.LocalDateTime; + +public record RecruitmentCreateRequest( + @NotBlank @Schema(description = "이름") String name, + @Future @Schema(description = "모집기간 시작일", pattern = DATETIME) LocalDateTime startDate, + @Future @Schema(description = "모집기간 종료일", pattern = DATETIME) LocalDateTime endDate) {} diff --git a/src/main/java/com/gdschongik/gdsc/global/common/constant/RegexConstant.java b/src/main/java/com/gdschongik/gdsc/global/common/constant/RegexConstant.java index 0ca98289b..a30adf5de 100644 --- a/src/main/java/com/gdschongik/gdsc/global/common/constant/RegexConstant.java +++ b/src/main/java/com/gdschongik/gdsc/global/common/constant/RegexConstant.java @@ -8,6 +8,7 @@ public class RegexConstant { public static final String NICKNAME = "[ㄱ-ㅣ가-힣]{1,6}$"; public static final String DEPARTMENT = "^D[0-9]{3}$"; public static final String HONGIK_EMAIL = "^[^\\W&=+'-+,<>]+(\\.[^\\W&=+'-+,<>]+)*@g\\.hongik\\.ac\\.kr$"; + public static final String DATETIME = "yyyy-MM-dd'T'HH:mm:ss"; private RegexConstant() {} } From b617659a21d3a51bcbdf00c9d8e3a4221f4eb321 Mon Sep 17 00:00:00 2001 From: "chosw1002@naver.com" Date: Sun, 26 May 2024 21:01:56 +0900 Subject: [PATCH 07/20] =?UTF-8?q?docs:=20=EC=9A=A9=EC=96=B4=20=EB=B3=80?= =?UTF-8?q?=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/recruitment/api/AdminRecruitmentController.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/gdschongik/gdsc/domain/recruitment/api/AdminRecruitmentController.java b/src/main/java/com/gdschongik/gdsc/domain/recruitment/api/AdminRecruitmentController.java index 0096969c4..c243707fe 100644 --- a/src/main/java/com/gdschongik/gdsc/domain/recruitment/api/AdminRecruitmentController.java +++ b/src/main/java/com/gdschongik/gdsc/domain/recruitment/api/AdminRecruitmentController.java @@ -12,7 +12,7 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; -@Tag(name = "Admin Recruitment", description = "어드민 리쿠르트먼트 관리 API입니다.") +@Tag(name = "Admin Recruitment", description = "어드민 리쿠르팅 관리 API입니다.") @RestController @RequestMapping("/admin/recruitment") @RequiredArgsConstructor @@ -20,7 +20,7 @@ public class AdminRecruitmentController { private final AdminRecruitmentService adminRecruitmentService; - @Operation(summary = "리쿠르트먼트 생성", description = "새로운 리쿠르트먼트(모집 기간)를 생성합니다.") + @Operation(summary = "리쿠르팅 생성", description = "새로운 리쿠르팅(모집 기간)를 생성합니다.") @PostMapping public ResponseEntity createRecruitment(@Valid @RequestBody RecruitmentCreateRequest request) { adminRecruitmentService.createRecruitment(request); From 5c0ac340f229bdece7b698d976588ac136d0c538 Mon Sep 17 00:00:00 2001 From: "chosw1002@naver.com" Date: Wed, 29 May 2024 20:06:12 +0900 Subject: [PATCH 08/20] =?UTF-8?q?refactor:=20=ED=95=99=EB=85=84=EB=8F=84?= =?UTF-8?q?=EC=99=80=20=ED=95=99=EA=B8=B0=EB=A5=BC=20=ED=81=B4=EB=9D=BC?= =?UTF-8?q?=EC=9D=B4=EC=96=B8=ED=8A=B8=EB=A1=9C=EB=B6=80=ED=84=B0=20?= =?UTF-8?q?=EC=9E=85=EB=A0=A5=EB=B0=9B=EB=8F=84=EB=A1=9D=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../recruitment/dto/request/RecruitmentCreateRequest.java | 7 ++++++- .../gdsc/global/common/constant/RegexConstant.java | 1 + .../application/AdminRecruitmentServiceTest.java | 3 ++- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/gdschongik/gdsc/domain/recruitment/dto/request/RecruitmentCreateRequest.java b/src/main/java/com/gdschongik/gdsc/domain/recruitment/dto/request/RecruitmentCreateRequest.java index 20a594676..c623d063e 100644 --- a/src/main/java/com/gdschongik/gdsc/domain/recruitment/dto/request/RecruitmentCreateRequest.java +++ b/src/main/java/com/gdschongik/gdsc/domain/recruitment/dto/request/RecruitmentCreateRequest.java @@ -2,12 +2,17 @@ import static com.gdschongik.gdsc.global.common.constant.RegexConstant.*; +import com.gdschongik.gdsc.domain.common.model.SemesterType; import io.swagger.v3.oas.annotations.media.Schema; import jakarta.validation.constraints.Future; import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotNull; import java.time.LocalDateTime; public record RecruitmentCreateRequest( @NotBlank @Schema(description = "이름") String name, @Future @Schema(description = "모집기간 시작일", pattern = DATETIME) LocalDateTime startDate, - @Future @Schema(description = "모집기간 종료일", pattern = DATETIME) LocalDateTime endDate) {} + @Future @Schema(description = "모집기간 종료일", pattern = DATETIME) LocalDateTime endDate, + @NotNull(message = "학년도는 null이 될 수 없습니다.") @Schema(description = "학년도", pattern = ACADEMIC_YEAR) + Integer academicYear, + @NotNull(message = "학기는 null이 될 수 없습니다.") @Schema(description = "학기") SemesterType semesterType) {} diff --git a/src/main/java/com/gdschongik/gdsc/global/common/constant/RegexConstant.java b/src/main/java/com/gdschongik/gdsc/global/common/constant/RegexConstant.java index a30adf5de..41f726245 100644 --- a/src/main/java/com/gdschongik/gdsc/global/common/constant/RegexConstant.java +++ b/src/main/java/com/gdschongik/gdsc/global/common/constant/RegexConstant.java @@ -9,6 +9,7 @@ public class RegexConstant { public static final String DEPARTMENT = "^D[0-9]{3}$"; public static final String HONGIK_EMAIL = "^[^\\W&=+'-+,<>]+(\\.[^\\W&=+'-+,<>]+)*@g\\.hongik\\.ac\\.kr$"; public static final String DATETIME = "yyyy-MM-dd'T'HH:mm:ss"; + public static final String ACADEMIC_YEAR = "^[0-9]{4}$"; private RegexConstant() {} } diff --git a/src/test/java/com/gdschongik/gdsc/domain/recruitment/application/AdminRecruitmentServiceTest.java b/src/test/java/com/gdschongik/gdsc/domain/recruitment/application/AdminRecruitmentServiceTest.java index 337c20adc..d5f32977d 100644 --- a/src/test/java/com/gdschongik/gdsc/domain/recruitment/application/AdminRecruitmentServiceTest.java +++ b/src/test/java/com/gdschongik/gdsc/domain/recruitment/application/AdminRecruitmentServiceTest.java @@ -33,7 +33,8 @@ class 모집기간_생성시 { void 기간이_중복되는_Recruitment가_있다면_실패한다() { // given createRecruitment(); - RecruitmentCreateRequest request = new RecruitmentCreateRequest(RECRUITMENT_NAME, START_DATE, END_DATE); + RecruitmentCreateRequest request = + new RecruitmentCreateRequest(RECRUITMENT_NAME, START_DATE, END_DATE, ACADEMIC_YEAR, SEMESTER_TYPE); // when & then assertThatThrownBy(() -> adminRecruitmentService.createRecruitment(request)) From de7d0721bc14e1457bdd9ae27fc67f4b9db964c7 Mon Sep 17 00:00:00 2001 From: "chosw1002@naver.com" Date: Sat, 1 Jun 2024 21:04:00 +0900 Subject: [PATCH 09/20] =?UTF-8?q?test:=20=EB=A6=AC=EC=BF=A0=EB=A5=B4?= =?UTF-8?q?=ED=8C=85=20=EC=83=9D=EC=84=B1=20=EB=A1=9C=EC=A7=81=EC=97=90=20?= =?UTF-8?q?=EB=8C=80=ED=95=9C=20=ED=85=8C=EC=8A=A4=ED=8A=B8=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AdminRecruitmentServiceTest.java | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/src/test/java/com/gdschongik/gdsc/domain/recruitment/application/AdminRecruitmentServiceTest.java b/src/test/java/com/gdschongik/gdsc/domain/recruitment/application/AdminRecruitmentServiceTest.java index d5f32977d..61bb53322 100644 --- a/src/test/java/com/gdschongik/gdsc/domain/recruitment/application/AdminRecruitmentServiceTest.java +++ b/src/test/java/com/gdschongik/gdsc/domain/recruitment/application/AdminRecruitmentServiceTest.java @@ -4,11 +4,13 @@ import static com.gdschongik.gdsc.global.exception.ErrorCode.*; import static org.assertj.core.api.Assertions.*; +import com.gdschongik.gdsc.domain.common.model.SemesterType; import com.gdschongik.gdsc.domain.recruitment.dao.RecruitmentRepository; import com.gdschongik.gdsc.domain.recruitment.domain.Recruitment; import com.gdschongik.gdsc.domain.recruitment.dto.request.RecruitmentCreateRequest; import com.gdschongik.gdsc.global.exception.CustomException; import com.gdschongik.gdsc.integration.IntegrationTest; +import java.time.LocalDateTime; import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; @@ -41,5 +43,41 @@ class 모집기간_생성시 { .isInstanceOf(CustomException.class) .hasMessage(RECRUITMENT_PERIOD_OVERLAP.getMessage()); } + + @Test + void 모집_시작일과_종료일의_연도가_입력된_학년도와_다르다면_실패한다() { + // given + RecruitmentCreateRequest request = + new RecruitmentCreateRequest(RECRUITMENT_NAME, START_DATE, END_DATE, 2025, SEMESTER_TYPE); + + // when & then + assertThatThrownBy(() -> adminRecruitmentService.createRecruitment(request)) + .isInstanceOf(CustomException.class) + .hasMessage(RECRUITMENT_PERIOD_MISMATCH_ACADEMIC_YEAR.getMessage()); + } + + @Test + void 모집_시작일과_종료일의_학기가_입력된_학기와_다르다면_실패한다() { + // given + RecruitmentCreateRequest request = new RecruitmentCreateRequest( + RECRUITMENT_NAME, START_DATE, END_DATE, ACADEMIC_YEAR, SemesterType.SECOND); + + // when & then + assertThatThrownBy(() -> adminRecruitmentService.createRecruitment(request)) + .isInstanceOf(CustomException.class) + .hasMessage(RECRUITMENT_PERIOD_MISMATCH_SEMESTER_TYPE.getMessage()); + } + + @Test + void 모집_시작일과_종료일이_학기_시작일로부터_2주_이내에_있지_않다면_실패한다() { + // given + RecruitmentCreateRequest request = new RecruitmentCreateRequest( + RECRUITMENT_NAME, START_DATE, LocalDateTime.of(2024, 4, 10, 00, 00), ACADEMIC_YEAR, SEMESTER_TYPE); + + // when & then + assertThatThrownBy(() -> adminRecruitmentService.createRecruitment(request)) + .isInstanceOf(CustomException.class) + .hasMessage(RECRUITMENT_PERIOD_NOT_WITHIN_TWO_WEEKS.getMessage()); + } } } From d9182d4eda48a752a3a7bb818076cc5813e0b0f8 Mon Sep 17 00:00:00 2001 From: "chosw1002@naver.com" Date: Sat, 1 Jun 2024 21:05:58 +0900 Subject: [PATCH 10/20] =?UTF-8?q?feat:=20=EB=A6=AC=EC=BF=A0=EB=A5=B4?= =?UTF-8?q?=ED=8A=B8=EB=A8=BC=ED=8A=B8=20=EC=83=9D=EC=84=B1=20=EB=A1=9C?= =?UTF-8?q?=EC=A7=81=20=EA=B2=80=EC=A6=9D=20=EB=A9=94=EC=84=9C=EB=93=9C=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/common/model/SemesterType.java | 26 +++++++++- .../application/AdminRecruitmentService.java | 51 ++++++++++++++++--- .../gdsc/global/exception/ErrorCode.java | 8 ++- 3 files changed, 76 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/gdschongik/gdsc/domain/common/model/SemesterType.java b/src/main/java/com/gdschongik/gdsc/domain/common/model/SemesterType.java index 0672c3ff5..35ad4dd56 100644 --- a/src/main/java/com/gdschongik/gdsc/domain/common/model/SemesterType.java +++ b/src/main/java/com/gdschongik/gdsc/domain/common/model/SemesterType.java @@ -1,6 +1,9 @@ package com.gdschongik.gdsc.domain.common.model; +import com.gdschongik.gdsc.global.exception.CustomException; +import com.gdschongik.gdsc.global.exception.ErrorCode; import java.time.LocalDateTime; +import java.time.Month; import lombok.AllArgsConstructor; import lombok.Getter; @@ -13,9 +16,28 @@ public enum SemesterType { private final String value; public static SemesterType from(LocalDateTime dateTime) { - if (dateTime.getMonthValue() < 7) { + return getSemesterType(dateTime); + } + + private static SemesterType getSemesterType(LocalDateTime dateTime) { + int year = dateTime.getYear(); + LocalDateTime firstSemesterStartDate = LocalDateTime.of(year, 3, 1, 0, 0, 0); + LocalDateTime secondSemesterStartDate = LocalDateTime.of(year, 9, 1, 0, 0, 0); + + if (dateTime.isAfter(firstSemesterStartDate.minusWeeks(2)) && dateTime.getMonthValue() < 7) { return FIRST; } - return SECOND; + + if (dateTime.isAfter(secondSemesterStartDate.minusWeeks(2))) { + return SECOND; + } + throw new CustomException(ErrorCode.SEMESTER_TYPE_INVALID_FOR_DATE); + } + + public static Month getStartMonth(SemesterType semesterType) { + if (semesterType == FIRST) { + return Month.MARCH; + } + return Month.SEPTEMBER; } } diff --git a/src/main/java/com/gdschongik/gdsc/domain/recruitment/application/AdminRecruitmentService.java b/src/main/java/com/gdschongik/gdsc/domain/recruitment/application/AdminRecruitmentService.java index 9b62a2bea..0776fc8a6 100644 --- a/src/main/java/com/gdschongik/gdsc/domain/recruitment/application/AdminRecruitmentService.java +++ b/src/main/java/com/gdschongik/gdsc/domain/recruitment/application/AdminRecruitmentService.java @@ -1,9 +1,12 @@ package com.gdschongik.gdsc.domain.recruitment.application; +import static com.gdschongik.gdsc.global.exception.ErrorCode.*; + import com.gdschongik.gdsc.domain.common.model.SemesterType; import com.gdschongik.gdsc.domain.recruitment.dao.RecruitmentRepository; import com.gdschongik.gdsc.domain.recruitment.domain.Recruitment; import com.gdschongik.gdsc.domain.recruitment.dto.request.RecruitmentCreateRequest; +import com.gdschongik.gdsc.global.exception.CustomException; import java.time.LocalDateTime; import java.util.List; import lombok.RequiredArgsConstructor; @@ -19,15 +22,51 @@ public class AdminRecruitmentService { @Transactional public void createRecruitment(RecruitmentCreateRequest request) { - LocalDateTime startDate = request.startDate(); - int academicYear = startDate.getYear(); - SemesterType semesterType = SemesterType.from(startDate); - - validatePeriodOverlap(academicYear, semesterType, request.startDate(), request.endDate()); + validatePeriodMatchesAcademicYear(request.startDate(), request.endDate(), request.academicYear()); + validatePeriodMatchesSemesterType(request.startDate(), request.endDate(), request.semesterType()); + validatePeriodWithinTwoWeeks( + request.startDate(), request.endDate(), request.academicYear(), request.semesterType()); + validatePeriodOverlap(request.academicYear(), request.semesterType(), request.startDate(), request.endDate()); Recruitment recruitment = Recruitment.createRecruitment( - request.name(), request.startDate(), request.endDate(), academicYear, semesterType); + request.name(), request.startDate(), request.endDate(), request.academicYear(), request.semesterType()); recruitmentRepository.save(recruitment); + // todo: recruitment 모집 시작 직전에 멤버 역할 수정하는 로직 필요. + } + + private void validatePeriodMatchesAcademicYear( + LocalDateTime startDate, LocalDateTime endDate, Integer academicYear) { + if (academicYear.equals(startDate.getYear()) && academicYear.equals(endDate.getYear())) { + return; + } + + throw new CustomException(RECRUITMENT_PERIOD_MISMATCH_ACADEMIC_YEAR); + } + + private void validatePeriodMatchesSemesterType( + LocalDateTime startDate, LocalDateTime endDate, SemesterType semesterType) { + if (SemesterType.from(startDate).equals(semesterType) + && SemesterType.from(endDate).equals(semesterType)) { + return; + } + + throw new CustomException(RECRUITMENT_PERIOD_MISMATCH_SEMESTER_TYPE); + } + + private void validatePeriodWithinTwoWeeks( + LocalDateTime startDate, LocalDateTime endDate, Integer academicYear, SemesterType semesterType) { + LocalDateTime semesterStartDate = + LocalDateTime.of(academicYear, SemesterType.getStartMonth(semesterType), 1, 0, 0); + + if (semesterStartDate.minusWeeks(2).isAfter(startDate) + || semesterStartDate.plusWeeks(2).isBefore(startDate)) { + throw new CustomException(RECRUITMENT_PERIOD_NOT_WITHIN_TWO_WEEKS); + } + + if (semesterStartDate.minusWeeks(2).isAfter(endDate) + || semesterStartDate.plusWeeks(2).isBefore(endDate)) { + throw new CustomException(RECRUITMENT_PERIOD_NOT_WITHIN_TWO_WEEKS); + } } private void validatePeriodOverlap( diff --git a/src/main/java/com/gdschongik/gdsc/global/exception/ErrorCode.java b/src/main/java/com/gdschongik/gdsc/global/exception/ErrorCode.java index 2c88fa8f5..499906b6a 100644 --- a/src/main/java/com/gdschongik/gdsc/global/exception/ErrorCode.java +++ b/src/main/java/com/gdschongik/gdsc/global/exception/ErrorCode.java @@ -58,6 +58,9 @@ public enum ErrorCode { DISCORD_NICKNAME_NOTNULL(HttpStatus.INTERNAL_SERVER_ERROR, "닉네임은 빈 값이 될 수 없습니다."), DISCORD_MEMBER_NOT_FOUND(HttpStatus.NOT_FOUND, "디스코드 멤버를 찾을 수 없습니다."), + // SemesterType + SEMESTER_TYPE_INVALID_FOR_DATE(HttpStatus.CONFLICT, "해당 날짜가 포함되는 학기가 없습니다."), + // Membership PAYMENT_NOT_VERIFIED(HttpStatus.CONFLICT, "회비 납부가 완료되지 않았습니다."), MEMBERSHIP_NOT_APPLICABLE(HttpStatus.CONFLICT, "멤버십 가입을 신청할 수 없는 회원입니다."), @@ -67,7 +70,10 @@ public enum ErrorCode { DATE_PRECEDENCE_INVALID(HttpStatus.BAD_REQUEST, "종료일이 시작일과 같거나 앞설 수 없습니다."), RECRUITMENT_NOT_OPEN(HttpStatus.CONFLICT, "리크루트먼트 모집기간이 아닙니다."), RECRUITMENT_NOT_FOUND(HttpStatus.NOT_FOUND, "열려있는 리크루트먼트가 없습니다."), - RECRUITMENT_PERIOD_OVERLAP(HttpStatus.BAD_REQUEST, "모집 기간이 중복됩니다."); + RECRUITMENT_PERIOD_OVERLAP(HttpStatus.BAD_REQUEST, "모집 기간이 중복됩니다."), + RECRUITMENT_PERIOD_MISMATCH_ACADEMIC_YEAR(HttpStatus.BAD_REQUEST, "모집 시작일과 종료일의 연도가 학년도와 일치하지 않습니다."), + RECRUITMENT_PERIOD_MISMATCH_SEMESTER_TYPE(HttpStatus.BAD_REQUEST, "모집 시작일과 종료일의 입력된 학기가 일치하지 않습니다."), + RECRUITMENT_PERIOD_NOT_WITHIN_TWO_WEEKS(HttpStatus.BAD_REQUEST, "모집 시작일과 종료일이 학기 시작일로부터 2주 이내에 있지 않습니다."); private final HttpStatus status; private final String message; From 9e969aefbfc9f034a044f595706baa4ad2558630 Mon Sep 17 00:00:00 2001 From: "chosw1002@naver.com" Date: Sun, 2 Jun 2024 22:56:36 +0900 Subject: [PATCH 11/20] =?UTF-8?q?refactor:=20SemesterType=EC=9D=B4=20?= =?UTF-8?q?=ED=95=99=EA=B8=B0=20=EC=8B=9C=EC=9E=91=EC=9D=BC=EC=9D=84=20?= =?UTF-8?q?=EC=83=81=EC=88=98=EB=A1=9C=20=EA=B0=80=EC=A7=80=EB=8F=84?= =?UTF-8?q?=EB=A1=9D=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/common/model/SemesterType.java | 23 +++++++++---------- .../application/AdminRecruitmentService.java | 8 +++++-- 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/src/main/java/com/gdschongik/gdsc/domain/common/model/SemesterType.java b/src/main/java/com/gdschongik/gdsc/domain/common/model/SemesterType.java index 35ad4dd56..366d55af6 100644 --- a/src/main/java/com/gdschongik/gdsc/domain/common/model/SemesterType.java +++ b/src/main/java/com/gdschongik/gdsc/domain/common/model/SemesterType.java @@ -4,16 +4,18 @@ import com.gdschongik.gdsc.global.exception.ErrorCode; import java.time.LocalDateTime; import java.time.Month; +import java.time.MonthDay; import lombok.AllArgsConstructor; import lombok.Getter; @Getter @AllArgsConstructor public enum SemesterType { - FIRST("1학기"), - SECOND("2학기"); + FIRST("1학기", MonthDay.of(3, 1)), + SECOND("2학기", MonthDay.of(9, 1)); private final String value; + private final MonthDay startDate; public static SemesterType from(LocalDateTime dateTime) { return getSemesterType(dateTime); @@ -21,10 +23,14 @@ public static SemesterType from(LocalDateTime dateTime) { private static SemesterType getSemesterType(LocalDateTime dateTime) { int year = dateTime.getYear(); - LocalDateTime firstSemesterStartDate = LocalDateTime.of(year, 3, 1, 0, 0, 0); - LocalDateTime secondSemesterStartDate = LocalDateTime.of(year, 9, 1, 0, 0, 0); - if (dateTime.isAfter(firstSemesterStartDate.minusWeeks(2)) && dateTime.getMonthValue() < 7) { + LocalDateTime firstSemesterStartDate = + LocalDateTime.of(year, FIRST.startDate.getMonth(), FIRST.startDate.getDayOfMonth(), 0, 0); + LocalDateTime secondSemesterStartDate = + LocalDateTime.of(year, SECOND.startDate.getMonth(), SECOND.startDate.getDayOfMonth(), 0, 0); + + if (dateTime.isAfter(firstSemesterStartDate.minusWeeks(2)) + && dateTime.getMonthValue() < Month.JULY.getValue()) { return FIRST; } @@ -33,11 +39,4 @@ private static SemesterType getSemesterType(LocalDateTime dateTime) { } throw new CustomException(ErrorCode.SEMESTER_TYPE_INVALID_FOR_DATE); } - - public static Month getStartMonth(SemesterType semesterType) { - if (semesterType == FIRST) { - return Month.MARCH; - } - return Month.SEPTEMBER; - } } diff --git a/src/main/java/com/gdschongik/gdsc/domain/recruitment/application/AdminRecruitmentService.java b/src/main/java/com/gdschongik/gdsc/domain/recruitment/application/AdminRecruitmentService.java index 0776fc8a6..cb8d1457e 100644 --- a/src/main/java/com/gdschongik/gdsc/domain/recruitment/application/AdminRecruitmentService.java +++ b/src/main/java/com/gdschongik/gdsc/domain/recruitment/application/AdminRecruitmentService.java @@ -55,8 +55,12 @@ private void validatePeriodMatchesSemesterType( private void validatePeriodWithinTwoWeeks( LocalDateTime startDate, LocalDateTime endDate, Integer academicYear, SemesterType semesterType) { - LocalDateTime semesterStartDate = - LocalDateTime.of(academicYear, SemesterType.getStartMonth(semesterType), 1, 0, 0); + LocalDateTime semesterStartDate = LocalDateTime.of( + academicYear, + semesterType.getStartDate().getMonth(), + semesterType.getStartDate().getDayOfMonth(), + 0, + 0); if (semesterStartDate.minusWeeks(2).isAfter(startDate) || semesterStartDate.plusWeeks(2).isBefore(startDate)) { From afe6a55923223d69a43b54a4e988c4678d6d465f Mon Sep 17 00:00:00 2001 From: "chosw1002@naver.com" Date: Sun, 2 Jun 2024 23:00:17 +0900 Subject: [PATCH 12/20] =?UTF-8?q?style:=20=EA=B0=9C=ED=96=89=20=EC=A0=9C?= =?UTF-8?q?=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/gdschongik/gdsc/domain/common/model/SemesterType.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/com/gdschongik/gdsc/domain/common/model/SemesterType.java b/src/main/java/com/gdschongik/gdsc/domain/common/model/SemesterType.java index 366d55af6..84c62c5c5 100644 --- a/src/main/java/com/gdschongik/gdsc/domain/common/model/SemesterType.java +++ b/src/main/java/com/gdschongik/gdsc/domain/common/model/SemesterType.java @@ -23,7 +23,6 @@ public static SemesterType from(LocalDateTime dateTime) { private static SemesterType getSemesterType(LocalDateTime dateTime) { int year = dateTime.getYear(); - LocalDateTime firstSemesterStartDate = LocalDateTime.of(year, FIRST.startDate.getMonth(), FIRST.startDate.getDayOfMonth(), 0, 0); LocalDateTime secondSemesterStartDate = From 5bad8d50df5e75230fa77b33d5336efbdc50afd2 Mon Sep 17 00:00:00 2001 From: "chosw1002@naver.com" Date: Sun, 2 Jun 2024 23:03:23 +0900 Subject: [PATCH 13/20] =?UTF-8?q?refactor:=20=EB=A9=94=EC=84=9C=EB=93=9C?= =?UTF-8?q?=20=EB=B6=84=EB=A6=AC=20=EB=B3=B5=EA=B5=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/gdschongik/gdsc/domain/common/model/SemesterType.java | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/main/java/com/gdschongik/gdsc/domain/common/model/SemesterType.java b/src/main/java/com/gdschongik/gdsc/domain/common/model/SemesterType.java index 84c62c5c5..d86543cd0 100644 --- a/src/main/java/com/gdschongik/gdsc/domain/common/model/SemesterType.java +++ b/src/main/java/com/gdschongik/gdsc/domain/common/model/SemesterType.java @@ -18,10 +18,6 @@ public enum SemesterType { private final MonthDay startDate; public static SemesterType from(LocalDateTime dateTime) { - return getSemesterType(dateTime); - } - - private static SemesterType getSemesterType(LocalDateTime dateTime) { int year = dateTime.getYear(); LocalDateTime firstSemesterStartDate = LocalDateTime.of(year, FIRST.startDate.getMonth(), FIRST.startDate.getDayOfMonth(), 0, 0); From 2c9d15e9111d4c4e72fda67d99307fd1019543cd Mon Sep 17 00:00:00 2001 From: "chosw1002@naver.com" Date: Sun, 2 Jun 2024 23:17:44 +0900 Subject: [PATCH 14/20] =?UTF-8?q?feat:=20=EC=8B=9C=EA=B0=84=EA=B3=BC=20?= =?UTF-8?q?=EA=B8=B0=EA=B0=84=EC=97=90=20=EB=8C=80=ED=95=9C=20=EC=83=81?= =?UTF-8?q?=EC=88=98=20=ED=81=B4=EB=9E=98=EC=8A=A4=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gdsc/domain/common/model/SemesterType.java | 8 ++++---- .../application/AdminRecruitmentService.java | 9 +++++---- .../global/common/constant/TemporalConstant.java | 12 ++++++++++++ 3 files changed, 21 insertions(+), 8 deletions(-) create mode 100644 src/main/java/com/gdschongik/gdsc/global/common/constant/TemporalConstant.java diff --git a/src/main/java/com/gdschongik/gdsc/domain/common/model/SemesterType.java b/src/main/java/com/gdschongik/gdsc/domain/common/model/SemesterType.java index d86543cd0..4ccc70ef1 100644 --- a/src/main/java/com/gdschongik/gdsc/domain/common/model/SemesterType.java +++ b/src/main/java/com/gdschongik/gdsc/domain/common/model/SemesterType.java @@ -1,9 +1,10 @@ package com.gdschongik.gdsc.domain.common.model; +import static com.gdschongik.gdsc.global.common.constant.TemporalConstant.*; + import com.gdschongik.gdsc.global.exception.CustomException; import com.gdschongik.gdsc.global.exception.ErrorCode; import java.time.LocalDateTime; -import java.time.Month; import java.time.MonthDay; import lombok.AllArgsConstructor; import lombok.Getter; @@ -24,12 +25,11 @@ public static SemesterType from(LocalDateTime dateTime) { LocalDateTime secondSemesterStartDate = LocalDateTime.of(year, SECOND.startDate.getMonth(), SECOND.startDate.getDayOfMonth(), 0, 0); - if (dateTime.isAfter(firstSemesterStartDate.minusWeeks(2)) - && dateTime.getMonthValue() < Month.JULY.getValue()) { + if (dateTime.isAfter(firstSemesterStartDate.minusWeeks(TWO_WEEKS)) && dateTime.getMonthValue() < JULY) { return FIRST; } - if (dateTime.isAfter(secondSemesterStartDate.minusWeeks(2))) { + if (dateTime.isAfter(secondSemesterStartDate.minusWeeks(TWO_WEEKS))) { return SECOND; } throw new CustomException(ErrorCode.SEMESTER_TYPE_INVALID_FOR_DATE); diff --git a/src/main/java/com/gdschongik/gdsc/domain/recruitment/application/AdminRecruitmentService.java b/src/main/java/com/gdschongik/gdsc/domain/recruitment/application/AdminRecruitmentService.java index cb8d1457e..7f74b0155 100644 --- a/src/main/java/com/gdschongik/gdsc/domain/recruitment/application/AdminRecruitmentService.java +++ b/src/main/java/com/gdschongik/gdsc/domain/recruitment/application/AdminRecruitmentService.java @@ -1,5 +1,6 @@ package com.gdschongik.gdsc.domain.recruitment.application; +import static com.gdschongik.gdsc.global.common.constant.TemporalConstant.*; import static com.gdschongik.gdsc.global.exception.ErrorCode.*; import com.gdschongik.gdsc.domain.common.model.SemesterType; @@ -62,13 +63,13 @@ private void validatePeriodWithinTwoWeeks( 0, 0); - if (semesterStartDate.minusWeeks(2).isAfter(startDate) - || semesterStartDate.plusWeeks(2).isBefore(startDate)) { + if (semesterStartDate.minusWeeks(TWO_WEEKS).isAfter(startDate) + || semesterStartDate.plusWeeks(TWO_WEEKS).isBefore(startDate)) { throw new CustomException(RECRUITMENT_PERIOD_NOT_WITHIN_TWO_WEEKS); } - if (semesterStartDate.minusWeeks(2).isAfter(endDate) - || semesterStartDate.plusWeeks(2).isBefore(endDate)) { + if (semesterStartDate.minusWeeks(TWO_WEEKS).isAfter(endDate) + || semesterStartDate.plusWeeks(TWO_WEEKS).isBefore(endDate)) { throw new CustomException(RECRUITMENT_PERIOD_NOT_WITHIN_TWO_WEEKS); } } diff --git a/src/main/java/com/gdschongik/gdsc/global/common/constant/TemporalConstant.java b/src/main/java/com/gdschongik/gdsc/global/common/constant/TemporalConstant.java new file mode 100644 index 000000000..a1ba4c182 --- /dev/null +++ b/src/main/java/com/gdschongik/gdsc/global/common/constant/TemporalConstant.java @@ -0,0 +1,12 @@ +package com.gdschongik.gdsc.global.common.constant; + +public class TemporalConstant { + + private TemporalConstant() {} + + // 월 상수 + public static final int JULY = 7; + + // 주 상수 + public static final int TWO_WEEKS = 2; +} From c6f6d3a67f84e476d0bc2c82fa088c9f2407e5fe Mon Sep 17 00:00:00 2001 From: "chosw1002@naver.com" Date: Mon, 3 Jun 2024 14:17:31 +0900 Subject: [PATCH 15/20] =?UTF-8?q?refactor:=20=ED=95=99=EA=B8=B0=20?= =?UTF-8?q?=ED=83=80=EC=9E=85=20=EB=A7=A4=ED=95=91=20=EB=A1=9C=EC=A7=81?= =?UTF-8?q?=EC=9D=84=20=EB=A6=AC=EC=BF=A0=EB=A5=B4=ED=8C=85=20=EC=84=9C?= =?UTF-8?q?=EB=B9=84=EC=8A=A4=EB=A1=9C=20=EC=9D=B4=EB=8F=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/common/model/SemesterType.java | 22 ---------------- .../application/AdminRecruitmentService.java | 26 +++++++++++++++++-- 2 files changed, 24 insertions(+), 24 deletions(-) diff --git a/src/main/java/com/gdschongik/gdsc/domain/common/model/SemesterType.java b/src/main/java/com/gdschongik/gdsc/domain/common/model/SemesterType.java index 4ccc70ef1..dace965f4 100644 --- a/src/main/java/com/gdschongik/gdsc/domain/common/model/SemesterType.java +++ b/src/main/java/com/gdschongik/gdsc/domain/common/model/SemesterType.java @@ -1,10 +1,5 @@ package com.gdschongik.gdsc.domain.common.model; -import static com.gdschongik.gdsc.global.common.constant.TemporalConstant.*; - -import com.gdschongik.gdsc.global.exception.CustomException; -import com.gdschongik.gdsc.global.exception.ErrorCode; -import java.time.LocalDateTime; import java.time.MonthDay; import lombok.AllArgsConstructor; import lombok.Getter; @@ -17,21 +12,4 @@ public enum SemesterType { private final String value; private final MonthDay startDate; - - public static SemesterType from(LocalDateTime dateTime) { - int year = dateTime.getYear(); - LocalDateTime firstSemesterStartDate = - LocalDateTime.of(year, FIRST.startDate.getMonth(), FIRST.startDate.getDayOfMonth(), 0, 0); - LocalDateTime secondSemesterStartDate = - LocalDateTime.of(year, SECOND.startDate.getMonth(), SECOND.startDate.getDayOfMonth(), 0, 0); - - if (dateTime.isAfter(firstSemesterStartDate.minusWeeks(TWO_WEEKS)) && dateTime.getMonthValue() < JULY) { - return FIRST; - } - - if (dateTime.isAfter(secondSemesterStartDate.minusWeeks(TWO_WEEKS))) { - return SECOND; - } - throw new CustomException(ErrorCode.SEMESTER_TYPE_INVALID_FOR_DATE); - } } diff --git a/src/main/java/com/gdschongik/gdsc/domain/recruitment/application/AdminRecruitmentService.java b/src/main/java/com/gdschongik/gdsc/domain/recruitment/application/AdminRecruitmentService.java index 7f74b0155..69758b4db 100644 --- a/src/main/java/com/gdschongik/gdsc/domain/recruitment/application/AdminRecruitmentService.java +++ b/src/main/java/com/gdschongik/gdsc/domain/recruitment/application/AdminRecruitmentService.java @@ -1,5 +1,6 @@ package com.gdschongik.gdsc.domain.recruitment.application; +import static com.gdschongik.gdsc.domain.common.model.SemesterType.*; import static com.gdschongik.gdsc.global.common.constant.TemporalConstant.*; import static com.gdschongik.gdsc.global.exception.ErrorCode.*; @@ -46,14 +47,35 @@ private void validatePeriodMatchesAcademicYear( private void validatePeriodMatchesSemesterType( LocalDateTime startDate, LocalDateTime endDate, SemesterType semesterType) { - if (SemesterType.from(startDate).equals(semesterType) - && SemesterType.from(endDate).equals(semesterType)) { + if (getSemesterTypeByStartDateOrEndDate(startDate).equals(semesterType) + && getSemesterTypeByStartDateOrEndDate(endDate).equals(semesterType)) { return; } throw new CustomException(RECRUITMENT_PERIOD_MISMATCH_SEMESTER_TYPE); } + private SemesterType getSemesterTypeByStartDateOrEndDate(LocalDateTime dateTime) { + int year = dateTime.getYear(); + LocalDateTime firstSemesterStartDate = LocalDateTime.of( + year, FIRST.getStartDate().getMonth(), FIRST.getStartDate().getDayOfMonth(), 0, 0); + LocalDateTime secondSemesterStartDate = LocalDateTime.of( + year, SECOND.getStartDate().getMonth(), SECOND.getStartDate().getDayOfMonth(), 0, 0); + + /* + 개강일 기준으로 2주 전까지는 같은 학기로 간주한다. + */ + if (dateTime.isAfter(firstSemesterStartDate.minusWeeks(TWO_WEEKS)) && dateTime.getMonthValue() < JULY) { + return FIRST; + } + + if (dateTime.isAfter(secondSemesterStartDate.minusWeeks(TWO_WEEKS))) { + return SECOND; + } + + throw new CustomException(SEMESTER_TYPE_INVALID_FOR_DATE); + } + private void validatePeriodWithinTwoWeeks( LocalDateTime startDate, LocalDateTime endDate, Integer academicYear, SemesterType semesterType) { LocalDateTime semesterStartDate = LocalDateTime.of( From 88d0290985c2ae789ce1757c0221d17ec3c7713a Mon Sep 17 00:00:00 2001 From: "chosw1002@naver.com" Date: Mon, 3 Jun 2024 14:32:12 +0900 Subject: [PATCH 16/20] =?UTF-8?q?rename:=20ErrorCode=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../recruitment/application/AdminRecruitmentService.java | 2 +- .../java/com/gdschongik/gdsc/global/exception/ErrorCode.java | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/gdschongik/gdsc/domain/recruitment/application/AdminRecruitmentService.java b/src/main/java/com/gdschongik/gdsc/domain/recruitment/application/AdminRecruitmentService.java index 69758b4db..a6adc3316 100644 --- a/src/main/java/com/gdschongik/gdsc/domain/recruitment/application/AdminRecruitmentService.java +++ b/src/main/java/com/gdschongik/gdsc/domain/recruitment/application/AdminRecruitmentService.java @@ -73,7 +73,7 @@ private SemesterType getSemesterTypeByStartDateOrEndDate(LocalDateTime dateTime) return SECOND; } - throw new CustomException(SEMESTER_TYPE_INVALID_FOR_DATE); + throw new CustomException(RECRUITMENT_PERIOD_SEMESTER_TYPE_UNMAPPED); } private void validatePeriodWithinTwoWeeks( diff --git a/src/main/java/com/gdschongik/gdsc/global/exception/ErrorCode.java b/src/main/java/com/gdschongik/gdsc/global/exception/ErrorCode.java index 499906b6a..b8a7e79ef 100644 --- a/src/main/java/com/gdschongik/gdsc/global/exception/ErrorCode.java +++ b/src/main/java/com/gdschongik/gdsc/global/exception/ErrorCode.java @@ -58,9 +58,6 @@ public enum ErrorCode { DISCORD_NICKNAME_NOTNULL(HttpStatus.INTERNAL_SERVER_ERROR, "닉네임은 빈 값이 될 수 없습니다."), DISCORD_MEMBER_NOT_FOUND(HttpStatus.NOT_FOUND, "디스코드 멤버를 찾을 수 없습니다."), - // SemesterType - SEMESTER_TYPE_INVALID_FOR_DATE(HttpStatus.CONFLICT, "해당 날짜가 포함되는 학기가 없습니다."), - // Membership PAYMENT_NOT_VERIFIED(HttpStatus.CONFLICT, "회비 납부가 완료되지 않았습니다."), MEMBERSHIP_NOT_APPLICABLE(HttpStatus.CONFLICT, "멤버십 가입을 신청할 수 없는 회원입니다."), @@ -73,6 +70,7 @@ public enum ErrorCode { RECRUITMENT_PERIOD_OVERLAP(HttpStatus.BAD_REQUEST, "모집 기간이 중복됩니다."), RECRUITMENT_PERIOD_MISMATCH_ACADEMIC_YEAR(HttpStatus.BAD_REQUEST, "모집 시작일과 종료일의 연도가 학년도와 일치하지 않습니다."), RECRUITMENT_PERIOD_MISMATCH_SEMESTER_TYPE(HttpStatus.BAD_REQUEST, "모집 시작일과 종료일의 입력된 학기가 일치하지 않습니다."), + RECRUITMENT_PERIOD_SEMESTER_TYPE_UNMAPPED(HttpStatus.CONFLICT, "모집 시작일과 종료일이 매핑되는 학기가 없습니다."), RECRUITMENT_PERIOD_NOT_WITHIN_TWO_WEEKS(HttpStatus.BAD_REQUEST, "모집 시작일과 종료일이 학기 시작일로부터 2주 이내에 있지 않습니다."); private final HttpStatus status; From 4d6daa65f9a20f7b11b6dca30e3f011e0bbab7c0 Mon Sep 17 00:00:00 2001 From: "chosw1002@naver.com" Date: Tue, 4 Jun 2024 10:30:06 +0900 Subject: [PATCH 17/20] =?UTF-8?q?fix:=20api=20=EA=B2=BD=EB=A1=9C=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gdsc/domain/recruitment/api/AdminRecruitmentController.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/gdschongik/gdsc/domain/recruitment/api/AdminRecruitmentController.java b/src/main/java/com/gdschongik/gdsc/domain/recruitment/api/AdminRecruitmentController.java index c243707fe..6a63c7038 100644 --- a/src/main/java/com/gdschongik/gdsc/domain/recruitment/api/AdminRecruitmentController.java +++ b/src/main/java/com/gdschongik/gdsc/domain/recruitment/api/AdminRecruitmentController.java @@ -14,7 +14,7 @@ @Tag(name = "Admin Recruitment", description = "어드민 리쿠르팅 관리 API입니다.") @RestController -@RequestMapping("/admin/recruitment") +@RequestMapping("/admin/recruitments") @RequiredArgsConstructor public class AdminRecruitmentController { From 1b6e87d2530cffa8dda9c8ea5528236029ce6a55 Mon Sep 17 00:00:00 2001 From: "chosw1002@naver.com" Date: Tue, 4 Jun 2024 10:30:32 +0900 Subject: [PATCH 18/20] =?UTF-8?q?rename:=20=EC=83=81=EC=88=98=20=EC=9D=B4?= =?UTF-8?q?=EB=A6=84=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../application/AdminRecruitmentService.java | 12 ++++++------ .../global/common/constant/TemporalConstant.java | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/gdschongik/gdsc/domain/recruitment/application/AdminRecruitmentService.java b/src/main/java/com/gdschongik/gdsc/domain/recruitment/application/AdminRecruitmentService.java index a6adc3316..242151add 100644 --- a/src/main/java/com/gdschongik/gdsc/domain/recruitment/application/AdminRecruitmentService.java +++ b/src/main/java/com/gdschongik/gdsc/domain/recruitment/application/AdminRecruitmentService.java @@ -65,11 +65,11 @@ private SemesterType getSemesterTypeByStartDateOrEndDate(LocalDateTime dateTime) /* 개강일 기준으로 2주 전까지는 같은 학기로 간주한다. */ - if (dateTime.isAfter(firstSemesterStartDate.minusWeeks(TWO_WEEKS)) && dateTime.getMonthValue() < JULY) { + if (dateTime.isAfter(firstSemesterStartDate.minusWeeks(PRE_SEMESTER_TERM)) && dateTime.getMonthValue() < JULY) { return FIRST; } - if (dateTime.isAfter(secondSemesterStartDate.minusWeeks(TWO_WEEKS))) { + if (dateTime.isAfter(secondSemesterStartDate.minusWeeks(PRE_SEMESTER_TERM))) { return SECOND; } @@ -85,13 +85,13 @@ private void validatePeriodWithinTwoWeeks( 0, 0); - if (semesterStartDate.minusWeeks(TWO_WEEKS).isAfter(startDate) - || semesterStartDate.plusWeeks(TWO_WEEKS).isBefore(startDate)) { + if (semesterStartDate.minusWeeks(PRE_SEMESTER_TERM).isAfter(startDate) + || semesterStartDate.plusWeeks(PRE_SEMESTER_TERM).isBefore(startDate)) { throw new CustomException(RECRUITMENT_PERIOD_NOT_WITHIN_TWO_WEEKS); } - if (semesterStartDate.minusWeeks(TWO_WEEKS).isAfter(endDate) - || semesterStartDate.plusWeeks(TWO_WEEKS).isBefore(endDate)) { + if (semesterStartDate.minusWeeks(PRE_SEMESTER_TERM).isAfter(endDate) + || semesterStartDate.plusWeeks(PRE_SEMESTER_TERM).isBefore(endDate)) { throw new CustomException(RECRUITMENT_PERIOD_NOT_WITHIN_TWO_WEEKS); } } diff --git a/src/main/java/com/gdschongik/gdsc/global/common/constant/TemporalConstant.java b/src/main/java/com/gdschongik/gdsc/global/common/constant/TemporalConstant.java index a1ba4c182..2d45c2448 100644 --- a/src/main/java/com/gdschongik/gdsc/global/common/constant/TemporalConstant.java +++ b/src/main/java/com/gdschongik/gdsc/global/common/constant/TemporalConstant.java @@ -7,6 +7,6 @@ private TemporalConstant() {} // 월 상수 public static final int JULY = 7; - // 주 상수 - public static final int TWO_WEEKS = 2; + // 학기 준비 기간 + public static final int PRE_SEMESTER_TERM = 2; } From 4aa1ea56639c208d4a0acaf4c04ec09ca7efb644 Mon Sep 17 00:00:00 2001 From: "chosw1002@naver.com" Date: Tue, 4 Jun 2024 22:12:56 +0900 Subject: [PATCH 19/20] =?UTF-8?q?refactor:=20=EC=83=81=EC=88=98=EB=A5=BC?= =?UTF-8?q?=20java.time.Month=EB=A1=9C=20=EB=8C=80=EC=B2=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../recruitment/application/AdminRecruitmentService.java | 4 +++- .../gdsc/global/common/constant/TemporalConstant.java | 5 +---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/gdschongik/gdsc/domain/recruitment/application/AdminRecruitmentService.java b/src/main/java/com/gdschongik/gdsc/domain/recruitment/application/AdminRecruitmentService.java index 242151add..e5fe002a5 100644 --- a/src/main/java/com/gdschongik/gdsc/domain/recruitment/application/AdminRecruitmentService.java +++ b/src/main/java/com/gdschongik/gdsc/domain/recruitment/application/AdminRecruitmentService.java @@ -10,6 +10,7 @@ import com.gdschongik.gdsc.domain.recruitment.dto.request.RecruitmentCreateRequest; import com.gdschongik.gdsc.global.exception.CustomException; import java.time.LocalDateTime; +import java.time.Month; import java.util.List; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; @@ -65,7 +66,8 @@ private SemesterType getSemesterTypeByStartDateOrEndDate(LocalDateTime dateTime) /* 개강일 기준으로 2주 전까지는 같은 학기로 간주한다. */ - if (dateTime.isAfter(firstSemesterStartDate.minusWeeks(PRE_SEMESTER_TERM)) && dateTime.getMonthValue() < JULY) { + if (dateTime.isAfter(firstSemesterStartDate.minusWeeks(PRE_SEMESTER_TERM)) + && dateTime.getMonthValue() < Month.JULY.getValue()) { return FIRST; } diff --git a/src/main/java/com/gdschongik/gdsc/global/common/constant/TemporalConstant.java b/src/main/java/com/gdschongik/gdsc/global/common/constant/TemporalConstant.java index 2d45c2448..5531ce26a 100644 --- a/src/main/java/com/gdschongik/gdsc/global/common/constant/TemporalConstant.java +++ b/src/main/java/com/gdschongik/gdsc/global/common/constant/TemporalConstant.java @@ -4,9 +4,6 @@ public class TemporalConstant { private TemporalConstant() {} - // 월 상수 - public static final int JULY = 7; - - // 학기 준비 기간 + // 학기 준비 기간(주 단위) public static final int PRE_SEMESTER_TERM = 2; } From 862cd8003dabd89b097cb75f8f9e9e6e2482360e Mon Sep 17 00:00:00 2001 From: "chosw1002@naver.com" Date: Tue, 4 Jun 2024 22:13:25 +0900 Subject: [PATCH 20/20] =?UTF-8?q?fix:=20ErrorCode=20=EB=A9=94=EC=8B=9C?= =?UTF-8?q?=EC=A7=80=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/gdschongik/gdsc/global/exception/ErrorCode.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/gdschongik/gdsc/global/exception/ErrorCode.java b/src/main/java/com/gdschongik/gdsc/global/exception/ErrorCode.java index b8a7e79ef..3cffb1460 100644 --- a/src/main/java/com/gdschongik/gdsc/global/exception/ErrorCode.java +++ b/src/main/java/com/gdschongik/gdsc/global/exception/ErrorCode.java @@ -65,8 +65,8 @@ public enum ErrorCode { // Recruitment DATE_PRECEDENCE_INVALID(HttpStatus.BAD_REQUEST, "종료일이 시작일과 같거나 앞설 수 없습니다."), - RECRUITMENT_NOT_OPEN(HttpStatus.CONFLICT, "리크루트먼트 모집기간이 아닙니다."), - RECRUITMENT_NOT_FOUND(HttpStatus.NOT_FOUND, "열려있는 리크루트먼트가 없습니다."), + RECRUITMENT_NOT_OPEN(HttpStatus.CONFLICT, "리크루팅 모집기간이 아닙니다."), + RECRUITMENT_NOT_FOUND(HttpStatus.NOT_FOUND, "열려있는 리크루팅이 없습니다."), RECRUITMENT_PERIOD_OVERLAP(HttpStatus.BAD_REQUEST, "모집 기간이 중복됩니다."), RECRUITMENT_PERIOD_MISMATCH_ACADEMIC_YEAR(HttpStatus.BAD_REQUEST, "모집 시작일과 종료일의 연도가 학년도와 일치하지 않습니다."), RECRUITMENT_PERIOD_MISMATCH_SEMESTER_TYPE(HttpStatus.BAD_REQUEST, "모집 시작일과 종료일의 입력된 학기가 일치하지 않습니다."),