Skip to content

Commit

Permalink
refactor [#109] 공연, 아티스트, 유저 존재 여부 조회 로직 분리
Browse files Browse the repository at this point in the history
  • Loading branch information
ch1hyun committed Jan 18, 2025
1 parent 1b21014 commit 16e7708
Showing 1 changed file with 10 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.sopt.confeti.api.user.facade;

import java.time.LocalDate;
import lombok.RequiredArgsConstructor;
import org.sopt.confeti.annotation.Facade;
import org.sopt.confeti.api.user.facade.dto.response.UserFavoriteArtistDTO;
Expand Down Expand Up @@ -46,11 +47,20 @@ public void addFestivalFavorite(long userId, long festivalId) {
public void removeFestivalFavorite(long userId, long festivalId) {
User user = userService.findById(userId);
Festival festival = festivalService.findById(festivalId);
validateExistUser(userId);
validateExistFestival(festivalId);
validateExistFestivalFavorite(userId, festivalId);

festivalFavoriteService.delete(user, festival);
}

@Transactional(readOnly = true)
protected void validateExistFestival(final long festivalId) {
if (!festivalService.existsById(festivalId)) {
throw new NotFoundException(ErrorMessage.NOT_FOUND);
}
}

@Transactional(readOnly = true)
protected void validateExistFestivalFavorite(final long userId, final long festivalId) {
if (!festivalFavoriteService.isFavorite(userId, festivalId)) {
Expand Down Expand Up @@ -142,11 +152,4 @@ protected void validateExistConcert(final long concertId) {
throw new NotFoundException(ErrorMessage.NOT_FOUND);
}
}

@Transactional(readOnly = true)
protected void validateExistFestival(final long festivalId) {
if (!festivalService.existsById(festivalId)) {
throw new NotFoundException(ErrorMessage.NOT_FOUND);
}
}
}

0 comments on commit 16e7708

Please sign in to comment.