Skip to content

Commit

Permalink
refactor: 불필요한 이벤트 호출 제거
Browse files Browse the repository at this point in the history
  • Loading branch information
Ohjintaek committed Mar 27, 2024
1 parent ac71f6e commit 3a7e610
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import co.kirikiri.roadmap.persistence.RoadmapReviewRepository;
import co.kirikiri.roadmap.service.event.RoadmapDeleteEvent;
import lombok.RequiredArgsConstructor;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.context.event.EventListener;
import org.springframework.stereotype.Service;

Expand All @@ -12,15 +11,9 @@
public class RoadmapReviewDeleteEventListener {

private final RoadmapReviewRepository roadmapReviewRepository;
private final ApplicationEventPublisher applicationEventPublisher;

@EventListener(condition = "#roadmapDeleteEvent.target == 'Review'")
public void handleRoadmapReviewDelete(final RoadmapDeleteEvent roadmapDeleteEvent) {
deleteRoadmapReviews(roadmapDeleteEvent.roadmapId());
}

private void deleteRoadmapReviews(final Long roadmapId) {
roadmapReviewRepository.deleteAllByRoadmapId(roadmapId);
applicationEventPublisher.publishEvent(new RoadmapDeleteEvent(roadmapId, "Roadmap"));
roadmapReviewRepository.deleteAllByRoadmapId(roadmapDeleteEvent.roadmapId());
}
}
2 changes: 1 addition & 1 deletion backend/kirikiri/src/main/resources/properties

0 comments on commit 3a7e610

Please sign in to comment.