Skip to content

Commit

Permalink
[fix] 플레이리스트 영화 추가 로직 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
syyling committed May 30, 2024
1 parent 87203ca commit 3799c74
Showing 1 changed file with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import com.mookive.mookive_backend.common.exception.Error;
import com.mookive.mookive_backend.movie.domain.entity.Movie;
import com.mookive.mookive_backend.movie.domain.service.MovieQueryService;
import com.mookive.mookive_backend.movie.domain.service.MovieSaveService;
import com.mookive.mookive_backend.movie.infra.service.MovieEntityGetService;
import com.mookive.mookive_backend.movieInPlaylist.application.dto.request.MovieInPlaylistRequest;
import com.mookive.mookive_backend.movieInPlaylist.application.mapper.MovieInPlaylistMapper;
import com.mookive.mookive_backend.movieInPlaylist.domain.entity.MovieInPlaylist;
Expand All @@ -24,6 +26,8 @@ public class MovieInPlaylistCreateService {
private final MovieQueryService movieQueryService;
private final MovieInPlaylistSaveService movieInPlaylistSaveService;
private final MovieInPlaylistQueryService movieInPlaylistQueryService;
private final MovieEntityGetService movieEntityGetService;
private final MovieSaveService movieSaveService;

/**
todo: "해당 영화가 이미 플레이리스트에 존재합니다" 라는 에러 메시지를 반환하도록 수정
Expand All @@ -32,6 +36,10 @@ public void createMovieInPlaylist(MovieInPlaylistRequest.MovieInPlaylistCreateRe
Long playlistId = movieInPlaylistCreateRequest.getPlaylistId();
String tmdbId = movieInPlaylistCreateRequest.getTmdbId();
Movie movie = movieQueryService.findByTmdbId(tmdbId);
if(movie == null) {
movie = movieEntityGetService.searchMovie(tmdbId);
movieSaveService.save(movie);
}
if(movieInPlaylistQueryService.existsByPlaylistIdAndMovieId(playlistId, movie.getId())) {
throw new BusinessException(Error.PLAYLIST_MOVIE_DUPLICATION);
}
Expand Down

0 comments on commit 3799c74

Please sign in to comment.