Skip to content

Commit c2ccfec

Browse files
authored
Merge pull request #112 from umc-commit/fix/111-userid-field
[FIX] Notification 컨트롤러 userId 참조 누락 수정
2 parents 684571c + d4f3f0c commit c2ccfec

File tree

3 files changed

+13
-13
lines changed

3 files changed

+13
-13
lines changed

src/notification/controller/notification.controller.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class NotificationController {
1818
async getNotifications(req, res, next) {
1919
try {
2020
// 현재 로그인한 사용자 ID
21-
const userId = BigInt(req.user.id);
21+
const userId = BigInt(req.user.userId);
2222

2323
// 쿼리 파라미터에서 페이지네이션 정보 추출
2424
const page = req.query.page || 1;
@@ -57,7 +57,7 @@ class NotificationController {
5757
const notificationId = BigInt(req.params.notificationId);
5858

5959
// 현재 로그인한 사용자 ID
60-
const userId = BigInt(req.user.id);
60+
const userId = BigInt(req.user.userId);
6161

6262
// 알림 읽음 처리 서비스 호출
6363
const result = await notificationService.markNotificationAsRead(notificationId, userId);
@@ -86,7 +86,7 @@ class NotificationController {
8686
async markAllNotificationsAsRead(req, res, next) {
8787
try {
8888
// 현재 로그인한 사용자 ID
89-
const userId = BigInt(req.user.id);
89+
const userId = BigInt(req.user.userId);
9090

9191
// 모든 알림 읽음 처리 서비스 호출
9292
const result = await notificationService.markAllNotificationsAsRead(userId);
@@ -113,7 +113,7 @@ class NotificationController {
113113
const { notification_ids } = req.body;
114114

115115
// 현재 로그인한 사용자 ID
116-
const userId = BigInt(req.user.id);
116+
const userId = BigInt(req.user.userId);
117117

118118
// 선택 알림 삭제 서비스 호출
119119
const result = await notificationService.deleteNotificationsByIds(notification_ids, userId);
@@ -140,7 +140,7 @@ class NotificationController {
140140
async deleteAllNotifications(req, res, next) {
141141
try {
142142
// 현재 로그인한 사용자 ID
143-
const userId = BigInt(req.user.id);
143+
const userId = BigInt(req.user.userId);
144144

145145
// 전체 알림 삭제 서비스 호출
146146
const result = await notificationService.deleteAllNotifications(userId);

src/notification/fcm/controller/push.controller.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class PushController {
2020
async registerPushToken(req, res, next) {
2121
try {
2222
// 현재 로그인한 사용자 ID
23-
const userId = BigInt(req.user.id);
23+
const userId = BigInt(req.user.userId);
2424

2525
// 요청 본문 데이터를 DTO로 구조화
2626
const tokenDto = new PushTokenRegisterDto(req.body);
@@ -52,7 +52,7 @@ class PushController {
5252
async deletePushToken(req, res, next) {
5353
try {
5454
// 현재 로그인한 사용자 ID
55-
const userId = BigInt(req.user.id);
55+
const userId = BigInt(req.user.userId);
5656

5757
// FCM 토큰 삭제 서비스 호출
5858
const result = await pushService.deletePushToken(userId);

src/notification/repository/notification.repository.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,15 @@ class NotificationRepository {
1515

1616
// 알림 목록 조회 (최신순)
1717
const notifications = await prisma.notification.findMany({
18-
where: { userId: BigInt(userId) },
18+
where: { userId: userId },
1919
orderBy: { createdAt: 'desc' }, // 최신순 정렬
2020
skip: offset,
2121
take: limit
2222
});
2323

2424
// 전체 개수 조회 (페이지네이션 정보 계산용)
2525
const total = await prisma.notification.count({
26-
where: { userId: BigInt(userId) }
26+
where: { userId: userId }
2727
});
2828

2929
return { items: notifications, total };
@@ -71,7 +71,7 @@ class NotificationRepository {
7171
async markAllNotificationsAsRead(userId) {
7272
return await prisma.notification.updateMany({
7373
where: {
74-
userId: BigInt(userId),
74+
userId: userId,
7575
isRead: false
7676
},
7777
data: {
@@ -93,7 +93,7 @@ class NotificationRepository {
9393
return await prisma.notification.deleteMany({
9494
where: {
9595
id: { in: bigIntIds },
96-
userId: BigInt(userId) // 본인의 알림만 삭제 가능
96+
userId: userId // 본인의 알림만 삭제 가능
9797
}
9898
});
9999
}
@@ -105,7 +105,7 @@ class NotificationRepository {
105105
*/
106106
async deleteAllNotificationsByUserId(userId) {
107107
return await prisma.notification.deleteMany({
108-
where: { userId: BigInt(userId) }
108+
where: { userId: userId }
109109
});
110110
}
111111

@@ -116,7 +116,7 @@ class NotificationRepository {
116116
*/
117117
async findUserById(userId) {
118118
return await prisma.user.findUnique({
119-
where: { id: BigInt(userId) },
119+
where: { id: userId },
120120
select: {
121121
id: true,
122122
nickname: true

0 commit comments

Comments
 (0)