Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,26 @@ int markAsReadByIdAndUserId(
@Param("readAt") LocalDateTime readAt
);

@Modifying(clearAutomatically = true, flushAutomatically = true)
@Query("""
update Notification n
set n.isRead = true,
n.readAt = :readAt
where n.user.id = :userId
and n.type = :type
and n.targetType = :targetType
and n.targetId = :videoId
and n.isRead = false
and n.deletedAt is null
""")
Comment thread
young0206 marked this conversation as resolved.
Outdated
int markVideoFeedbackNotificationsAsRead(
@Param("userId") Long userId,
@Param("type") NotificationType type,
@Param("targetType") String targetType,
@Param("videoId") Long videoId,
@Param("readAt") LocalDateTime readAt
);

// 동일 대상의 미읽음 그룹 알림을 잠금 조회해 누적 개수와 문구를 같은 엔티티 상태 기준으로 갱신한다.
@Lock(LockModeType.PESSIMISTIC_WRITE)
@Query("""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,20 @@ public void markAllNotificationsAsRead(Long currentUserId) {
notificationRepository.markAllAsReadByUserId(currentUserId, LocalDateTime.now());
}

@Transactional
public void markVideoFeedbackNotificationsAsRead(Long userId, Long videoId) {
validateActiveUser(userId);
validateRequiredId(videoId);

notificationRepository.markVideoFeedbackNotificationsAsRead(
userId,
NotificationType.VIDEO_FEEDBACK_COMMENTED,
NotificationTargetType.VIDEO.name(),
videoId,
LocalDateTime.now()
);
}

/**
* 영상 목록의 미읽은 피드백 누적 개수를 한 번에 조회한다.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ public class VideoService {
private final YoutubeUrlParser youtubeUrlParser;
private final YoutubeApiClient youtubeApiClient;

@Transactional
public VideoDetailResDTO getVideo(Long memberId, Long projectId, Long videoId) {
if (!projectAccessRepository.projectExistsById(projectId)) {
throw new BaseException(CommonErrorCode.NOT_FOUND);
Expand All @@ -75,6 +76,8 @@ public VideoDetailResDTO getVideo(Long memberId, Long projectId, Long videoId) {
projectAccessRepository.findProjectRoleNames(projectId)
);

notificationService.markVideoFeedbackNotificationsAsRead(memberId, videoId);

return VideoDetailResDTO.from(video, bookmarked, projectTags);
}

Expand Down
Loading