diff --git a/src/main/java/com/flickspick/movie/application/MovieService.java b/src/main/java/com/flickspick/movie/application/MovieService.java index d6a63a3..073b329 100644 --- a/src/main/java/com/flickspick/movie/application/MovieService.java +++ b/src/main/java/com/flickspick/movie/application/MovieService.java @@ -4,6 +4,7 @@ import com.flickspick.exception.movie.MovieNotFoundException; import com.flickspick.exception.rec.RecommendTypeNotFoundException; import com.flickspick.movie.domain.Movie; +import com.flickspick.movie.dto.MovieResponse; import com.flickspick.movie.infrastructure.MovieRepository; import com.flickspick.movie.model.MovieModel; import com.flickspick.recommendtype.model.RecTypeModel; @@ -69,4 +70,10 @@ public List getList(Long movieId, int count) { public Long getMovieCount() { return movieRepository.count(); } + + public MovieResponse getMovie(Long movieId) { + var movieModel = get(movieId); + var recMovies = getList(movieId, 3); + return MovieResponse.toResponse(movieModel, recMovies); + } } diff --git a/src/main/java/com/flickspick/movie/dto/MovieResponse.java b/src/main/java/com/flickspick/movie/dto/MovieResponse.java new file mode 100644 index 0000000..3b76c66 --- /dev/null +++ b/src/main/java/com/flickspick/movie/dto/MovieResponse.java @@ -0,0 +1,19 @@ +package com.flickspick.movie.dto; + +import java.util.List; + +import com.flickspick.movie.model.MovieModel; + +import lombok.AllArgsConstructor; +import lombok.Data; + +@Data +@AllArgsConstructor +public class MovieResponse { + private MovieModel movie; + private List recMovies; + + public static MovieResponse toResponse(MovieModel movieModel, List recMovies) { + return new MovieResponse(movieModel, recMovies); + } +} diff --git a/src/main/java/com/flickspick/movie/presentation/MovieController.java b/src/main/java/com/flickspick/movie/presentation/MovieController.java new file mode 100644 index 0000000..b20bc8a --- /dev/null +++ b/src/main/java/com/flickspick/movie/presentation/MovieController.java @@ -0,0 +1,34 @@ +package com.flickspick.movie.presentation; + +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import com.flickspick.auth.model.AuthUser; +import com.flickspick.common.model.dto.ResponseDto; +import com.flickspick.home.application.HomeService; +import com.flickspick.movie.application.MovieService; +import com.flickspick.movie.dto.MovieResponse; +import com.flickspick.movie.model.MovieModel; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.tags.Tag; +import lombok.RequiredArgsConstructor; + +@Tag(name = "무비") +@RestController +@RequestMapping(value = "/api/v1/movies", produces = MediaType.APPLICATION_JSON_VALUE) +@RequiredArgsConstructor +public class MovieController { + private final MovieService movieService; + + @Operation(summary = "무비 조회") + @GetMapping(path = "/{movieId}") + public ResponseEntity getMovie(AuthUser user, @PathVariable Long movieId) { + MovieResponse response = movieService.getMovie(movieId); + return ResponseDto.ok(response); + } +}