Skip to content

Commit

Permalink
feat: 동의 처리된 알림 동의 내역 생성 로직 추가(#66)
Browse files Browse the repository at this point in the history
  • Loading branch information
Minjae-An committed May 10, 2024
1 parent 4299ef7 commit c6d7ec2
Showing 1 changed file with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package yeonba.be.notification.service;

import java.util.Arrays;
import java.util.List;
import java.util.Optional;
import lombok.RequiredArgsConstructor;
import org.springframework.data.domain.Page;
Expand All @@ -16,6 +18,7 @@
import yeonba.be.notification.enums.NotificationType;
import yeonba.be.notification.event.NotificationSendEvent;
import yeonba.be.notification.repository.NotificationCommand;
import yeonba.be.notification.repository.NotificationPermissionCommand;
import yeonba.be.notification.repository.NotificationPermissionQuery;
import yeonba.be.notification.repository.NotificationQuery;
import yeonba.be.user.entity.User;
Expand All @@ -26,10 +29,12 @@
public class NotificationService {

private final UserQuery userQuery;
private final NotificationCommand notificationCommand;
private final NotificationQuery notificationQuery;
private final NotificationPermissionQuery notificationPermissionQuery;

private final NotificationCommand notificationCommand;
private final NotificationPermissionCommand notificationPermissionCommand;

@Transactional
public NotificationPageResponse getRecentlyReceivedNotificationsBy(
long receiverId, NotificationPageRequest request) {
Expand Down Expand Up @@ -67,6 +72,15 @@ public void saveNotification(NotificationSendEvent sendEvent) {
notificationCommand.save(notification);
}

public void saveAllowedNotificationPermissions(User user) {

List<NotificationPermission> notificationPermissions =
Arrays.stream(NotificationType.values())
.map(type -> new NotificationPermission(type, user))
.toList();
notificationPermissionCommand.saveAll(notificationPermissions);
}

@Transactional(readOnly = true)
public NotificationUnreadExistResponse isUnreadNotificationExist(long receiverId) {

Expand Down

0 comments on commit c6d7ec2

Please sign in to comment.