From c91b5bfb0c372cc70ceb69a077f39e61c8e0da06 Mon Sep 17 00:00:00 2001 From: yesjuhee Date: Thu, 9 May 2024 11:05:11 +0900 Subject: [PATCH] =?UTF-8?q?[FIX]=20=ED=8A=B9=EC=A0=95=20=ED=95=99=EA=B3=BC?= =?UTF-8?q?=20=ED=95=99=EC=83=9D=20=EB=85=BC=EB=AC=B8=20=EC=A0=95=EB=B3=B4?= =?UTF-8?q?=20=EC=97=85=EB=8D=B0=EC=9D=B4=ED=8A=B8=20=EC=98=A4=EB=A5=98=20?= =?UTF-8?q?=EC=88=98=EC=A0=95=20(#130)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix: 학생이 본심 논문 수정 시 수정지시사항 반영 학과 체크 * fix: 관리자가 본심 논문 수정 시 수정지시사항 반영 학과 체크 * fix: 논문 정보 업데이트 API 다시 수정 * fix: 학생 엑셀 업로드로 논문 제목 수정시 생길 수 있는 오류 수정 --- src/modules/students/students.service.ts | 38 ++++++++++++++---------- src/modules/theses/theses.service.ts | 30 +++++++++++-------- 2 files changed, 40 insertions(+), 28 deletions(-) diff --git a/src/modules/students/students.service.ts b/src/modules/students/students.service.ts index ac64f2f..94b5757 100644 --- a/src/modules/students/students.service.ts +++ b/src/modules/students/students.service.ts @@ -433,10 +433,12 @@ export class StudentsService { where: { id: mainThesisInfo.id }, data: { title: thesisTitle }, }); - await tx.thesisInfo.update({ - where: { id: revisionThesisInfo.id }, - data: { title: thesisTitle }, - }); + if (revisionThesisInfo) { + await tx.thesisInfo.update({ + where: { id: revisionThesisInfo.id }, + data: { title: thesisTitle }, + }); + } } // 지도 정보 수정 (reviewer, review) @@ -1572,9 +1574,9 @@ export class StudentsService { (thesisFile) => thesisFile.type === ThesisFileType.PRESENTATION )[0]; - const [thesisInfo] = await this.prismaService.$transaction([ + const thesisInfo = await this.prismaService.$transaction(async (tx) => { // 본심 논문 정보 업데이트 - this.prismaService.thesisInfo.update({ + const thesisData = await tx.thesisInfo.update({ where: { id: mainThesisInfo.id }, data: { title, @@ -1600,17 +1602,21 @@ export class StudentsService { include: { file: true }, }, }, - }), - // 수정지시사항 논문 정보 업데이트 - this.prismaService.thesisInfo.update({ - where: { id: revisionThesisInfo.id }, - data: { - title, - abstract, - }, - }), - ]); + }); + + if (revisionThesisInfo) { + // 수정지시사항 논문 정보 업데이트 : 수정 지시시항 포함 학과만!! + await tx.thesisInfo.update({ + where: { id: revisionThesisInfo.id }, + data: { + title, + abstract, + }, + }); + } + return thesisData; + }); return thesisInfo; } // 수정 지시사항 반영 단계일 경우 else if (currentStage === Stage.REVISION) { diff --git a/src/modules/theses/theses.service.ts b/src/modules/theses/theses.service.ts index 2c133a8..7bb9472 100644 --- a/src/modules/theses/theses.service.ts +++ b/src/modules/theses/theses.service.ts @@ -78,9 +78,9 @@ export class ThesesService { (thesisInfo) => thesisInfo.stage === Stage.REVISION )[0]; - const [thesisInfo] = await this.prismaService.$transaction([ + const thesisInfo = await this.prismaService.$transaction(async (tx) => { // 본심 논문 정보 업데이트 - this.prismaService.thesisInfo.update({ + const thesisData = tx.thesisInfo.update({ where: { id }, data: { title, @@ -106,16 +106,22 @@ export class ThesesService { include: { file: true }, }, }, - }), - // 수정지시사항 논문 정보 업데이트 - this.prismaService.thesisInfo.update({ - where: { id: revisionThesisInfo.id }, - data: { - title, - abstract, - }, - }), - ]); + }); + + if (revisionThesisInfo) { + // 수정지시사항 논문 정보 업데이트 : 수정 지시시항 포함 학과만!! + await tx.thesisInfo.update({ + where: { id: revisionThesisInfo.id }, + // where: { id: revisionThesisInfo.id }, + data: { + title, + abstract, + }, + }); + } + + return thesisData; + }); return thesisInfo; } // 수정 지시사항 반영 단계일 경우