File tree Expand file tree Collapse file tree
src/main/java/clap/server
adapter/outbound/persistense
port/outbound/notification Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -42,6 +42,13 @@ public List<Notification> findNotificationsByMemberId(final Long memberId) {
4242 .collect (Collectors .toList ());
4343 }
4444
45+ @ Override
46+ public List <Notification > findNotificationsByTaskId (Long taskId ) {
47+ return notificationRepository .findByTask_TaskId (taskId )
48+ .stream ().map (notificationPersistenceMapper ::toDomain )
49+ .collect (Collectors .toList ());
50+ }
51+
4552 @ Override
4653 public Integer countNotification (final Long memberId ) {
4754 return notificationRepository .countByIsReadFalseAndReceiver_MemberId (memberId );
@@ -51,4 +58,9 @@ public Integer countNotification(final Long memberId) {
5158 public void save (final Notification notification ) {
5259 notificationRepository .save (notificationPersistenceMapper .toEntity (notification ));
5360 }
61+
62+ @ Override
63+ public void delete (Notification notification ) {
64+ notificationRepository .delete (notificationPersistenceMapper .toEntity (notification ));
65+ }
5466}
Original file line number Diff line number Diff line change @@ -27,5 +27,7 @@ Slice<NotificationEntity> findAllByReceiver_MemberIdOrderByCreatedAtDesc(
2727 "AND n.task.isDeleted = false" )
2828 List <NotificationEntity > findAllByReceiver_MemberId (Long memberId );
2929
30+ List <NotificationEntity > findByTask_TaskId (Long taskId );
31+
3032 Integer countByIsReadFalseAndReceiver_MemberId (Long memberId );
3133}
Original file line number Diff line number Diff line change 55
66public interface CommandNotificationPort {
77 void save (Notification notification );
8+
9+ void delete (Notification notification );
810}
Original file line number Diff line number Diff line change @@ -16,5 +16,7 @@ public interface LoadNotificationPort {
1616
1717 List <Notification > findNotificationsByMemberId (Long memberId );
1818
19+ List <Notification > findNotificationsByTaskId (Long taskId );
20+
1921 Integer countNotification (Long memberId );
2022}
Original file line number Diff line number Diff line change 22
33import clap .server .application .port .inbound .domain .TaskService ;
44import clap .server .application .port .inbound .task .CancelTaskUsecase ;
5+ import clap .server .application .port .outbound .notification .CommandNotificationPort ;
6+ import clap .server .application .port .outbound .notification .LoadNotificationPort ;
57import clap .server .common .annotation .architecture .ApplicationService ;
8+ import clap .server .domain .model .notification .Notification ;
69import clap .server .domain .model .task .Task ;
710import lombok .RequiredArgsConstructor ;
811import org .springframework .transaction .annotation .Transactional ;
912
10- import java .util .Objects ;
13+ import java .util .List ;
1114
1215
1316@ ApplicationService
1417@ RequiredArgsConstructor
1518@ Transactional
1619public class CancelTaskService implements CancelTaskUsecase {
1720 private final TaskService taskService ;
21+ private final LoadNotificationPort loadNotificationPort ;
22+ private final CommandNotificationPort commandNotificationPort ;
1823
1924 @ Override
2025 public void cancleTask (Long taskId , Long memberId ) {
2126 Task task = taskService .findById (taskId );
27+ deleteNotification (task .getTaskId ());
2228 task .cancelTask (memberId );
2329 taskService .upsert (task );
2430 }
31+
32+ private void deleteNotification (Long taskId ) {
33+ List <Notification > notificationList = loadNotificationPort .findNotificationsByTaskId (taskId );
34+
35+ notificationList .forEach (commandNotificationPort ::delete );
36+ }
37+
2538}
You can’t perform that action at this time.
0 commit comments