Skip to content

Commit

Permalink
[fix] 리뷰 생성 dto movieId 필드 tmdbId로 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
syyling committed May 27, 2024
1 parent 7c6899a commit 442de38
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public class RecordRequest {
@Getter
@NoArgsConstructor
public static class RecordCreateRequest {
private Long movieId;
private String tmdbId;
private Long userId;
private String rating;
private String review;
Expand All @@ -21,9 +21,9 @@ public static class RecordCreateRequest {


@Builder
public RecordCreateRequest(Long movieId, Long userId, String rating,
public RecordCreateRequest(String tmdbId, Long userId, String rating,
String review, LocalDate date, ArrayList<String> keywords) {
this.movieId = movieId;
this.tmdbId = tmdbId;
this.userId = userId;
this.rating = rating;
this.review = review;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,17 +51,16 @@ public class RecordCreateService {
* WatchedCreateService와 중복되는 코드 많음 -> 리팩토링 필요
*/
public void createRecord(RecordRequest.RecordCreateRequest recordCreateRequest) {
Long movieId = recordCreateRequest.getMovieId();
String tmdbId = recordCreateRequest.getTmdbId();
Long userId = recordCreateRequest.getUserId();
Movie movie = movieQueryService.findById(movieId);
Movie movie = movieQueryService.findByTmdbId(tmdbId);
User user = userQueryService.findById(userId);
Optional<Record> optionalRecord = recordQueryService.findByUserIdAndMovieId(userId, movieId);
if(!watchedQueryService.existsByUserIdAndMovieId(userId, movieId)){
Optional<Record> optionalRecord = recordQueryService.findByUserIdAndMovieId(userId, movie.getId());
if(!watchedQueryService.existsByUserIdAndMovieId(userId, movie.getId())){
Watched watched = WatchedMapper.mapToWatched(user, movie);
watchedSaveService.save(watched);

Playlist playlist = watchedPlaylistQueryService.findByUserId(userId).getPlaylist();
System.out.println(playlist.getId());
MovieInPlaylist movieInPlaylist = MovieInPlaylist.builder()
.movie(movie)
.playlist(playlist)
Expand All @@ -76,13 +75,13 @@ public void createRecord(RecordRequest.RecordCreateRequest recordCreateRequest)
ArrayList<String> keywords = recordCreateRequest.getKeywords();
record.updateRecord(rating, review, date);
keywordDeleteService.deleteAllByRecordId(record.getId());
saveKeywords(keywords, record, movieId);
saveKeywords(keywords, record, movie.getId());
}
else {
Record record = RecordMapper.mapToRecord(recordCreateRequest, movie, user);
recordSaveService.saveRecord(record);
ArrayList<String> keywords = recordCreateRequest.getKeywords();
saveKeywords(keywords, record, movieId);
saveKeywords(keywords, record, movie.getId());
}
}

Expand Down

0 comments on commit 442de38

Please sign in to comment.