Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: 즐찾 해제 시 자식 음식객체 연쇄삭제 명시적으로 추가 (#114) #119

Merged
merged 2 commits into from
Nov 22, 2023
Merged
Changes from 1 commit
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 @@ -128,6 +128,8 @@ public void updateFavoriteFood(UpdateFavoriteFoodDto updateFavoriteFoodDto) {
@Transactional
public void deleteFavoriteFood(Long favoriteFoodId, Long userId) {
validateFavoriteFood(favoriteFoodId, userId);
FavoriteFood favoriteFood = getFavoriteFoodById(favoriteFoodId);
favoriteFood.getFoods().forEach(food -> food.setFavoriteFood(null)); // 즐겨찾기 음식으로부터 태어난 음식들의 즐겨찾기 정보를 null로 초기화
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cascade가 잘 이루어지지 않는 것 같은데, 일단 이렇게 하되, 나중에 좀 논의를 해봐야 할 것 같습니다.

favoriteFoodRepository.deleteById(favoriteFoodId);
log.info("즐겨찾기 음식 해제 완료: " + favoriteFoodId);
}
Expand Down
Loading