diff --git a/src/docs/asciidoc/analysis.adoc b/src/docs/asciidoc/analysis.adoc index f591d69f..1cff385e 100644 --- a/src/docs/asciidoc/analysis.adoc +++ b/src/docs/asciidoc/analysis.adoc @@ -3,7 +3,7 @@ === 전형별 지원자 수 조회 전형별 지원자들의 수를 조회할 수 있습니다. -=== 요청 형식 +==== 요청 형식 ==== Request Header include::{snippets}/analysis-controller-test/전형별_지원자수를_조회한다/request-headers.adoc[] @@ -17,7 +17,7 @@ include::{snippets}/analysis-controller-test/전형별_지원자수를_조회한 === 전형별 성적 분포 조회 1차 합격자, 2차 전형자, 최종 합격자들의 전형별 성적 분포를 조회할 수 있습니다. -=== 요청 형식 +==== 요청 형식 ==== Request Header include::{snippets}/analysis-controller-test/_1차_합격자들의_성적_분포를_조회한다/request-headers.adoc[] @@ -44,7 +44,7 @@ include::{snippets}/analysis-controller-test/최종_합격자들의_성적_분 === 전형별 성비 조회 1차 합격자, 2차 전형자, 최종 합격자들의 전형별, 지역별 성비를 조회할 수 있습니다. -=== 요청 형식 +==== 요청 형식 ==== Request Header include::{snippets}/analysis-controller-test/전형별_성비를_조회한다/request-headers.adoc[] @@ -63,7 +63,7 @@ include::{snippets}/analysis-controller-test/전형별_성비를_조회한다/ht === 전형별 출신학교 조회 1차 합격자, 2차 전형자, 최종 합격자들의 출신학교를 조회할 수 있습니다. -=== 요청 형식 +==== 요청 형식 ==== Request Header include::{snippets}/analysis-controller-test/부산_특정구_출신_지원자들의_출신학교_통계를_조회한다/request-headers.adoc[] diff --git a/src/main/java/com/bamdoliro/maru/application/analysis/QuerySchoolStatusUseCase.java b/src/main/java/com/bamdoliro/maru/application/analysis/QuerySchoolStatusUseCase.java index 7a011839..883b31d9 100644 --- a/src/main/java/com/bamdoliro/maru/application/analysis/QuerySchoolStatusUseCase.java +++ b/src/main/java/com/bamdoliro/maru/application/analysis/QuerySchoolStatusUseCase.java @@ -15,10 +15,17 @@ public class QuerySchoolStatusUseCase { private final FormRepository formRepository; public List execute(SchoolStatusRequest request) { - String keyword = request.getIsBusan() ? "부산광역시" : ""; - keyword += request.getGu() == null ? "" : (" " + request.getGu()); + if (request.getIsBusan()) { + String keyword = "부산광역시"; + keyword += request.getGu() == null ? "" : (" " + request.getGu()); - return formRepository.findSchoolByAddress(request.getStatusList(), keyword) + return formRepository.findSchoolByAddress(request.getStatusList(), keyword) + .stream() + .map(SchoolStatusResponse::new) + .toList(); + } + + return formRepository.findNotBusanSchool(request.getStatusList()) .stream() .map(SchoolStatusResponse::new) .toList(); diff --git a/src/main/java/com/bamdoliro/maru/infrastructure/persistence/form/FormRepositoryCustom.java b/src/main/java/com/bamdoliro/maru/infrastructure/persistence/form/FormRepositoryCustom.java index 672bfa7c..eb7702cb 100644 --- a/src/main/java/com/bamdoliro/maru/infrastructure/persistence/form/FormRepositoryCustom.java +++ b/src/main/java/com/bamdoliro/maru/infrastructure/persistence/form/FormRepositoryCustom.java @@ -31,4 +31,5 @@ public interface FormRepositoryCustom { List findTypeAndCountGroupByType(); List findGradeGroupByTypeAndStatus(List round); List findSchoolByAddress(List round, String keyword); + List findNotBusanSchool(List round); } \ No newline at end of file diff --git a/src/main/java/com/bamdoliro/maru/infrastructure/persistence/form/FormRepositoryImpl.java b/src/main/java/com/bamdoliro/maru/infrastructure/persistence/form/FormRepositoryImpl.java index 4111aa2e..35bee959 100644 --- a/src/main/java/com/bamdoliro/maru/infrastructure/persistence/form/FormRepositoryImpl.java +++ b/src/main/java/com/bamdoliro/maru/infrastructure/persistence/form/FormRepositoryImpl.java @@ -3,6 +3,7 @@ import com.bamdoliro.maru.domain.form.domain.Form; import com.bamdoliro.maru.domain.form.domain.type.FormStatus; import com.bamdoliro.maru.domain.form.domain.type.FormType; +import com.bamdoliro.maru.domain.form.domain.value.QSchool; import com.bamdoliro.maru.infrastructure.persistence.form.vo.*; import com.querydsl.core.types.dsl.BooleanExpression; import com.querydsl.jpa.impl.JPAQueryFactory; @@ -285,4 +286,17 @@ public List findSchoolByAddress(List round, String k .and(form.status.in(round))) .fetch(); } + + @Override + public List findNotBusanSchool(List round) { + return queryFactory + .select(new QSchoolStatusVo( + form.applicant.name, + form.education.school.name, + form.education.school.address + )) + .from(form) + .where(form.education.school.location.eq("부산광역시").not()) + .fetch(); + } } \ No newline at end of file diff --git a/src/test/java/com/bamdoliro/maru/application/analysis/QuerySchoolStatusUseCaseTest.java b/src/test/java/com/bamdoliro/maru/application/analysis/QuerySchoolStatusUseCaseTest.java index a16d134b..0b5c4adf 100644 --- a/src/test/java/com/bamdoliro/maru/application/analysis/QuerySchoolStatusUseCaseTest.java +++ b/src/test/java/com/bamdoliro/maru/application/analysis/QuerySchoolStatusUseCaseTest.java @@ -37,7 +37,7 @@ class QuerySchoolStatusUseCaseTest { new SchoolStatusVo("박이로", "마루중학교", "경기도 밤돌시 이로구 밤돌이로 1") ); List round = List.of(FormStatus.FIRST_PASSED, FormStatus.FAILED, FormStatus.PASSED); - given(formRepository.findSchoolByAddress(round, "")).willReturn(voList); + given(formRepository.findNotBusanSchool(round)).willReturn(voList); SchoolStatusRequest request = new SchoolStatusRequest(round, false, null); // when @@ -45,7 +45,7 @@ class QuerySchoolStatusUseCaseTest { // then Assertions.assertEquals(responseList.size(), voList.size()); - verify(formRepository, times(1)).findSchoolByAddress(round, ""); + verify(formRepository, times(1)).findNotBusanSchool(round); } @Test @@ -98,7 +98,7 @@ class QuerySchoolStatusUseCaseTest { new SchoolStatusVo("박이로", "마루중학교", "경기도 밤돌시 이로구 밤돌이로 1") ); List round = List.of(FormStatus.FAILED, FormStatus.PASSED); - given(formRepository.findSchoolByAddress(round, "")).willReturn(voList); + given(formRepository.findNotBusanSchool(round)).willReturn(voList); SchoolStatusRequest request = new SchoolStatusRequest(round, false, null); // when @@ -106,7 +106,7 @@ class QuerySchoolStatusUseCaseTest { // then Assertions.assertEquals(responseList.size(), voList.size()); - verify(formRepository, times(1)).findSchoolByAddress(round, ""); + verify(formRepository, times(1)).findNotBusanSchool(round); } @Test @@ -159,7 +159,7 @@ class QuerySchoolStatusUseCaseTest { new SchoolStatusVo("박이로", "마루중학교", "경기도 밤돌시 이로구 밤돌이로 1") ); List round = List.of(FormStatus.PASSED); - given(formRepository.findSchoolByAddress(round, "")).willReturn(voList); + given(formRepository.findNotBusanSchool(round)).willReturn(voList); SchoolStatusRequest request = new SchoolStatusRequest(round, false, null); // when @@ -167,7 +167,7 @@ class QuerySchoolStatusUseCaseTest { // then Assertions.assertEquals(responseList.size(), voList.size()); - verify(formRepository, times(1)).findSchoolByAddress(round, ""); + verify(formRepository, times(1)).findNotBusanSchool(round); } @Test