From 4f00d49ae114f2b69ae402592830801187f4010a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E1=84=80=E1=85=B3=E1=86=A8=E1=84=85=E1=85=A1=E1=86=A8?= =?UTF-8?q?=E1=84=8F=E1=85=A9=E1=84=83=E1=85=B5=E1=86=BC?= <50691225+DongGeon0908@users.noreply.github.com> Date: Sun, 24 Sep 2023 06:20:22 +0900 Subject: [PATCH] fix: add user model in rec response --- .../flickspick/rec/application/RecService.java | 6 +++++- .../java/com/flickspick/rec/dto/RecResponse.java | 15 +++++++++------ 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/flickspick/rec/application/RecService.java b/src/main/java/com/flickspick/rec/application/RecService.java index 2ec024f..26defb1 100644 --- a/src/main/java/com/flickspick/rec/application/RecService.java +++ b/src/main/java/com/flickspick/rec/application/RecService.java @@ -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; @@ -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 questionAndAnswer = request.getAnswers() .stream() @@ -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); } } diff --git a/src/main/java/com/flickspick/rec/dto/RecResponse.java b/src/main/java/com/flickspick/rec/dto/RecResponse.java index e359af7..a772f7b 100644 --- a/src/main/java/com/flickspick/rec/dto/RecResponse.java +++ b/src/main/java/com/flickspick/rec/dto/RecResponse.java @@ -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; @@ -10,15 +11,17 @@ @Data @AllArgsConstructor public class RecResponse { + private UserModel user; private RecTypeModel recType; private MovieModel movie; private List recMovies; - public static RecResponse toResponse(RecTypeModel recTypeModel, MovieModel movie, List recMovies) { - return new RecResponse( - recTypeModel, - movie, - recMovies - ); + public static RecResponse toResponse( + RecTypeModel recTypeModel, + MovieModel movie, + List recMovies, + UserModel user + ) { + return new RecResponse(user, recTypeModel, movie, recMovies); } }