From 3799c74e2001cf90293d9e33e9582dfbff94a376 Mon Sep 17 00:00:00 2001 From: syyling Date: Thu, 30 May 2024 10:33:01 +0900 Subject: [PATCH] =?UTF-8?q?[fix]=20=ED=94=8C=EB=A0=88=EC=9D=B4=EB=A6=AC?= =?UTF-8?q?=EC=8A=A4=ED=8A=B8=20=EC=98=81=ED=99=94=20=EC=B6=94=EA=B0=80=20?= =?UTF-8?q?=EB=A1=9C=EC=A7=81=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../application/service/MovieInPlaylistCreateService.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/main/java/com/mookive/mookive_backend/movieInPlaylist/application/service/MovieInPlaylistCreateService.java b/src/main/java/com/mookive/mookive_backend/movieInPlaylist/application/service/MovieInPlaylistCreateService.java index 7dcd841..74d3f21 100644 --- a/src/main/java/com/mookive/mookive_backend/movieInPlaylist/application/service/MovieInPlaylistCreateService.java +++ b/src/main/java/com/mookive/mookive_backend/movieInPlaylist/application/service/MovieInPlaylistCreateService.java @@ -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; @@ -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: "해당 영화가 이미 플레이리스트에 존재합니다" 라는 에러 메시지를 반환하도록 수정 @@ -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); }