From 1f33d2a495c409f60920245bb04e6658b7911dc1 Mon Sep 17 00:00:00 2001 From: modzivv Date: Fri, 1 Aug 2025 00:32:37 +0900 Subject: [PATCH 1/3] =?UTF-8?q?fix:=20BigInt=20=EB=B3=80=ED=99=98=20?= =?UTF-8?q?=EC=8B=9C=20undefined=20=ED=8C=8C=EB=9D=BC=EB=AF=B8=ED=84=B0?= =?UTF-8?q?=EB=A1=9C=20=EC=9D=B8=ED=95=9C=20=EC=84=9C=EB=B2=84=20=EC=98=A4?= =?UTF-8?q?=EB=A5=98=20=ED=95=B4=EA=B2=B0=20#104?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/common/errors/notification.errors.js | 22 ++++++++ src/common/errors/review.errors.js | 55 +++++++++++++++---- .../controller/notification.controller.js | 13 +++-- .../fcm/controller/push.controller.js | 10 +++- src/review/controller/review.controller.js | 29 ++++++++-- 5 files changed, 106 insertions(+), 23 deletions(-) diff --git a/src/common/errors/notification.errors.js b/src/common/errors/notification.errors.js index 3ecf5e1..85fe537 100644 --- a/src/common/errors/notification.errors.js +++ b/src/common/errors/notification.errors.js @@ -120,4 +120,26 @@ export class PushTokenAlreadyExistsError extends BaseError { data }); } +} + +export class NotificationIdRequiredError extends BaseError { + constructor(data = null) { + super({ + errorCode: "N012", + reason: "notificationId가 필요합니다", + statusCode: 400, + data + }); + } +} + +export class TargetUserIdRequiredError extends BaseError { + constructor(data = null) { + super({ + errorCode: "N014", + reason: "target_user_id가 필요합니다", + statusCode: 400, + data + }); + } } \ No newline at end of file diff --git a/src/common/errors/review.errors.js b/src/common/errors/review.errors.js index db1ae29..31640d3 100644 --- a/src/common/errors/review.errors.js +++ b/src/common/errors/review.errors.js @@ -33,17 +33,6 @@ export class ReviewContentTooShortError extends BaseError { } } -export class ReviewContentTooLongError extends BaseError { - constructor(data = null) { - super({ - errorCode: "R011", - reason: "리뷰 내용이 1000자를 초과합니다", - statusCode: 400, // Bad Request - data, - }); - } -} - export class RequestNotFoundError extends BaseError { constructor(data = null) { super({ @@ -119,4 +108,48 @@ export class ReviewRatingInvalidError extends BaseError { data, }); } +} + +export class ReviewContentTooLongError extends BaseError { + constructor(data = null) { + super({ + errorCode: "R011", + reason: "리뷰 내용이 1000자를 초과합니다", + statusCode: 400, // Bad Request + data, + }); + } +} + +export class RequestIdRequiredError extends BaseError { + constructor(data = null) { + super({ + errorCode: "R012", + reason: "requestId가 필요합니다", + statusCode: 400, // Bad Request + data, + }); + } +} + +export class ReviewIdRequiredError extends BaseError { + constructor(data = null) { + super({ + errorCode: "R013", + reason: "reviewId가 필요합니다", + statusCode: 400, // Bad Request + data, + }); + } +} + +export class UserIdRequiredError extends BaseError { + constructor(data = null) { + super({ + errorCode: "R014", + reason: "userId가 필요합니다", + statusCode: 400, // Bad Request + data, + }); + } } \ No newline at end of file diff --git a/src/notification/controller/notification.controller.js b/src/notification/controller/notification.controller.js index 3132777..a42f6f2 100644 --- a/src/notification/controller/notification.controller.js +++ b/src/notification/controller/notification.controller.js @@ -1,12 +1,14 @@ import { StatusCodes } from "http-status-codes"; -import notificationService from '../service/notification.service.js'; import { stringifyWithBigInt } from "../../bigintJson.js"; import { - NotificationListResponseDto, - NotificationReadResponseDto, + NotificationIdRequiredError +} from '../../common/errors/notification.errors.js'; +import { NotificationDeleteResponseDto, - NotificationListItemDto + NotificationListResponseDto, + NotificationReadResponseDto } from '../dto/notification.dto.js'; +import notificationService from '../service/notification.service.js'; class NotificationController { @@ -49,6 +51,9 @@ class NotificationController { async markNotificationAsRead(req, res, next) { try { // URL 파라미터에서 알림 ID를 추출하고 BigInt로 변환 + if (!req.params.notificationId) { + throw new NotificationIdRequiredError(); // notificationId가 누락된 경우 NotificationIdRequiredError 반환 + } const notificationId = BigInt(req.params.notificationId); // 현재 로그인한 사용자 ID diff --git a/src/notification/fcm/controller/push.controller.js b/src/notification/fcm/controller/push.controller.js index 7cee2f8..fc59113 100644 --- a/src/notification/fcm/controller/push.controller.js +++ b/src/notification/fcm/controller/push.controller.js @@ -1,11 +1,14 @@ import { StatusCodes } from "http-status-codes"; import { stringifyWithBigInt } from "../../../bigintJson.js"; import { + TargetUserIdRequiredError +} from '../../../common/errors/notification.errors.js'; +import { + PushSendResponseDto, PushTokenDeleteResponseDto, PushTokenRegisterDto, PushTokenResponseDto, - TestPushRequestDto, - PushSendResponseDto + TestPushRequestDto } from '../dto/push.dto.js'; import pushService from '../service/push.service.js'; @@ -79,6 +82,9 @@ class PushController { const testPushDto = new TestPushRequestDto(req.body); // 대상 사용자 ID 추출 + if (!testPushDto.target_user_id) { + throw new TargetUserIdRequiredError(); // target_user_id가 누락된 경우 TargetUserIdRequiredError 반환 + } const targetUserId = BigInt(testPushDto.target_user_id); // 테스트 Push 발송 서비스 호출 diff --git a/src/review/controller/review.controller.js b/src/review/controller/review.controller.js index f9b39cf..27c81bd 100644 --- a/src/review/controller/review.controller.js +++ b/src/review/controller/review.controller.js @@ -1,13 +1,18 @@ import { StatusCodes } from "http-status-codes"; -import reviewService from '../service/review.service.js'; import { stringifyWithBigInt } from "../../bigintJson.js"; import { + RequestIdRequiredError, + ReviewIdRequiredError, + UserIdRequiredError +} from '../../common/errors/review.errors.js'; +import { + ImageUploadResponseDto, ReviewCreateDto, - ReviewUpdateDto, + ReviewListResponseDto, ReviewResponseDto, - ImageUploadResponseDto, - ReviewListResponseDto + ReviewUpdateDto } from '../dto/review.dto.js'; // DTO 클래스 import +import reviewService from '../service/review.service.js'; class ReviewController { @@ -42,10 +47,13 @@ class ReviewController { async createReview(req, res, next) { try { // URL 파라미터에서 커미션 신청 ID(requestId)를 추출하고 BigInt로 변환 + if (!req.params.requestId) { + throw new RequestIdRequiredError(); // requestId가 누락된 경우 RequestIdRequiredError 반환 + } const requestId = BigInt(req.params.requestId); // 현재 로그인한 사용자 ID (BigInt 변환) - const userId = BigInt(req.user.id); + const userId = BigInt(req.user.id); // Authentication middleware ensures req.user.id exists // 요청 본문 데이터를 DTO 클래스로 구조화 const reviewDto = new ReviewCreateDto(req.body); @@ -77,6 +85,9 @@ class ReviewController { async updateReview(req, res, next) { try { // URL 파라미터에서 리뷰 ID를 추출하고 BigInt로 변환 + if (!req.params.reviewId) { + throw new ReviewIdRequiredError(); // reviewId가 누락된 경우 ReviewIdRequiredError 반환 + } const reviewId = BigInt(req.params.reviewId); // 현재 로그인한 사용자 ID (BigInt 변환) @@ -112,6 +123,9 @@ class ReviewController { async deleteReview(req, res, next) { try { // URL 파라미터에서 리뷰 ID를 추출하고 BigInt로 변환 + if (!req.params.reviewId) { + throw new ReviewIdRequiredError(); // reviewId가 누락된 경우 ReviewIdRequiredError 반환 + } const reviewId = BigInt(req.params.reviewId); // 현재 로그인한 사용자 ID (BigInt 변환) @@ -138,7 +152,10 @@ class ReviewController { */ async getReviewsByUserId(req, res, next) { try { - // URL 파라미터에서 사용자 ID 추출 + // URL 파라미터에서 사용자 ID를 추출하고 BigInt로 변환 + if (!req.params.userId) { + throw new UserIdRequiredError(); // userId가 누락된 경우 UserIdRequiredError 반환 + } const userId = BigInt(req.params.userId); // 쿼리 파라미터에서 페이지네이션 정보 추출 From 6bc7dc4f74592708df9b8145de8dfe0e6d909f29 Mon Sep 17 00:00:00 2001 From: modzivv Date: Fri, 1 Aug 2025 00:59:57 +0900 Subject: [PATCH 2/3] =?UTF-8?q?fix:=20=EB=A6=AC=EB=B7=B0=20=EC=BB=A8?= =?UTF-8?q?=ED=8A=B8=EB=A1=A4=EB=9F=AC=20userId=20=ED=95=84=EB=93=9C?= =?UTF-8?q?=EB=AA=85=20=EC=88=98=EC=A0=95=20#104?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/review/controller/review.controller.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/review/controller/review.controller.js b/src/review/controller/review.controller.js index 27c81bd..411dcf0 100644 --- a/src/review/controller/review.controller.js +++ b/src/review/controller/review.controller.js @@ -53,7 +53,7 @@ class ReviewController { const requestId = BigInt(req.params.requestId); // 현재 로그인한 사용자 ID (BigInt 변환) - const userId = BigInt(req.user.id); // Authentication middleware ensures req.user.id exists + const userId = BigInt(req.user.userId); // 요청 본문 데이터를 DTO 클래스로 구조화 const reviewDto = new ReviewCreateDto(req.body); @@ -91,7 +91,7 @@ class ReviewController { const reviewId = BigInt(req.params.reviewId); // 현재 로그인한 사용자 ID (BigInt 변환) - const userId = BigInt(req.user.id); + const userId = BigInt(req.user.userId); // 요청 본문 데이터를 DTO 클래스로 구조화 const reviewDto = new ReviewUpdateDto(req.body); @@ -129,7 +129,7 @@ class ReviewController { const reviewId = BigInt(req.params.reviewId); // 현재 로그인한 사용자 ID (BigInt 변환) - const userId = BigInt(req.user.id); + const userId = BigInt(req.user.userId); // 리뷰 삭제 서비스 호출 const result = await reviewService.deleteReview(reviewId, userId); From 2e68d04fd4cbc295273556ae6354bf183102fb37 Mon Sep 17 00:00:00 2001 From: modzivv Date: Fri, 1 Aug 2025 01:21:14 +0900 Subject: [PATCH 3/3] =?UTF-8?q?fix:=20=EC=95=8C=EB=A6=BC=20=EC=97=90?= =?UTF-8?q?=EB=9F=AC=20=EC=BD=94=EB=93=9C=20N013=20->=20N014=20=EB=B3=80?= =?UTF-8?q?=EA=B2=BD=20#104?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/common/errors/notification.errors.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common/errors/notification.errors.js b/src/common/errors/notification.errors.js index 85fe537..57e5e3c 100644 --- a/src/common/errors/notification.errors.js +++ b/src/common/errors/notification.errors.js @@ -136,7 +136,7 @@ export class NotificationIdRequiredError extends BaseError { export class TargetUserIdRequiredError extends BaseError { constructor(data = null) { super({ - errorCode: "N014", + errorCode: "N013", reason: "target_user_id가 필요합니다", statusCode: 400, data