Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions src/common/errors/notification.errors.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: "N013",
reason: "target_user_id가 필요합니다",
statusCode: 400,
data
});
}
}
55 changes: 44 additions & 11 deletions src/common/errors/review.errors.js
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down Expand Up @@ -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,
});
}
}
13 changes: 9 additions & 4 deletions src/notification/controller/notification.controller.js
Original file line number Diff line number Diff line change
@@ -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 {

Expand Down Expand Up @@ -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
Expand Down
10 changes: 8 additions & 2 deletions src/notification/fcm/controller/push.controller.js
Original file line number Diff line number Diff line change
@@ -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';

Expand Down Expand Up @@ -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 발송 서비스 호출
Expand Down
33 changes: 25 additions & 8 deletions src/review/controller/review.controller.js
Original file line number Diff line number Diff line change
@@ -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 {

Expand Down Expand Up @@ -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.userId);

// 요청 본문 데이터를 DTO 클래스로 구조화
const reviewDto = new ReviewCreateDto(req.body);
Expand Down Expand Up @@ -77,10 +85,13 @@ 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 변환)
const userId = BigInt(req.user.id);
const userId = BigInt(req.user.userId);

// 요청 본문 데이터를 DTO 클래스로 구조화
const reviewDto = new ReviewUpdateDto(req.body);
Expand Down Expand Up @@ -112,10 +123,13 @@ 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 변환)
const userId = BigInt(req.user.id);
const userId = BigInt(req.user.userId);

// 리뷰 삭제 서비스 호출
const result = await reviewService.deleteReview(reviewId, userId);
Expand All @@ -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);

// 쿼리 파라미터에서 페이지네이션 정보 추출
Expand Down