-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathReadNotificationService.java
More file actions
29 lines (24 loc) · 1.26 KB
/
ReadNotificationService.java
File metadata and controls
29 lines (24 loc) · 1.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
package clap.server.application.service.notification;
import clap.server.application.port.inbound.notification.UpdateNotificationUsecase;
import clap.server.application.port.outbound.notification.CommandNotificationPort;
import clap.server.application.port.outbound.notification.LoadNotificationPort;
import clap.server.common.annotation.architecture.ApplicationService;
import clap.server.domain.model.notification.Notification;
import clap.server.exception.ApplicationException;
import clap.server.exception.code.NotificationErrorCode;
import lombok.RequiredArgsConstructor;
import org.springframework.transaction.annotation.Transactional;
@ApplicationService
@RequiredArgsConstructor
public class ReadNotificationService implements UpdateNotificationUsecase {
private final LoadNotificationPort loadNotificationPort;
private final CommandNotificationPort commandNotificationPort;
@Transactional
@Override
public void updateNotification(Long notificationId) {
Notification notification = loadNotificationPort.findById(notificationId)
.orElseThrow(() -> new ApplicationException(NotificationErrorCode.NOTIFICATION_NOT_FOUND));
notification.updateNotificationIsRead();
commandNotificationPort.save(notification);
}
}