-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* refactor: 리쿠르팅 생성 api 수정 * refactor: 검증 로직을 도메인 서비스로 이동 * refactor: 학기 기간을 서버에서 지정하도록 수정 * refactor: 레포지토리 활용 로직을 응용 서비스로 이동 * docs: 주석 추가 * refactor: 검증 로직을 도메인 서비스로 이동 * fix: 학기 시작일과 종료일을 직접 입력할 수 있도록 수정 * remove: 학기 시작일과 종료일결정 로직 제거 * test: given 분리
- Loading branch information
1 parent
794bb85
commit f20de72
Showing
6 changed files
with
87 additions
and
99 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 2 additions & 1 deletion
3
src/main/java/com/gdschongik/gdsc/domain/recruitment/dao/RecruitmentRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,13 @@ | ||
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<Recruitment, Long> { | ||
|
||
// boolean existsByAcademicYearAndSemesterType(Integer academicYear, SemesterType semesterType); | ||
boolean existsByAcademicYearAndSemesterType(Integer academicYear, SemesterType semesterType); | ||
|
||
List<Recruitment> findByOrderBySemesterPeriodDesc(); | ||
} |
17 changes: 17 additions & 0 deletions
17
src/main/java/com/gdschongik/gdsc/domain/recruitment/domain/RecruitmentValidator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package com.gdschongik.gdsc.domain.recruitment.domain; | ||
|
||
import static com.gdschongik.gdsc.global.exception.ErrorCode.*; | ||
|
||
import com.gdschongik.gdsc.global.annotation.DomainService; | ||
import com.gdschongik.gdsc.global.exception.CustomException; | ||
|
||
@DomainService | ||
public class RecruitmentValidator { | ||
|
||
public void validateRecruitmentCreate(boolean isRecruitmentOverlap) { | ||
// 학년도와 학기가 같은 리쿠르팅이 이미 존재하는 경우 | ||
if (isRecruitmentOverlap) { | ||
throw new CustomException(RECRUITMENT_OVERLAP); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 24 additions & 45 deletions
69
.../java/com/gdschongik/gdsc/domain/recruitment/application/AdminRecruitmentServiceTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
src/test/java/com/gdschongik/gdsc/domain/recruitment/domain/RecruitmentValidatorTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package com.gdschongik.gdsc.domain.recruitment.domain; | ||
|
||
import static com.gdschongik.gdsc.global.exception.ErrorCode.*; | ||
import static org.assertj.core.api.Assertions.*; | ||
|
||
import com.gdschongik.gdsc.global.exception.CustomException; | ||
import org.junit.jupiter.api.Test; | ||
|
||
public class RecruitmentValidatorTest { | ||
|
||
RecruitmentValidator recruitmentValidator = new RecruitmentValidator(); | ||
|
||
@Test | ||
void 학년도_학기가_모두_중복되는_리쿠르팅이라면_실패한다() { | ||
// given | ||
boolean isRecruitmentOverlap = true; | ||
|
||
// when & then | ||
assertThatThrownBy(() -> recruitmentValidator.validateRecruitmentCreate(isRecruitmentOverlap)) | ||
.isInstanceOf(CustomException.class) | ||
.hasMessage(RECRUITMENT_OVERLAP.getMessage()); | ||
} | ||
} |