Skip to content

Commit

Permalink
fix: add user model in rec response
Browse files Browse the repository at this point in the history
  • Loading branch information
DongGeon0908 committed Sep 23, 2023
1 parent c2dd70e commit 4f00d49
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
6 changes: 5 additions & 1 deletion src/main/java/com/flickspick/rec/application/RecService.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import com.flickspick.rec.dto.RecResponse;
import com.flickspick.recommendtype.application.RecommendTypeService;
import com.flickspick.recommendtype.model.RecTypeModel;
import com.flickspick.user.application.UserService;
import com.flickspick.user_movie_history.application.UserMovieHistoryService;
import com.flickspick.user_movie_history.domain.UserMovieHistory;
import lombok.RequiredArgsConstructor;
Expand All @@ -29,9 +30,12 @@ public class RecService {
private final RecommendTypeService recommendTypeService;
private final MovieService movieService;
private final MovieRecommendTypeRepository movieRecommendTypeRepository;
private final UserService userService;

@SneakyThrows
public RecResponse get(AuthUser user, RecRequest request) {
var userModel = userService.getUserModel(user.getId());

Random rand = new SecureRandom();
Map<Long, Long> questionAndAnswer = request.getAnswers()
.stream()
Expand All @@ -57,6 +61,6 @@ public RecResponse get(AuthUser user, RecRequest request) {

userMovieHistoryService.saveUserMovieHistory(userMovieHistory);

return RecResponse.toResponse(recTypeModel, movieModel, recMovies);
return RecResponse.toResponse(recTypeModel, movieModel, recMovies, userModel);
}
}
15 changes: 9 additions & 6 deletions src/main/java/com/flickspick/rec/dto/RecResponse.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.flickspick.movie.model.MovieModel;
import com.flickspick.recommendtype.model.RecTypeModel;
import com.flickspick.user.model.UserModel;
import lombok.AllArgsConstructor;
import lombok.Data;

Expand All @@ -10,15 +11,17 @@
@Data
@AllArgsConstructor
public class RecResponse {
private UserModel user;
private RecTypeModel recType;
private MovieModel movie;
private List<MovieModel> recMovies;

public static RecResponse toResponse(RecTypeModel recTypeModel, MovieModel movie, List<MovieModel> recMovies) {
return new RecResponse(
recTypeModel,
movie,
recMovies
);
public static RecResponse toResponse(
RecTypeModel recTypeModel,
MovieModel movie,
List<MovieModel> recMovies,
UserModel user
) {
return new RecResponse(user, recTypeModel, movie, recMovies);
}
}

0 comments on commit 4f00d49

Please sign in to comment.