Skip to content

Commit

Permalink
feat/#294 : 회원탈퇴시 notification도 삭제되게 설정
Browse files Browse the repository at this point in the history
  • Loading branch information
LJH098 committed Jun 5, 2024
1 parent 07de2be commit 6ec4abb
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
import com.gaebaljip.exceed.common.event.DeleteMemberEvent;
import com.gaebaljip.exceed.food.adapter.out.FoodEntity;
import com.gaebaljip.exceed.food.application.port.out.FoodPort;
import com.gaebaljip.exceed.infrastructure.sse.adapter.out.NotifyEntity;
import com.gaebaljip.exceed.infrastructure.sse.application.port.out.NotifyPort;
import com.gaebaljip.exceed.meal.adapter.out.MealEntity;
import com.gaebaljip.exceed.meal.adapter.out.MealFoodEntity;
import com.gaebaljip.exceed.meal.application.port.out.MealFoodPort;
Expand All @@ -26,6 +28,7 @@ public class DeleteMemberEventListener {
private final FoodPort foodPort;
private final MealPort mealPort;
private final MealFoodPort mealFoodPort;
private final NotifyPort notifyPort;

@EventListener(classes = DeleteMemberEvent.class)
@Transactional
Expand All @@ -34,6 +37,12 @@ public void handle(DeleteMemberEvent event) {
mealPort.deleteByAllByIdInQuery(findMIdsByMemberEntity(event.getMemberEntity()));
foodPort.deleteByAllByIdInQuery(findFIdsByMemberEntity(event.getMemberEntity()));
historyPort.deleteByAllByIdInQuery(findHIdsByMemberEntity(event.getMemberEntity()));
notifyPort.deleteByAllByIdInQuery(findNIdsByMemberEntity(event.getMemberEntity()));
}

private List<Long> findNIdsByMemberEntity(MemberEntity memberEntity) {
List<NotifyEntity> notifyEntities = notifyPort.findByMemberEntity(memberEntity);
return notifyEntities.stream().map(NotifyEntity::getId).toList();
}

private List<Long> findMfIdsByMemberEntity(MemberEntity memberEntity) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import java.time.LocalDateTime;
import java.util.Optional;

import com.gaebaljip.exceed.common.annotation.Timer;
import org.springframework.stereotype.Component;

import com.gaebaljip.exceed.auth.exception.MemberNotCheckedException;
Expand Down

0 comments on commit 6ec4abb

Please sign in to comment.