Skip to content

Commit 2d2c7cb

Browse files
authored
fix : 삭제한 문제에 대한 알림 삭제 (#381)
1 parent 27dfbc3 commit 2d2c7cb

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

src/main/java/com/gamzabat/algohub/feature/notification/repository/NotificationRepository.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
import com.gamzabat.algohub.feature.group.studygroup.domain.StudyGroup;
1010
import com.gamzabat.algohub.feature.notification.domain.Notification;
11+
import com.gamzabat.algohub.feature.problem.domain.Problem;
1112
import com.gamzabat.algohub.feature.user.domain.User;
1213

1314
public interface NotificationRepository extends JpaRepository<Notification, Long> {
@@ -19,6 +20,10 @@ public interface NotificationRepository extends JpaRepository<Notification, Long
1920
@Query("delete from Notification n where n.studyGroup = :studyGroup")
2021
void deleteAllByStudyGroup(StudyGroup studyGroup);
2122

23+
@Modifying
24+
@Query("DELETE FROM Notification n WHERE n.problem = :problem")
25+
void deleteAllByProblem(Problem problem);
26+
2227
@Modifying
2328
@Query("DELETE FROM Notification n WHERE n.user = :user AND n.studyGroup = :studyGroup")
2429
void deleteAllByUserAndStudyGroup(User user, StudyGroup studyGroup);

src/main/java/com/gamzabat/algohub/feature/problem/service/ProblemService.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import com.gamzabat.algohub.feature.group.studygroup.repository.GroupMemberRepository;
3030
import com.gamzabat.algohub.feature.group.studygroup.repository.StudyGroupRepository;
3131
import com.gamzabat.algohub.feature.notification.enums.NotificationCategory;
32+
import com.gamzabat.algohub.feature.notification.repository.NotificationRepository;
3233
import com.gamzabat.algohub.feature.notification.service.NotificationService;
3334
import com.gamzabat.algohub.feature.problem.domain.Problem;
3435
import com.gamzabat.algohub.feature.problem.dto.CreateProblemRequest;
@@ -53,6 +54,7 @@ public class ProblemService {
5354
private final GroupMemberRepository groupMemberRepository;
5455
private final NotificationService notificationService;
5556
private final RestTemplate restTemplate;
57+
private final NotificationRepository notificationRepository;
5658

5759
@Transactional
5860
public void createProblem(User user, Long groupId, CreateProblemRequest request) {
@@ -212,6 +214,7 @@ public void deleteProblem(User user, Long problemId) {
212214

213215
solutionRepository.deleteAllByProblem(problem);
214216
problemRepository.delete(problem);
217+
notificationRepository.deleteAllByProblem(problem);
215218
log.info("success to delete problem user_id={} , problem_id = {}", user.getId(), problemId);
216219
}
217220

0 commit comments

Comments
 (0)