Skip to content

Commit 20fa0dc

Browse files
committed
CLAP-136 Fix: ErrorCode 생성 및 Class 명 수정
1 parent 47082c4 commit 20fa0dc

File tree

2 files changed

+22
-6
lines changed

2 files changed

+22
-6
lines changed

src/main/java/clap/server/application/service/notification/UpdateNotificationService.java renamed to src/main/java/clap/server/application/service/notification/ReadNotificationService.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,18 @@
11
package clap.server.application.service.notification;
22

3-
import clap.server.adapter.outbound.persistense.entity.notification.NotificationEntity;
4-
import clap.server.adapter.outbound.persistense.repository.notification.NotificationRepository;
53
import clap.server.application.port.inbound.notification.UpdateNotificationUsecase;
64
import clap.server.application.port.outbound.notification.CommandNotificationPort;
75
import clap.server.application.port.outbound.notification.LoadNotificationPort;
86
import clap.server.common.annotation.architecture.ApplicationService;
97
import clap.server.domain.model.notification.Notification;
8+
import clap.server.exception.ApplicationException;
9+
import clap.server.exception.code.NotificationErrorCode;
1010
import lombok.RequiredArgsConstructor;
1111
import org.springframework.transaction.annotation.Transactional;
1212

13-
import java.util.Optional;
14-
1513
@ApplicationService
1614
@RequiredArgsConstructor
17-
public class UpdateNotificationService implements UpdateNotificationUsecase {
15+
public class ReadNotificationService implements UpdateNotificationUsecase {
1816

1917
private final LoadNotificationPort loadNotificationPort;
2018
private final CommandNotificationPort commandNotificationPort;
@@ -23,7 +21,8 @@ public class UpdateNotificationService implements UpdateNotificationUsecase {
2321
@Transactional
2422
@Override
2523
public void updateNotification(Long notificationId) {
26-
Notification notification = loadNotificationPort.findById(notificationId).get();
24+
Notification notification = loadNotificationPort.findById(notificationId)
25+
.orElseThrow(() -> new ApplicationException(NotificationErrorCode.NOTIFICATION_NOT_FOUND));
2726
notification.updateNotificationIsRead();
2827
commandNotificationPort.save(notification);
2928
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package clap.server.exception.code;
2+
3+
import lombok.Getter;
4+
import lombok.RequiredArgsConstructor;
5+
import org.springframework.http.HttpStatus;
6+
7+
@Getter
8+
@RequiredArgsConstructor
9+
public enum NotificationErrorCode implements BaseErrorCode {
10+
11+
NOTIFICATION_NOT_FOUND(HttpStatus.NOT_FOUND, "NOTIFICATION_001", "알림을 찾을 수 없습니다"),
12+
;
13+
14+
private final HttpStatus httpStatus;
15+
private final String customCode;
16+
private final String message;
17+
}

0 commit comments

Comments
 (0)