Skip to content

Commit

Permalink
feat: movie 단건 조회
Browse files Browse the repository at this point in the history
  • Loading branch information
kdomo committed Sep 23, 2023
1 parent f1f5c02 commit c2dd70e
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -69,4 +70,10 @@ public List<MovieModel> 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);
}
}
19 changes: 19 additions & 0 deletions src/main/java/com/flickspick/movie/dto/MovieResponse.java
Original file line number Diff line number Diff line change
@@ -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<MovieModel> recMovies;

public static MovieResponse toResponse(MovieModel movieModel, List<MovieModel> recMovies) {
return new MovieResponse(movieModel, recMovies);
}
}
Original file line number Diff line number Diff line change
@@ -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);
}
}

0 comments on commit c2dd70e

Please sign in to comment.