Skip to content

Commit 3151210

Browse files
committed
CLAP-278 Fix : Notification entity taskTitle 컬럼 추가
1 parent e176c0a commit 3151210

File tree

10 files changed

+53
-40
lines changed

10 files changed

+53
-40
lines changed

src/main/java/clap/server/adapter/outbound/api/dto/PushNotificationTemplate.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
public record PushNotificationTemplate(
66

7-
Long taskId,
87
String email,
98
NotificationType notificationType,
109
String taskName,

src/main/java/clap/server/adapter/outbound/persistense/entity/notification/NotificationEntity.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ public class NotificationEntity extends BaseTimeEntity {
3737
@Column(nullable = true)
3838
private String message;
3939

40+
@Column(nullable = false)
41+
private String taskTitle;
42+
4043
@Column(nullable = false)
4144
private boolean isRead;
4245
}

src/main/java/clap/server/application/service/history/PostCommentService.java

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,14 @@ public void save(Long userId, Long taskId, CreateCommentRequest request) {
5151
TaskHistory taskHistory = TaskHistory.createTaskHistory(TaskHistoryType.COMMENT, task, null, member, savedComment);
5252
commandTaskHistoryPort.save(taskHistory);
5353

54+
String taskTitle = task.getTitle();
55+
Member receiver;
5456
if (member.getMemberInfo().getRole() == MemberRole.ROLE_USER) {
55-
publishNotification(task.getProcessor(), task, comment.getContent(), member.getNickname());
57+
receiver = task.getProcessor();
58+
publishNotification(receiver, task, request.content(), member.getNickname(), taskTitle, receiver.getMemberInfo().getEmail());
5659
} else {
57-
publishNotification(task.getRequester(), task, comment.getContent(), task.getProcessor().getNickname());
60+
receiver = task.getRequester();
61+
publishNotification(receiver, task, request.content(), receiver.getNickname(), taskTitle, receiver.getMemberInfo().getEmail());
5862
}
5963
}
6064
}
@@ -74,9 +78,11 @@ public void saveCommentAttachment(Long userId, Long taskId, MultipartFile file)
7478
commandTaskHistoryPort.save(taskHistory);
7579

7680
if (member.getMemberInfo().getRole() == MemberRole.ROLE_USER) {
77-
publishNotification(task.getProcessor(), task, fileName + "(첨부파일)", member.getNickname());
81+
Member receiver = task.getProcessor();
82+
publishNotification(receiver, task, fileName + "(첨부파일)", member.getNickname(), task.getTitle(), receiver.getMemberInfo().getEmail());
7883
} else {
79-
publishNotification(task.getRequester(), task, fileName + "(첨부파일)", task.getProcessor().getNickname());
84+
Member receiver = task.getRequester();
85+
publishNotification(receiver, task, fileName + "(첨부파일)", task.getProcessor().getNickname(), task.getTitle(), receiver.getMemberInfo().getEmail());
8086
}
8187
}
8288
}
@@ -88,8 +94,8 @@ private String saveAttachment(MultipartFile file, Task task, Comment comment) {
8894
return file.getOriginalFilename();
8995
}
9096

91-
private void publishNotification(Member receiver, Task task, String message, String commenterName) {
92-
sendNotificationService.sendPushNotification(receiver, NotificationType.COMMENT, task, message, commenterName);
97+
private void publishNotification(Member receiver, Task task, String message, String commenterName, String taskTitle, String email) {
98+
sendNotificationService.sendPushNotification(receiver, email, NotificationType.COMMENT, task, taskTitle, message, commenterName);
9399
}
94100

95101
}

src/main/java/clap/server/application/service/task/ApprovalTaskService.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@ public ApprovalTaskResponse approvalTaskByReviewer(Long reviewerId, Long taskId,
5757
commandTaskHistoryPort.save(taskHistory);
5858

5959
List<Member> receivers = List.of(reviewer, processor);
60-
publishNotification(receivers, task);
60+
String processorName = task.getProcessor().getNickname();
61+
publishNotification(receivers, task, task.getTitle(), processorName);
6162

6263
return TaskResponseMapper.toApprovalTaskResponse(taskService.upsert(task));
6364
}
@@ -70,13 +71,13 @@ public FindApprovalFormResponse findApprovalForm(Long managerId, Long taskId) {
7071
return TaskResponseMapper.toFindApprovalFormResponse(task);
7172
}
7273

73-
private void publishNotification(List<Member> receivers, Task task){
74+
private void publishNotification(List<Member> receivers, Task task, String taskTitle, String processorName){
7475
receivers.forEach(receiver -> {
75-
sendNotificationService.sendPushNotification(receiver, NotificationType.PROCESSOR_ASSIGNED,
76-
task, task.getProcessor().getNickname(), null);
76+
sendNotificationService.sendPushNotification(receiver, receiver.getMemberInfo().getEmail(), NotificationType.PROCESSOR_ASSIGNED,
77+
task, taskTitle, processorName, null);
7778
});
7879
sendNotificationService.sendAgitNotification(NotificationType.PROCESSOR_CHANGED,
79-
task, task.getProcessor().getNickname(), null);
80+
task, taskTitle, processorName, null);
8081
}
8182

8283
}

src/main/java/clap/server/application/service/task/CreateTaskService.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public CreateTaskResponse createTask(Long requesterId, CreateTaskRequest createT
4949

5050
if (files != null) {
5151
saveAttachments(files, savedTask);}
52-
publishNotification(savedTask);
52+
publishNotification(savedTask, savedTask.getTitle());
5353
return TaskResponseMapper.toCreateTaskResponse(savedTask);
5454
}
5555

@@ -59,12 +59,12 @@ private void saveAttachments(List<MultipartFile> files, Task task) {
5959
commandAttachmentPort.saveAll(attachments);
6060
}
6161

62-
private void publishNotification(Task task) {
62+
private void publishNotification(Task task, String taskTitle) {
6363
List<Member> reviewers = memberService.findReviewers();
64-
reviewers.forEach(reviewer -> {sendNotificationService.sendPushNotification(reviewer, NotificationType.TASK_REQUESTED,
65-
task, null, null);});
64+
reviewers.forEach(reviewer -> {sendNotificationService.sendPushNotification(reviewer, reviewer.getMemberInfo().getNickname(), NotificationType.TASK_REQUESTED,
65+
task, taskTitle, null, null);});
6666

6767
sendNotificationService.sendAgitNotification(NotificationType.TASK_REQUESTED,
68-
task, null, null);
68+
task, taskTitle, null, null);
6969
}
7070
}

src/main/java/clap/server/application/service/task/UpdateTaskBoardService.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -181,14 +181,14 @@ public void validateRequest(UpdateTaskOrderRequest request, TaskStatus targetSta
181181
}
182182
}
183183

184-
private void publishNotification(Task task, NotificationType notificationType, String message) {
184+
private void publishNotification(Task task, NotificationType notificationType, String message, String taskTitle) {
185185
List<Member> receivers = List.of(task.getRequester(), task.getProcessor());
186186
receivers.forEach(receiver -> {
187-
sendNotificationService.sendPushNotification(receiver, notificationType,
188-
task, message, null);
187+
sendNotificationService.sendPushNotification(receiver, receiver.getMemberInfo().getNickname(), notificationType,
188+
task, taskTitle, message, null);
189189
});
190190
sendNotificationService.sendAgitNotification(notificationType,
191-
task, message, null);
191+
task, message, taskTitle, null);
192192
}
193193

194194
}

src/main/java/clap/server/application/service/task/UpdateTaskService.java

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ public class UpdateTaskService implements UpdateTaskUsecase, UpdateTaskStatusUse
5656
private final CommandAttachmentPort commandAttachmentPort;
5757
private final CommandTaskHistoryPort commandTaskHistoryPort;
5858
private final S3UploadPort s3UploadPort;
59-
private final ObjectMapper objectMapper;
6059

6160
@Override
6261
@Transactional
@@ -89,7 +88,9 @@ public void updateTaskStatus(Long memberId, Long taskId, TaskStatus taskStatus)
8988
Task updateTask = taskService.upsert(task);
9089
TaskHistory taskHistory = TaskHistory.createTaskHistory(TaskHistoryType.STATUS_SWITCHED, task, taskStatus.getDescription(), null,null);
9190
commandTaskHistoryPort.save(taskHistory);
92-
publishNotification(updateTask, NotificationType.STATUS_SWITCHED, String.valueOf(updateTask.getTaskStatus()));
91+
92+
String taskTitle = task.getTitle();
93+
publishNotification(updateTask, NotificationType.STATUS_SWITCHED, String.valueOf(updateTask.getTaskStatus()), taskTitle);
9394
}
9495
}
9596

@@ -106,7 +107,8 @@ public void updateTaskProcessor(Long taskId, Long userId, UpdateTaskProcessorReq
106107
TaskHistory taskHistory = TaskHistory.createTaskHistory(TaskHistoryType.PROCESSOR_CHANGED, task, null, processor,null);
107108
commandTaskHistoryPort.save(taskHistory);
108109

109-
publishNotification(updateTask, NotificationType.PROCESSOR_CHANGED, updateTask.getProcessor().getNickname());
110+
String taskTitle = task.getTitle();
111+
publishNotification(updateTask, NotificationType.PROCESSOR_CHANGED, updateTask.getProcessor().getNickname(), taskTitle);
110112
}
111113

112114
@Transactional
@@ -140,13 +142,13 @@ private List<Attachment> validateAndGetAttachments(List<Long> attachmentIdsToDel
140142
return attachmentsOfTask;
141143
}
142144

143-
private void publishNotification(Task task, NotificationType notificationType, String message) {
145+
private void publishNotification(Task task, NotificationType notificationType, String message, String taskTitle) {
144146
List<Member> receivers = List.of(task.getRequester(), task.getProcessor());
145147
receivers.forEach(receiver -> {
146-
sendNotificationService.sendPushNotification(receiver, notificationType,
147-
task, message, null);
148+
sendNotificationService.sendPushNotification(receiver, receiver.getMemberInfo().getEmail(), notificationType,
149+
task, taskTitle, message, null);
148150
});
149151

150-
sendNotificationService.sendAgitNotification(notificationType, task, message, null);
152+
sendNotificationService.sendAgitNotification(notificationType, task, taskTitle, message, null);
151153
}
152154
}

src/main/java/clap/server/application/service/webhook/SendNotificationService.java

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,23 +25,21 @@ public class SendNotificationService {
2525
private final CommandNotificationPort commandNotificationPort;
2626

2727
@Async("notificationExecutor")
28-
public void sendPushNotification(Member receiver, NotificationType notificationType,
29-
Task task, String message, String commenterName) {
30-
String email = receiver.getMemberInfo().getEmail();
31-
String taskTitle = task.getTitle();
28+
public void sendPushNotification(Member receiver, String email, NotificationType notificationType,
29+
Task task, String taskTitle, String message, String commenterName) {
3230
String requesterNickname = task.getRequester().getNickname();
3331

34-
Notification notification = createTaskNotification(task, receiver, notificationType, message);
32+
Notification notification = createTaskNotification(task, receiver, notificationType, message, taskTitle);
3533

3634
SseRequest sseRequest = new SseRequest(
37-
task.getTitle(),
35+
taskTitle,
3836
notificationType,
3937
receiver.getMemberId(),
4038
message
4139
);
4240

4341
PushNotificationTemplate pushNotificationTemplate = new PushNotificationTemplate(
44-
task.getTaskId(), email, notificationType, taskTitle, requesterNickname, message, commenterName
42+
email, notificationType, taskTitle, requesterNickname, message, commenterName
4543
);
4644

4745
CompletableFuture<Void> saveNotification = CompletableFuture.runAsync(() -> {
@@ -71,12 +69,11 @@ public void sendPushNotification(Member receiver, NotificationType notificationT
7169

7270
@Async("notificationExecutor")
7371
public void sendAgitNotification(NotificationType notificationType,
74-
Task task, String message, String commenterName) {
72+
Task task, String taskTitle, String message, String commenterName) {
7573
PushNotificationTemplate pushNotificationTemplate = new PushNotificationTemplate(
76-
task.getTaskId(),
7774
null,
7875
notificationType,
79-
task.getTitle(),
76+
taskTitle,
8077
task.getRequester().getNickname(),
8178
message,
8279
commenterName

src/main/java/clap/server/domain/model/notification/Notification.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,27 +24,30 @@ public class Notification extends BaseTime {
2424
private NotificationType type;
2525
private Member receiver;
2626
private String message;
27+
private String taskTitle;
2728
private boolean isRead;
2829

2930
@Builder
30-
public Notification(Task task, NotificationType type, Member receiver, String message) {
31+
public Notification(Task task, NotificationType type, Member receiver, String message, String taskTitle) {
3132
this.task = task;
3233
this.type = type;
3334
this.receiver = receiver;
3435
this.message = message;
36+
this.taskTitle = taskTitle;
3537
this.isRead = false;
3638
}
3739

3840
public void updateNotificationIsRead() {
3941
this.isRead = true;
4042
}
4143

42-
public static Notification createTaskNotification(Task task, Member reviewer, NotificationType type, String message) {
44+
public static Notification createTaskNotification(Task task, Member reviewer, NotificationType type, String message, String taskTitle) {
4345
return Notification.builder()
4446
.task(task)
4547
.type(type)
4648
.receiver(reviewer)
4749
.message(message)
50+
.taskTitle(taskTitle)
4851
.build();
4952
}
5053
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
alter table notification
2+
add task_title VARCHAR(20) not null;

0 commit comments

Comments
 (0)