From d347a5048f9b10941b27c9ac418e4920539f3293 Mon Sep 17 00:00:00 2001 From: leGit-y Date: Sun, 22 Oct 2023 22:35:06 +0900 Subject: [PATCH] =?UTF-8?q?[FIX]=20=EB=A6=AC=EB=B7=B0=EC=82=AD=EC=A0=9C?= =?UTF-8?q?=ED=9B=84=20=EA=B3=A0=EB=AF=BC=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/repository/reviewRepository.ts | 11 ++++++++++- src/service/worryService.ts | 4 ++++ swagger.yaml | 2 +- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/repository/reviewRepository.ts b/src/repository/reviewRepository.ts index da2567f..56831bc 100644 --- a/src/repository/reviewRepository.ts +++ b/src/repository/reviewRepository.ts @@ -33,9 +33,18 @@ const findreviewById = async (worryId: number) => { }); }; +const deleteReviewById = async (worryId: number) => { + return await prisma.review.delete({ + where:{ + worry_id: worryId + } + }); +}; + export default{ createReview, updateReview, - findreviewById + findreviewById, + deleteReviewById } \ No newline at end of file diff --git a/src/service/worryService.ts b/src/service/worryService.ts index 35f0e51..09b665a 100644 --- a/src/service/worryService.ts +++ b/src/service/worryService.ts @@ -69,6 +69,10 @@ const deleteWorry =async (worryId: number,userId: number) => { if (worry.user_id != userId) { throw new ClientException("고민글 작성자만 삭제할 수 있습니다."); } + const review = await reviewRepository.findreviewById(worryId); + if(review){ + await reviewRepository.deleteReviewById(worryId); + } await worryRepository.deleteWorry(worryId); } diff --git a/swagger.yaml b/swagger.yaml index 92dc065..049949b 100644 --- a/swagger.yaml +++ b/swagger.yaml @@ -59,7 +59,7 @@ paths: $ref: '#/components/responses/BadRequest' '500': $ref: '#/components/responses/InternalServerError' - /auth/refresh/token: + /auth/token/refresh: post: tags: - Auth