generated from Bamdoliro/repository-generator
-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[새기능] 입학등록원 & 금연서약서 제출 및 조회 #166
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
3b7c84c
feat: 입학등록원 양식 작성
oxjadex aadf172
feat: 입학 등록원 타임리프 적용
jyj1289 51365b1
feat: 입학 등록원 및 금연서약서 다운로드 API 작성
jyj1289 faa7ae4
feat: 금연서약서 부활
jyj1289 946b680
test(#165): 금연서약서 및 입학등록원 다운로드 API 테스트 작성
jyj1289 15d4b2e
docs(#165): 금연서약서 및 입학등록원 다운로드 API 문서화
jyj1289 d3dd0b6
feat(#165): 금연서약서 및 입학등록원 업로드 API 작성
jyj1289 8e02606
feat(#165): 금연서약서 및 입학등록원 업로드 API 작성
jyj1289 e841792
test(#165): 금연서약서 및 입학등록원 업로드 API 테스트 작성
jyj1289 3a1b6fa
docs(#165): 금연서약서 및 입학등록원 업로드 API 문서화
jyj1289 fc96d36
fix(#165): 오타수정
jyj1289 54aaec5
fix(#165): 원서 상태검증
jyj1289 38e5e32
refactor(#165): Usecase 및 메서드 이름 변경
jyj1289 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
65 changes: 65 additions & 0 deletions
65
...ain/java/com/bamdoliro/maru/application/form/DownloadAdmissionAndPledgeFormatUseCase.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,65 @@ | ||
package com.bamdoliro.maru.application.form; | ||
|
||
import com.bamdoliro.maru.domain.form.domain.Form; | ||
import com.bamdoliro.maru.domain.form.exception.InvalidFormStatusException; | ||
import com.bamdoliro.maru.domain.form.service.FormFacade; | ||
import com.bamdoliro.maru.domain.user.domain.User; | ||
import com.bamdoliro.maru.infrastructure.pdf.GeneratePdfService; | ||
import com.bamdoliro.maru.infrastructure.pdf.MergePdfService; | ||
import com.bamdoliro.maru.infrastructure.thymeleaf.ProcessTemplateService; | ||
import com.bamdoliro.maru.infrastructure.thymeleaf.Templates; | ||
import com.bamdoliro.maru.shared.annotation.UseCase; | ||
import com.itextpdf.kernel.pdf.PdfDocument; | ||
import com.itextpdf.kernel.pdf.PdfWriter; | ||
import com.itextpdf.kernel.utils.PdfMerger; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.core.io.ByteArrayResource; | ||
|
||
import java.io.ByteArrayOutputStream; | ||
import java.util.Map; | ||
import java.util.List; | ||
|
||
@RequiredArgsConstructor | ||
@UseCase | ||
public class DownloadAdmissionAndPledgeFormatUseCase { | ||
|
||
private final MergePdfService mergePdfService; | ||
private final FormFacade formFacade; | ||
private final ProcessTemplateService processTemplateService; | ||
private final GeneratePdfService generatePdfService; | ||
|
||
public ByteArrayResource execute(User user) { | ||
Form form = formFacade.getForm(user); | ||
validate(form); | ||
|
||
Map<String, Object> formMap = Map.of( | ||
"form", form | ||
); | ||
|
||
List<String> templates = List.of( | ||
Templates.REGISTRATION, | ||
Templates.NO_SMOKING | ||
); | ||
|
||
|
||
ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); | ||
PdfDocument mergedDocument = new PdfDocument(new PdfWriter(outputStream)); | ||
PdfMerger pdfMerger = new PdfMerger(mergedDocument); | ||
|
||
templates | ||
.stream() | ||
.map((t) -> processTemplateService.execute(t, formMap)) | ||
.map(generatePdfService::execute) | ||
.forEach((s) -> mergePdfService.execute(pdfMerger, s)); | ||
|
||
mergedDocument.close(); | ||
pdfMerger.close(); | ||
|
||
return new ByteArrayResource(outputStream.toByteArray()); | ||
} | ||
|
||
private void validate(Form form) { | ||
if (!form.isPassedNow()) | ||
throw new InvalidFormStatusException(); | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
src/main/java/com/bamdoliro/maru/application/form/UploadAdmissionAndPledgeUseCase.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,31 @@ | ||
package com.bamdoliro.maru.application.form; | ||
|
||
import com.bamdoliro.maru.domain.form.domain.Form; | ||
import com.bamdoliro.maru.domain.form.exception.InvalidFormStatusException; | ||
import com.bamdoliro.maru.domain.form.service.FormFacade; | ||
import com.bamdoliro.maru.domain.user.domain.User; | ||
import com.bamdoliro.maru.infrastructure.s3.FileService; | ||
import com.bamdoliro.maru.infrastructure.s3.constants.FolderConstant; | ||
import com.bamdoliro.maru.infrastructure.s3.dto.response.UrlResponse; | ||
import com.bamdoliro.maru.shared.annotation.UseCase; | ||
import lombok.RequiredArgsConstructor; | ||
|
||
@RequiredArgsConstructor | ||
@UseCase | ||
public class UploadAdmissionAndPledgeUseCase { | ||
|
||
private final FileService fileService; | ||
private final FormFacade formFacade; | ||
|
||
public UrlResponse execute(User user) { | ||
Form form = formFacade.getForm(user); | ||
validate(form); | ||
|
||
return fileService.getPresignedUrl(FolderConstant.ADMISSION_AND_PLEDGE, user.getUuid().toString()); | ||
} | ||
|
||
private void validate(Form form) { | ||
if(!form.isPassedNow()) | ||
throw new InvalidFormStatusException(); | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,153 @@ | ||
<!DOCTYPE html> | ||
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org" lang="ko"> | ||
<head> | ||
<meta charset="UTF-8"/> | ||
<style> | ||
@page { | ||
size: A4; | ||
margin: 70px; | ||
} | ||
* { | ||
font-family: SUIT, sans-serif; | ||
margin: 0; | ||
padding: 0; | ||
box-sizing: border-box; | ||
} | ||
table { | ||
border: none; | ||
border-collapse: collapse; | ||
width: 100%; | ||
font-size: 14px; | ||
text-align: center; | ||
line-height: normal; | ||
} | ||
tr { | ||
vertical-align: middle; | ||
} | ||
td { | ||
padding: 8px 0; | ||
} | ||
th { | ||
background-color: #ECF2FA; | ||
font-weight: 500; | ||
padding: 8px 0; | ||
} | ||
.ba { | ||
border: #000000 1px solid; | ||
} | ||
caption { | ||
font-weight: bold; | ||
font-size: 28px; | ||
line-height: 48px; | ||
text-align: center; | ||
} | ||
.left { | ||
text-align: left; | ||
} | ||
.right { | ||
text-align: right; | ||
} | ||
.center { | ||
text-align: center; | ||
} | ||
.text-box { | ||
padding: 15px 10px; | ||
vertical-align: text-top; | ||
} | ||
.middle { | ||
font-size: 18px; | ||
line-height: 160%; | ||
} | ||
.school { | ||
font-weight: bold; | ||
font-size: 24px; | ||
} | ||
.guide { | ||
font-size: 11px; | ||
color: #BBBCC2; | ||
font-weight: 300; | ||
} | ||
.indent { | ||
text-indent: 18px; | ||
font-size: 22px; | ||
word-break: keep-all; | ||
} | ||
.red { | ||
color: #F44336; | ||
font-weight: 600; | ||
} | ||
.padding { | ||
padding: 16px; | ||
} | ||
</style> | ||
<title>원서</title> | ||
</head> | ||
<body> | ||
<table> | ||
<caption>금연 동의서</caption> | ||
<tr> | ||
<th scope="row" class="ba" style="width:15%;">성명</th> | ||
<td class="ba" style="width:35%;" th:text="${form.applicant.name}"></td> | ||
<th scope="row" class="ba" style="width:15%;">수험번호</th> | ||
<td class="ba" style="width:35%;" th:text="${form.getExaminationNumber()}">1000</td> | ||
</tr> | ||
<tr> | ||
<th scope="row" class="ba">출신중학교</th> | ||
<td class="ba" colspan="3" th:text="${form.education.school.name}"></td> | ||
</tr> | ||
<tr> | ||
<td style="height: 24px"></td> | ||
</tr> | ||
<tr> | ||
<td class="ba text-box middle left padding" colspan="4"> | ||
<p>하나. 나 자신의 건강을 위해서 흡연을 하지 않겠습니다.</p> | ||
<p>하나. 흡연의 유혹에 절대로 흔들리지 않겠습니다.</p> | ||
<p>하나. 흡연을 하는 친구가 있으면 충고하여 금연을 할 수 있도록 돕겠습니다.</p> | ||
<div style="height: 48px;"></div> | ||
<p class="indent">나 <span th:text="${form.applicant.name}"></span>은(는) 이 시대를 이끌어갈 SW 분야 영 마이스터가 되기 위해 <span class="red">흡연을 하지 않겠습니다.</span></p> | ||
<p class="indent">보호자는 지원자의 건강한 성장과 발전을 위해 용기와 도움을 줄 것을 약속합니다.</p> | ||
<div style="height: 48px;"></div> | ||
<p id="security">■ 개인 정보 수집·이용 동의</p> | ||
<table aria-describedby="security"> | ||
<tr> | ||
<th scope="col" class="ba" style="width: 35%">항목</th> | ||
<th scope="col" class="ba" style="width: 30%">수집목적</th> | ||
<th scope="col" class="ba" style="width: 35%">보유기간</th> | ||
</tr> | ||
<tr> | ||
<td class="ba">학생(성명, 출신중학교)</td> | ||
<td class="ba">금연동의서</td> | ||
<td class="ba">3년</td> | ||
</tr> | ||
<tr> | ||
<td class="left" colspan="3"> | ||
※ 개인정보 수집·이용에 대한 동의를 거부할 권리가 있습니다.<br/> | ||
그러나 동의를 거부할 경우 최종입학에 제한을 받을 수 있습니다. | ||
<div style="height: 24px;"></div> | ||
</td> | ||
</tr> | ||
<tr> | ||
<th scope="row" class="ba">개인정보 수집·이용 동의</th> | ||
<td class="ba" colspan="2">□ 예 □ 아니오</td> | ||
</tr> | ||
</table> | ||
<div style="height: 48px;"></div> | ||
<p class="middle center" th:text="${#dates.format(#dates.createNow(),'YYYY년 MM월 dd일')}"></p> | ||
<div style="height: 54px;"></div> | ||
<p class="right"> | ||
지원자 | ||
<span th:text="${form.applicant.name}"></span> | ||
<span class="guide">(서명)</span> | ||
</p> | ||
<p class="right"> | ||
보호자 | ||
<span th:text="${form.parent.name}"></span> | ||
<span class="guide">(서명)</span> | ||
</p> | ||
<div style="height: 54px;"></div> | ||
<p class="school left">부산소프트웨어마이스터고등학교장 귀하</p> | ||
</td> | ||
</tr> | ||
</table> | ||
</body> | ||
</html> |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
요거 왠지 공통 메서드일 거 같은데 분리하는 거 고려해봐도 좋을 거 같아욤
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
마루 운영 끝난 후 반영하도록 하겠습니다 :)