|
1 | 1 | package com.grepp.teamnotfound.app.model.notification; |
2 | 2 |
|
| 3 | +import com.grepp.teamnotfound.app.model.board.entity.Article; |
| 4 | +import com.grepp.teamnotfound.app.model.board.repository.ArticleRepository; |
3 | 5 | import com.grepp.teamnotfound.app.model.notification.code.NotiTarget; |
4 | 6 | import com.grepp.teamnotfound.app.model.notification.code.NotiType; |
5 | 7 | import com.grepp.teamnotfound.app.model.notification.dto.NotiReadDto; |
|
11 | 13 | import com.grepp.teamnotfound.app.model.notification.repository.NotiManagementRepository; |
12 | 14 | import com.grepp.teamnotfound.app.model.notification.repository.ScheduleNotiRepository; |
13 | 15 | import com.grepp.teamnotfound.app.model.notification.repository.ServiceNotiRepository; |
14 | | -import com.grepp.teamnotfound.app.model.schedule.repository.ScheduleRepository; |
15 | 16 | import com.grepp.teamnotfound.app.model.user.entity.User; |
16 | 17 | import com.grepp.teamnotfound.app.model.user.repository.UserRepository; |
17 | 18 | import com.grepp.teamnotfound.infra.error.exception.BusinessException; |
@@ -40,7 +41,7 @@ public class NotificationService { |
40 | 41 | private final NotiManagementRepository notiManagementRepository; |
41 | 42 | private final ScheduleNotiRepository scheduleNotiRepository; |
42 | 43 | private final ServiceNotiRepository serviceNotiRepository; |
43 | | - private final ScheduleRepository scheduleRepository; |
| 44 | + private final ArticleRepository articleRepository; |
44 | 45 |
|
45 | 46 | ModelMapper modelMapper = new ModelMapper(); |
46 | 47 |
|
@@ -71,11 +72,17 @@ public List<NotiUserDto> getUserNoti(Long userId) { |
71 | 72 |
|
72 | 73 | List<ServiceNoti> serviceNotis = serviceNotiRepository.getAllNoti(user.getUserId(), monthBefore); |
73 | 74 | for (ServiceNoti sn : serviceNotis) { |
| 75 | + Article article = null; |
| 76 | + if (sn.getTargetId() != null) { |
| 77 | + article = articleRepository.findById(sn.getTargetId()).orElse(null); |
| 78 | + } |
| 79 | + |
74 | 80 | result.add(NotiUserDto.builder() |
75 | 81 | .notiId(sn.getServiceNotiId()) |
76 | 82 | .content(sn.getContent()) |
77 | 83 | .type(sn.getNotificationType()) |
78 | 84 | .targetId(sn.getTargetId()) |
| 85 | + .boardType(article != null ? article.getBoard().getName() : null) |
79 | 86 | .isRead(sn.getIsRead()) |
80 | 87 | .createdAt(sn.getCreatedAt()) |
81 | 88 | .build()); |
|
0 commit comments