-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathNotificationPersistenceAdapter.java
More file actions
34 lines (28 loc) · 1.61 KB
/
NotificationPersistenceAdapter.java
File metadata and controls
34 lines (28 loc) · 1.61 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
30
31
32
33
34
package clap.server.adapter.outbound.persistense;
import clap.server.adapter.inbound.web.dto.notification.FindNotificationListResponse;
import clap.server.adapter.outbound.persistense.mapper.NotificationPersistenceMapper;
import clap.server.adapter.outbound.persistense.repository.notification.NotificationRepository;
import clap.server.application.mapper.NotificationMapper;
import clap.server.application.port.outbound.notification.CommandNotificationPort;
import clap.server.application.port.outbound.notification.LoadNotificationPort;
import clap.server.common.annotation.architecture.PersistenceAdapter;
import clap.server.domain.model.notification.Notification;
import lombok.RequiredArgsConstructor;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
@PersistenceAdapter
@RequiredArgsConstructor
public class NotificationPersistenceAdapter implements LoadNotificationPort, CommandNotificationPort {
private final NotificationRepository notificationRepository;
private final NotificationPersistenceMapper notificationPersistenceMapper;
@Override
public Page<FindNotificationListResponse> findAllByReceiverId(Long receiverId, Pageable pageable) {
Page<Notification> notificationList = notificationRepository.findAllByReceiver_MemberId(receiverId, pageable)
.map(notificationPersistenceMapper::toDomain);
return notificationList.map(NotificationMapper::toFindNoticeListResponse);
}
@Override
public void save(Notification notification) {
notificationRepository.save(notificationPersistenceMapper.toEntity(notification));
}
}