generated from Bamdoliro/repository-generator
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
[새기능] 어드민 분석 기능
- Loading branch information
Showing
36 changed files
with
1,167 additions
and
40 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
== 분석 Analysis | ||
|
||
=== 전형별 지원자 수 조회 | ||
전형별 지원자들의 수를 조회할 수 있습니다. | ||
|
||
=== 요청 형식 | ||
|
||
==== Request Header | ||
include::{snippets}/analysis-controller-test/전형별_지원자수를_조회한다/request-headers.adoc[] | ||
|
||
==== 요청 | ||
include::{snippets}/analysis-controller-test/전형별_지원자수를_조회한다/http-request.adoc[] | ||
|
||
==== 응답 | ||
include::{snippets}/analysis-controller-test/전형별_지원자수를_조회한다/http-response.adoc[] | ||
|
||
=== 전형별 성적 분포 조회 | ||
1차 합격자, 2차 전형자, 최종 합격자들의 전형별 성적 분포를 조회할 수 있습니다. | ||
|
||
=== 요청 형식 | ||
|
||
==== Request Header | ||
include::{snippets}/analysis-controller-test/_1차_합격자들의_성적_분포를_조회한다/request-headers.adoc[] | ||
|
||
==== Query Parameter | ||
include::{snippets}/analysis-controller-test/_1차_합격자들의_성적_분포를_조회한다/query-parameters.adoc[] | ||
|
||
==== 요청 | ||
|
||
===== 1차 합격자 | ||
include::{snippets}/analysis-controller-test/_1차_합격자들의_성적_분포를_조회한다/http-request.adoc[] | ||
|
||
===== 2차 전형자 | ||
include::{snippets}/analysis-controller-test/_2차_전형자들의_성적_분포를_조회한다/http-request.adoc[] | ||
|
||
===== 최종 합격자 | ||
include::{snippets}/analysis-controller-test/최종_합격자들의_성적_분포를_조회한다/http-request.adoc[] | ||
|
||
==== 응답 | ||
|
||
===== 정상 응답 | ||
include::{snippets}/analysis-controller-test/최종_합격자들의_성적_분포를_조회한다/http-response.adoc[] | ||
|
||
=== 전형별 성비 조회 | ||
1차 합격자, 2차 전형자, 최종 합격자들의 전형별, 지역별 성비를 조회할 수 있습니다. | ||
|
||
=== 요청 형식 | ||
|
||
==== Request Header | ||
include::{snippets}/analysis-controller-test/전형별_성비를_조회한다/request-headers.adoc[] | ||
|
||
==== Query Parameter | ||
include::{snippets}/analysis-controller-test/전형별_성비를_조회한다/query-parameters.adoc[] | ||
|
||
==== 요청 | ||
include::{snippets}/analysis-controller-test/전형별_성비를_조회한다/http-request.adoc[] | ||
|
||
==== 응답 | ||
|
||
===== 정상 응답 | ||
include::{snippets}/analysis-controller-test/전형별_성비를_조회한다/http-response.adoc[] | ||
|
||
=== 전형별 출신학교 조회 | ||
1차 합격자, 2차 전형자, 최종 합격자들의 출신학교를 조회할 수 있습니다. | ||
|
||
=== 요청 형식 | ||
|
||
==== Request Header | ||
include::{snippets}/analysis-controller-test/부산_특정구_출신_지원자들의_출신학교_통계를_조회한다/request-headers.adoc[] | ||
|
||
==== Query Parameter | ||
include::{snippets}/analysis-controller-test/부산_특정구_출신_지원자들의_출신학교_통계를_조회한다/query-parameters.adoc[] | ||
|
||
==== 요청 | ||
===== 부산 특정구 출신 | ||
include::{snippets}/analysis-controller-test/부산_특정구_출신_지원자들의_출신학교_통계를_조회한다/http-request.adoc[] | ||
|
||
==== 부산 출신 | ||
include::{snippets}/analysis-controller-test/부산_출신_지원자들의_출신학교_통계를_조회한다/http-request.adoc[] | ||
|
||
==== 타지역 출신 | ||
include::{snippets}/analysis-controller-test/타지역_출신_지원자들의_출신학교_통계를_조회한다/http-request.adoc[] | ||
|
||
==== 응답 | ||
==== 부산 특정구 출신 정상 응답 | ||
include::{snippets}/analysis-controller-test/부산_특정구_출신_지원자들의_출신학교_통계를_조회한다/http-response.adoc[] | ||
|
||
==== 부산 출신 정상 응답 | ||
include::{snippets}/analysis-controller-test/부산_출신_지원자들의_출신학교_통계를_조회한다/http-response.adoc[] | ||
|
||
==== 타지역 출신 정상 응답 | ||
include::{snippets}/analysis-controller-test/타지역_출신_지원자들의_출신학교_통계를_조회한다/http-response.adoc[] |
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 |
---|---|---|
|
@@ -27,4 +27,6 @@ include::fair.adoc[] | |
|
||
include::message.adoc[] | ||
|
||
include::analysis.adoc[] | ||
|
||
include::enum.adoc[] |
76 changes: 76 additions & 0 deletions
76
src/main/java/com/bamdoliro/maru/application/analysis/QueryGenderRatioUseCase.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,76 @@ | ||
package com.bamdoliro.maru.application.analysis; | ||
|
||
import com.bamdoliro.maru.domain.form.domain.Form; | ||
import com.bamdoliro.maru.domain.form.domain.type.FormType; | ||
import com.bamdoliro.maru.domain.form.domain.type.Gender; | ||
import com.bamdoliro.maru.infrastructure.persistence.form.FormRepository; | ||
import com.bamdoliro.maru.presentation.analysis.dto.request.GenderRatioRequest; | ||
import com.bamdoliro.maru.presentation.analysis.dto.response.GenderRatioResponse; | ||
import com.bamdoliro.maru.shared.annotation.UseCase; | ||
import lombok.RequiredArgsConstructor; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.stream.Collectors; | ||
|
||
@RequiredArgsConstructor | ||
@UseCase | ||
public class QueryGenderRatioUseCase { | ||
private final FormRepository formRepository; | ||
|
||
public List<GenderRatioResponse> execute(GenderRatioRequest request) { | ||
FormType.Category mainCategory = request.getMainCategory(); | ||
List<GenderRatioResponse> result = new ArrayList<>(); | ||
List<FormType.Category> subCategories = new ArrayList<>(); | ||
|
||
if (mainCategory.equals(FormType.Category.REGULAR)) | ||
subCategories.add(FormType.Category.REGULAR); | ||
else if (mainCategory.equals(FormType.Category.SPECIAL)) | ||
subCategories.addAll(List.of( | ||
FormType.Category.MEISTER_TALENT, | ||
FormType.Category.SOCIAL_INTEGRATION)); | ||
else if (mainCategory.equals(FormType.Category.SUPERNUMERARY)) | ||
subCategories.addAll(List.of( | ||
FormType.Category.NATIONAL_VETERANS_EDUCATION, | ||
FormType.Category.SPECIAL_ADMISSION)); | ||
|
||
Map<FormType.Category, List<Form>> formLists = subCategories.stream() | ||
.collect(Collectors.toMap( | ||
category -> category, | ||
category -> formRepository.findByCategory(category).stream() | ||
.filter(form -> request.getStatusList().contains(form.getStatus())) | ||
.collect(Collectors.toList()) | ||
)); | ||
|
||
for(Map.Entry<FormType.Category, List<Form>> entry : formLists.entrySet()) { | ||
FormType.Category category = entry.getKey(); | ||
List<Form> formList = entry.getValue(); | ||
|
||
long busanMale = formList.stream().filter(this::isBusan).filter(this::isMale).count(); | ||
long busanFemale = formList.stream().filter(this::isBusan).filter(this::isFemale).count(); | ||
long otherLocationMale = formList.stream().filter(this::isNotBusan).filter(this::isMale).count(); | ||
long otherLocationFemale = formList.stream().filter(this::isNotBusan).filter(this::isFemale).count(); | ||
|
||
result.add(new GenderRatioResponse(category, busanMale, busanFemale, otherLocationMale, otherLocationFemale)); | ||
} | ||
|
||
return result; | ||
} | ||
|
||
private boolean isBusan(Form form) { | ||
return form.getEducation().getSchool().isBusan(); | ||
} | ||
|
||
private boolean isNotBusan(Form form) { | ||
return !isBusan(form); | ||
} | ||
|
||
private boolean isMale(Form form) { | ||
return form.getApplicant().getGender().equals(Gender.MALE); | ||
} | ||
|
||
private boolean isFemale(Form form) { | ||
return !isMale(form); | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
src/main/java/com/bamdoliro/maru/application/analysis/QueryGradeDistributionUseCase.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,37 @@ | ||
package com.bamdoliro.maru.application.analysis; | ||
|
||
import com.bamdoliro.maru.domain.form.domain.type.FormType; | ||
import com.bamdoliro.maru.infrastructure.persistence.form.FormRepository; | ||
import com.bamdoliro.maru.presentation.analysis.dto.request.GradeDistributionRequest; | ||
import com.bamdoliro.maru.presentation.analysis.dto.response.GradeDistributionResponse; | ||
import com.bamdoliro.maru.shared.annotation.UseCase; | ||
import lombok.RequiredArgsConstructor; | ||
|
||
import java.util.List; | ||
|
||
@RequiredArgsConstructor | ||
@UseCase | ||
public class QueryGradeDistributionUseCase { | ||
|
||
private final FormRepository formRepository; | ||
|
||
public List<GradeDistributionResponse> execute(GradeDistributionRequest request) { | ||
List<GradeDistributionResponse> result = new java.util.ArrayList<>(formRepository.findGradeGroupByTypeAndStatus(request.getStatusList()) | ||
.stream() | ||
.map(GradeDistributionResponse::new) | ||
.toList()); | ||
|
||
List<FormType> existingTypes = result | ||
.stream() | ||
.map(GradeDistributionResponse::getType) | ||
.toList(); | ||
|
||
for (FormType formType : FormType.values()) { | ||
if (!existingTypes.contains(formType)) { | ||
result.add(new GradeDistributionResponse(formType, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0)); | ||
} | ||
} | ||
|
||
return result; | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
src/main/java/com/bamdoliro/maru/application/analysis/QueryNumberOfApplicantsUseCase.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,37 @@ | ||
package com.bamdoliro.maru.application.analysis; | ||
|
||
import com.bamdoliro.maru.domain.form.domain.type.FormType; | ||
import com.bamdoliro.maru.infrastructure.persistence.form.FormRepository; | ||
import com.bamdoliro.maru.presentation.analysis.dto.response.NumberOfApplicantsResponse; | ||
import com.bamdoliro.maru.shared.annotation.UseCase; | ||
import lombok.RequiredArgsConstructor; | ||
|
||
import java.util.List; | ||
import java.util.stream.Collectors; | ||
|
||
@RequiredArgsConstructor | ||
@UseCase | ||
public class QueryNumberOfApplicantsUseCase { | ||
|
||
private final FormRepository formRepository; | ||
|
||
public List<NumberOfApplicantsResponse> execute() { | ||
List<NumberOfApplicantsResponse> result = formRepository.findTypeAndCountGroupByType() | ||
.stream() | ||
.map(NumberOfApplicantsResponse::new) | ||
.collect(Collectors.toList()); | ||
|
||
List<FormType> existingTypes = result | ||
.stream() | ||
.map(NumberOfApplicantsResponse::getType) | ||
.toList(); | ||
|
||
for (FormType formType: FormType.values()) { | ||
if (!existingTypes.contains(formType)) { | ||
result.add(new NumberOfApplicantsResponse(formType, 0L)); | ||
} | ||
} | ||
|
||
return result; | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
src/main/java/com/bamdoliro/maru/application/analysis/QuerySchoolStatusUseCase.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,33 @@ | ||
package com.bamdoliro.maru.application.analysis; | ||
|
||
import com.bamdoliro.maru.infrastructure.persistence.form.FormRepository; | ||
import com.bamdoliro.maru.presentation.analysis.dto.request.SchoolStatusRequest; | ||
import com.bamdoliro.maru.presentation.analysis.dto.response.SchoolStatusResponse; | ||
import com.bamdoliro.maru.shared.annotation.UseCase; | ||
import lombok.RequiredArgsConstructor; | ||
|
||
import java.util.List; | ||
|
||
@RequiredArgsConstructor | ||
@UseCase | ||
public class QuerySchoolStatusUseCase { | ||
|
||
private final FormRepository formRepository; | ||
|
||
public List<SchoolStatusResponse> execute(SchoolStatusRequest request) { | ||
if (request.getIsBusan()) { | ||
String keyword = "부산광역시"; | ||
keyword += request.getGu() == null ? "" : (" " + request.getGu()); | ||
|
||
return formRepository.findSchoolByAddress(request.getStatusList(), keyword) | ||
.stream() | ||
.map(SchoolStatusResponse::new) | ||
.toList(); | ||
} | ||
|
||
return formRepository.findNotBusanSchool(request.getStatusList()) | ||
.stream() | ||
.map(SchoolStatusResponse::new) | ||
.toList(); | ||
} | ||
} |
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
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
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
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
Oops, something went wrong.