Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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 @@ -8,6 +8,7 @@

import com.gamzabat.algohub.feature.group.studygroup.domain.StudyGroup;
import com.gamzabat.algohub.feature.notification.domain.Notification;
import com.gamzabat.algohub.feature.problem.domain.Problem;
import com.gamzabat.algohub.feature.user.domain.User;

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

@Modifying
@Query("DELETE FROM Notification n WHERE n.problem = :problem")
void deleteAllByProblem(Problem problem);

@Modifying
@Query("DELETE FROM Notification n WHERE n.user = :user AND n.studyGroup = :studyGroup")
void deleteAllByUserAndStudyGroup(User user, StudyGroup studyGroup);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import com.gamzabat.algohub.feature.group.studygroup.repository.GroupMemberRepository;
import com.gamzabat.algohub.feature.group.studygroup.repository.StudyGroupRepository;
import com.gamzabat.algohub.feature.notification.enums.NotificationCategory;
import com.gamzabat.algohub.feature.notification.repository.NotificationRepository;
import com.gamzabat.algohub.feature.notification.service.NotificationService;
import com.gamzabat.algohub.feature.problem.domain.Problem;
import com.gamzabat.algohub.feature.problem.dto.CreateProblemRequest;
Expand All @@ -53,6 +54,7 @@ public class ProblemService {
private final GroupMemberRepository groupMemberRepository;
private final NotificationService notificationService;
private final RestTemplate restTemplate;
private final NotificationRepository notificationRepository;

@Transactional
public void createProblem(User user, Long groupId, CreateProblemRequest request) {
Expand Down Expand Up @@ -212,6 +214,7 @@ public void deleteProblem(User user, Long problemId) {

solutionRepository.deleteAllByProblem(problem);
problemRepository.delete(problem);
notificationRepository.deleteAllByProblem(problem);
log.info("success to delete problem user_id={} , problem_id = {}", user.getId(), problemId);
}

Expand Down
Loading