Commit f1734f75 authored by Daniel Puchala's avatar Daniel Puchala
Browse files

fix: change from user and movie dto to ids in review create dto

parent e8241b59
......@@ -17,9 +17,9 @@ import javax.validation.constraints.NotNull;
public class ReviewCreateDto implements CreateDto {
@NotNull
private SimpleUserDto user;
private Long userId;
@NotNull
private SimpleMovieDto movie;
private long movieId;
@NotNull
private String text;
......
......@@ -53,8 +53,8 @@ public class ReviewFacadeImpl extends GenericFacadeImpl<Review, ReviewDto, Revie
@Override
protected Review mapToCreatedEntity(ReviewCreateDto dto) {
User author = userService.findById(dto.getUser().getId());
Movie movie = movieService.findById(dto.getMovie().getId());
User author = userService.findById(dto.getUserId());
Movie movie = movieService.findById(dto.getMovieId());
Review createdReview = createMapper.toModel(dto);
createdReview.setUser(author);
......@@ -71,8 +71,8 @@ public class ReviewFacadeImpl extends GenericFacadeImpl<Review, ReviewDto, Revie
@Override
protected Review mapToUpdatedEntity(ReviewUpdateDto dto) {
User author = userService.findById(dto.getUser().getId());
Movie movie = movieService.findById(dto.getMovie().getId());
User author = userService.findById(dto.getUserId());
Movie movie = movieService.findById(dto.getMovieId());
Review updatedReview = updateMapper.toModel(dto);
updatedReview.setUser(author);
......@@ -146,12 +146,12 @@ public class ReviewFacadeImpl extends GenericFacadeImpl<Review, ReviewDto, Revie
public ReviewDto create(ReviewCreateDto createDto) {
Review entity = mapToCreatedEntity(createDto);
User author = userService.findById(createDto.getUser().getId());
User author = userService.findById(createDto.getUserId());
Set<Review> authorReviews = author.getReviews();
authorReviews.add(entity);
userService.update(author);
Movie movie = movieService.findById(createDto.getMovie().getId());
Movie movie = movieService.findById(createDto.getMovieId());
Set<Review> movieReviews = movie.getReviews();
movieReviews.add(entity);
movieService.update(movie);
......@@ -167,12 +167,12 @@ public class ReviewFacadeImpl extends GenericFacadeImpl<Review, ReviewDto, Revie
public ReviewDto update(ReviewUpdateDto updateDto) {
Review entity = mapToUpdatedEntity(updateDto);
User author = userService.findById(updateDto.getUser().getId());
User author = userService.findById(updateDto.getUserId());
Set<Review> authorReviews = author.getReviews();
authorReviews.add(entity);
userService.update(author);
Movie movie = movieService.findById(updateDto.getMovie().getId());
Movie movie = movieService.findById(updateDto.getMovieId());
Set<Review> movieReviews = movie.getReviews();
movieReviews.add(entity);
movieService.update(movie);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment