Skip to content

Commit

Permalink
Merge branch 'develop' of https://github.com/Bamdoliro/marubase into …
Browse files Browse the repository at this point in the history
…feat/#119
  • Loading branch information
jyj1289 committed Sep 8, 2024
2 parents 360778a + d0d5dce commit b224d2f
Show file tree
Hide file tree
Showing 15 changed files with 257 additions and 38 deletions.
8 changes: 4 additions & 4 deletions src/docs/asciidoc/analysis.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
=== 전형별 지원자 수 조회
전형별 지원자들의 수를 조회할 수 있습니다.

=== 요청 형식
==== 요청 형식

==== Request Header
include::{snippets}/analysis-controller-test/전형별_지원자수를_조회한다/request-headers.adoc[]
Expand All @@ -17,7 +17,7 @@ include::{snippets}/analysis-controller-test/전형별_지원자수를_조회한
=== 전형별 성적 분포 조회
1차 합격자, 2차 전형자, 최종 합격자들의 전형별 성적 분포를 조회할 수 있습니다.

=== 요청 형식
==== 요청 형식

==== Request Header
include::{snippets}/analysis-controller-test/_1차_합격자들의_성적_분포를_조회한다/request-headers.adoc[]
Expand All @@ -44,7 +44,7 @@ include::{snippets}/analysis-controller-test/최종_합격자들의_성적_분
=== 전형별 성비 조회
1차 합격자, 2차 전형자, 최종 합격자들의 전형별, 지역별 성비를 조회할 수 있습니다.

=== 요청 형식
==== 요청 형식

==== Request Header
include::{snippets}/analysis-controller-test/전형별_성비를_조회한다/request-headers.adoc[]
Expand All @@ -63,7 +63,7 @@ include::{snippets}/analysis-controller-test/전형별_성비를_조회한다/ht
=== 전형별 출신학교 조회
1차 합격자, 2차 전형자, 최종 합격자들의 출신학교를 조회할 수 있습니다.

=== 요청 형식
==== 요청 형식

==== Request Header
include::{snippets}/analysis-controller-test/부산_특정구_출신_지원자들의_출신학교_통계를_조회한다/request-headers.adoc[]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,17 @@ public class QuerySchoolStatusUseCase {
private final FormRepository formRepository;

public List<SchoolStatusResponse> 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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import com.bamdoliro.maru.domain.form.domain.type.AchievementLevel;
import com.bamdoliro.maru.domain.form.domain.value.Subject;
import com.bamdoliro.maru.domain.form.domain.value.SubjectMap;
import com.bamdoliro.maru.domain.form.exception.FormAlreadySubmittedException;
import com.bamdoliro.maru.domain.form.service.FormFacade;
import com.bamdoliro.maru.domain.user.domain.User;
import com.bamdoliro.maru.infrastructure.pdf.GeneratePdfService;
Expand All @@ -24,10 +23,7 @@
import org.springframework.core.io.ByteArrayResource;

import java.io.ByteArrayOutputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.*;
import java.util.stream.Collectors;

@Slf4j
Expand Down Expand Up @@ -72,10 +68,25 @@ public ByteArrayResource execute(User user) {

private List<SubjectVO> getSubjectList(Form form) {
List<SubjectVO> value = new ArrayList<>();
List<String> careerElectiveCourses = List.of("음악", "미술", "체육");
Map<String, List<Subject>> subjectMap = form.getGrade()
.getSubjectListValue()
.stream()
.collect(Collectors.groupingBy(Subject::getSubjectName));
.filter(subject -> !careerElectiveCourses.contains(subject.getSubjectName()))
.collect(Collectors.groupingBy(
Subject::getSubjectName,
LinkedHashMap::new,
Collectors.toList()
));
careerElectiveCourses.forEach(course -> {
List<Subject> subjects = form.getGrade().getSubjectListValue()
.stream()
.filter(subject -> course.equals(subject.getSubjectName()))
.collect(Collectors.toList());
if (!subjects.isEmpty()) {
subjectMap.put(course, subjects);
}
});

subjectMap.forEach((key, values) -> {
SubjectVO subject = new SubjectVO(key);
Expand All @@ -84,7 +95,7 @@ private List<SubjectVO> getSubjectList(Form form) {
subject.score = v.getOriginalScore();
} else {
try {
SubjectVO.class.getField("achievementLevel" + v.toString())
SubjectVO.class.getField("achievementLevel" + v)
.set(subject, v.getAchievementLevel());
} catch (IllegalAccessException | NoSuchFieldException e) {
throw new RuntimeException(e);
Expand All @@ -103,16 +114,16 @@ private List<String> getRequiredTemplates(Form form) {
Templates.FORM,
Templates.GRADE_TABLE,
Templates.DOCUMENT,
Templates.NO_SMOKING
Templates.WRITTEN_OATH
);
}

return List.of(
Templates.FORM,
Templates.GRADE_TABLE,
Templates.DOCUMENT,
Templates.RECOMMENDATION,
Templates.NO_SMOKING
Templates.WRITTEN_OATH,
Templates.RECOMMENDATION
);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
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.exception.MissingTotalScoreException;
import com.bamdoliro.maru.infrastructure.persistence.form.FormRepository;
import com.bamdoliro.maru.presentation.form.dto.response.FormSimpleResponse;
import com.bamdoliro.maru.shared.annotation.UseCase;
Expand All @@ -25,13 +24,14 @@ public List<FormSimpleResponse> execute(FormStatus status, FormType.Category cat
.filter(form -> Objects.isNull(category) || form.getType().categoryEquals(category))
.toList());

if (sort != null && formList.stream().anyMatch(form -> form.getScore().getTotalScore() == null)) {
throw new MissingTotalScoreException();
}
if ("total-score-asc".equals(sort)) {
formList.sort(Comparator.comparing(form -> form.getScore().getTotalScore(), Comparator.naturalOrder()));
} else if ("total-score-desc".equals(sort)) {
formList.sort(Comparator.comparing(form -> form.getScore().getTotalScore(), Comparator.reverseOrder()));
if (sort != null) {
switch (sort) {
case "total-score-asc" ->
formList.sort(Comparator.comparing(form -> form.getScore().getTotalScore(), Comparator.nullsLast(Comparator.naturalOrder())));
case "total-score-desc" ->
formList.sort(Comparator.comparing(form -> form.getScore().getTotalScore(), Comparator.nullsLast(Comparator.reverseOrder())));
case "form-id" -> formList.sort(Comparator.comparing(Form::getId));
}
}

return formList.stream()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,5 @@ public interface FormRepositoryCustom {
List<NumberOfApplicantsVo> findTypeAndCountGroupByType();
List<GradeVo> findGradeGroupByTypeAndStatus(List<FormStatus> round);
List<SchoolStatusVo> findSchoolByAddress(List<FormStatus> round, String keyword);
List<SchoolStatusVo> findNotBusanSchool(List<FormStatus> round);
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -285,4 +286,17 @@ public List<SchoolStatusVo> findSchoolByAddress(List<FormStatus> round, String k
.and(form.status.in(round)))
.fetch();
}

@Override
public List<SchoolStatusVo> findNotBusanSchool(List<FormStatus> 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();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ public class Templates {
public static final String ADMISSION_TICKET = "admission-ticket";
public static final String PROOF_OF_APPLICATION = "proof-of-application";
public static final String GRADE_TABLE = "grade-table";
public static final String WRITTEN_OATH = "written-oath";
}
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public ResponseEntity<ErrorResponse> enumMismatchException(MethodArgumentNotVali

return ResponseEntity
.status(GlobalErrorProperty.BAD_REQUEST.getStatus())
.body(new ErrorResponse(GlobalErrorProperty.BAD_REQUEST, e.getMessage()));
.body(new ErrorResponse(GlobalErrorProperty.BAD_REQUEST, e.getBindingResult().getFieldErrors().get(0).getDefaultMessage()));
}

@ExceptionHandler(FileSizeLimitExceededException.class)
Expand Down
6 changes: 5 additions & 1 deletion src/main/resources/templates/document.html
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,10 @@
font-weight: 500;
padding: 8px 0;
}

.format {
font-size: 13px;
font-weight: bold;
}
.ba {
border: #000000 1px solid;
}
Expand All @@ -65,6 +68,7 @@
</head>
<body>
<table>
<p class="format">[서식2]</p>
<caption>자기소개서 및 학업계획서</caption>
<tr>
<th scope="row" class="ba" style="width:15%;">성명</th>
Expand Down
8 changes: 6 additions & 2 deletions src/main/resources/templates/form.html
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,10 @@
line-height: 48px;
text-align: center;
}

.format {
font-size: 13px;
font-weight: bold;
}
.school {
font-weight: bold;
font-size: 18px;
Expand Down Expand Up @@ -100,7 +103,8 @@
</head>
<body>
<table>
<caption th:text='${year+"학년도 부산소프트웨어마이스터고등학교 전형원서"}'></caption>
<p class="format">[서식1]</p>
<caption th:text='${year+"학년도 부산소프트웨어마이스터고등학교 입학원서"}'></caption>
<colgroup>
<col style="width:6.39%"/>
<col style="width:1.46%"/>
Expand Down
8 changes: 6 additions & 2 deletions src/main/resources/templates/recommendation.html
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,10 @@
font-weight: 500;
padding: 8px 0;
}

.format {
font-size: 13px;
font-weight: bold;
}
.ba {
border: #000000 1px solid;
}
Expand Down Expand Up @@ -93,6 +96,7 @@
</head>
<body>
<table>
<p class="format">[서식4]</p>
<caption>학교장 추천서</caption>
<tr>
<th scope="row" class="ba" style="width:15%;">성명</th>
Expand Down Expand Up @@ -158,7 +162,7 @@
<span class="guide">(직인)</span>
</p>
<div style="height: 96px;"></div>
<p class="school left">부산소프트웨어마이스터고등학교장 귀하</p>
<p class="school center">부산소프트웨어마이스터고등학교장 귀하</p>
</td>
</tr>
</table>
Expand Down
Loading

0 comments on commit b224d2f

Please sign in to comment.