Skip to content

Commit

Permalink
fix: 파일 이름 양식 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
jcy0308 committed Aug 30, 2024
1 parent 21d0055 commit f0d1bcd
Showing 1 changed file with 24 additions and 11 deletions.
35 changes: 24 additions & 11 deletions src/modules/reviews/reviews.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export class ReviewsService {
return fileName;
}

async buildResultPdf(reviewId, replacer, isMain) {
async buildResultPdf(reviewId, replacer, isMain, studentName: string) {
const fileName = (isMain ? "" : "예비") + "심사결과보고서_양식.html";
const filePath = path.join("resources", "format", fileName);
try {
Expand Down Expand Up @@ -271,8 +271,9 @@ export class ReviewsService {

const key = v1();
const createdAt = new Date();
await this.kafkaProducer.sendMessage("pdf-topic", key, formatHtml, {
originalName: reviewId.toString() + "_" + fileName.replace(".html", ".pdf"),
await this.kafkaProducer.sendMessage("pdf-topic", reviewId, formatHtml, {
originalName: studentName + "_" + fileName.replace("_양식.html", ".pdf"),
uuid: key,
});
// await convertHTMLToPDF(formatHtml, async (pdf) => {
// if (err) throw new InternalServerErrorException("Creating PDF Buffer failed!");
Expand All @@ -285,11 +286,10 @@ export class ReviewsService {
// "application/pdf"
// );
// });

return resolve(
await this.prismaService.file.create({
data: {
name: reviewId.toString() + "_" + fileName.replace(".html", ".pdf"),
name: studentName + "_" + fileName.replace("_양식.html", ".pdf"),
mimeType: "application/pdf",
uuid: key,
createdAt: createdAt,
Expand All @@ -304,7 +304,7 @@ export class ReviewsService {
}
}

async buildReportPdf(reviewId, replacer, isMain) {
async buildReportPdf(reviewId, replacer, isMain, studentName: string) {
const fileName = (isMain ? "" : "예비") + "심사보고서_양식.html";
const filePath = path.join("resources", "format", fileName);
try {
Expand Down Expand Up @@ -339,12 +339,15 @@ export class ReviewsService {
// "application/pdf"
// );
// });
await this.kafkaProducer.sendMessage("pdf-topic", key, formatHtml);
await this.kafkaProducer.sendMessage("pdf-topic", reviewId, formatHtml, {
originalName: studentName + "_" + fileName.replace("_양식.html", ".pdf"),
uuid: key,
});

return resolve(
await this.prismaService.file.create({
data: {
name: reviewId.toString() + "_" + fileName.replace(".html", ".pdf"),
name: studentName + "_" + fileName.replace("_양식.html", ".pdf"),
mimeType: "application/pdf",
uuid: key,
createdAt: createdAt,
Expand Down Expand Up @@ -753,7 +756,12 @@ export class ReviewsService {
"$심사위원:성명": foundReview.reviewer.name,
$서명: foundReview.reviewer.signId,
};
file = await this.buildReportPdf(foundReview.id, replacer, isMain);
file = await this.buildReportPdf(
foundReview.id,
replacer,
isMain,
foundReview.thesisInfo.process.student.name
);
} //내용심사 & 구두심사 중 하나라도 보류중인 경우 파일생성없이 comment와 상태만 업데이트
} else if (foundReview.thesisInfo.stage == Stage.PRELIMINARY) {
// 예심 (=내용 심사 only)
Expand All @@ -772,7 +780,12 @@ export class ReviewsService {
"$심사위원:성명": foundReview.reviewer.name,
$서명: foundReview.reviewer.signId,
};
file = await this.buildReportPdf(foundReview.id, replacer, isMain);
file = await this.buildReportPdf(
foundReview.id,
replacer,
isMain,
foundReview.thesisInfo.process.student.name
);
}
}
}
Expand Down Expand Up @@ -1224,7 +1237,7 @@ export class ReviewsService {
}
}
const isMain = foundReview.thesisInfo.stage == Stage.MAIN ? true : false;
file = await this.buildResultPdf(foundReview.id, replacer, isMain);
file = await this.buildResultPdf(foundReview.id, replacer, isMain, foundReview.thesisInfo.process.student.name);
}
try {
const review = await this.prismaService.$transaction(async (tx) => {
Expand Down

0 comments on commit f0d1bcd

Please sign in to comment.