From c2dd70e6593516ec17bd7126ac59a391d03b5b09 Mon Sep 17 00:00:00 2001 From: kdomo Date: Sun, 24 Sep 2023 06:09:12 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20movie=20=EB=8B=A8=EA=B1=B4=20=EC=A1=B0?= =?UTF-8?q?=ED=9A=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../movie/application/MovieService.java | 7 ++++ .../flickspick/movie/dto/MovieResponse.java | 19 +++++++++++ .../movie/presentation/MovieController.java | 34 +++++++++++++++++++ 3 files changed, 60 insertions(+) create mode 100644 src/main/java/com/flickspick/movie/dto/MovieResponse.java create mode 100644 src/main/java/com/flickspick/movie/presentation/MovieController.java 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); + } +}