Skip to content

Commit

Permalink
pref(#72): auto admission year
Browse files Browse the repository at this point in the history
- 기존 수험표에 하드코딩해놨던 입학 일정을 Schedule class로 옮겼습니다~
  • Loading branch information
gimhanul committed Sep 1, 2023
1 parent f8dd8ac commit b99982c
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,18 @@
import com.bamdoliro.maru.infrastructure.thymeleaf.ProcessTemplateService;
import com.bamdoliro.maru.infrastructure.thymeleaf.Templates;
import com.bamdoliro.maru.shared.annotation.UseCase;
import com.bamdoliro.maru.shared.constants.Schedule;
import lombok.RequiredArgsConstructor;
import org.springframework.core.io.ByteArrayResource;

import java.io.ByteArrayOutputStream;
import java.util.Map;

import static com.bamdoliro.maru.shared.constants.Schedule.CODING_TEST;
import static com.bamdoliro.maru.shared.constants.Schedule.DEPTH_INTERVIEW;
import static com.bamdoliro.maru.shared.constants.Schedule.NCS;
import static com.bamdoliro.maru.shared.constants.Schedule.PHYSICAL_EXAMINATION;

@RequiredArgsConstructor
@UseCase
public class GenerateAdmissionTicketUseCase {
Expand All @@ -27,7 +33,12 @@ public ByteArrayResource execute(User user) {
validateFormStatus(form);

Map<String, Object> formMap = Map.of(
"form", form
"form", form,
"year", Schedule.getAdmissionYear(),
"codingTest", Schedule.toLocaleString(CODING_TEST),
"ncs", Schedule.toLocaleString(NCS),
"depthInterview", Schedule.toLocaleString(DEPTH_INTERVIEW),
"physicalExamination", Schedule.toLocaleString(PHYSICAL_EXAMINATION)
);
String html = processTemplateService.execute(Templates.ADMISSION_TICKET, formMap);
ByteArrayOutputStream outputStream = generatePdfService.execute(html);
Expand Down
11 changes: 11 additions & 0 deletions src/main/java/com/bamdoliro/maru/shared/constants/Schedule.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Locale;

@UtilityClass
public class Schedule {
Expand All @@ -12,9 +14,18 @@ public class Schedule {
public static final LocalDateTime END = LocalDateTime.of(2023, 10, 19, 17, 0);
public static final LocalDateTime ANNOUNCEMENT_OF_FIRST_PASS = LocalDateTime.of(2023, 10, 23, 15, 0);
public static final LocalDateTime ANNOUNCEMENT_OF_SECOND_PASS = LocalDateTime.of(2023, 11, 2, 15, 0);
public static final LocalDateTime CODING_TEST = LocalDateTime.of(2023, 10, 27, 9, 30);
public static final LocalDateTime NCS = LocalDateTime.of(2023, 10, 27, 11, 0);
public static final LocalDateTime DEPTH_INTERVIEW = LocalDateTime.of(2023, 10, 27, 13, 0);
public static final LocalDateTime PHYSICAL_EXAMINATION = LocalDateTime.of(2023, 10, 27, 13, 0);
public static final String SELECT_FIRST_PASS_CRON = "0 0 1 20 10 ?";

public static int getAdmissionYear() {
return START.plusYears(1L).getYear();
}

public String toLocaleString(LocalDateTime datetime) {
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy.MM.dd (E) HH:mm", Locale.KOREA);
return formatter.format(datetime);
}
}
10 changes: 5 additions & 5 deletions src/main/resources/templates/admission-ticket.html
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@
<table class="admission-ticket">
<tr class="ba">
<td colspan="3" class="ba center" style="height: 48px;">
<p>2023학년도</p>
<p th:text='${year+"학년도"}'></p>
<p>부산소프트웨어마이스터고등학교 입학전형</p>
<p class="big letter-spacing-10">수험표</p>
</td>
Expand Down Expand Up @@ -174,22 +174,22 @@
</tr>
<tr>
<td class="ba" style="word-break: keep-all;">코딩 테스트 (마이스터 인재전형 지원자)</td>
<td class="ba">2023.10.27 (금) 09:30</td>
<td class="ba" th:text="${codingTest}"></td>
<td class="ba">평가장</td>
</tr>
<tr>
<td class="ba">NCS 인적성 검사</td>
<td class="ba">2023.10.27 (금) 11:00</td>
<td class="ba" th:text="${ncs}"></td>
<td class="ba">검사장</td>
</tr>
<tr>
<td class="ba">심층면접</td>
<td class="ba">2023.10.27 (금) 13:00</td>
<td class="ba" th:text="${depthInterview}"></td>
<td class="ba">면접장</td>
</tr>
<tr>
<td class="ba">신체검사</td>
<td class="ba">2023.10.27 (금) 13:00</td>
<td class="ba" th:text="${physicalExamination}"></td>
<td class="ba">검사장</td>
</tr>
</table>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.bamdoliro.maru.application.form;

import com.bamdoliro.maru.domain.form.domain.Form;
import com.bamdoliro.maru.domain.form.domain.type.FormType;
import com.bamdoliro.maru.domain.form.service.CalculateFormScoreService;
import com.bamdoliro.maru.domain.user.domain.User;
import com.bamdoliro.maru.infrastructure.persistence.form.FormRepository;
Expand All @@ -18,8 +17,6 @@

import java.io.IOException;

import static org.junit.jupiter.api.Assertions.*;

@Disabled
@ActiveProfiles("test")
@SpringBootTest
Expand Down

0 comments on commit b99982c

Please sign in to comment.