-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
118 additions
and
3 deletions.
There are no files selected for viewing
23 changes: 23 additions & 0 deletions
23
...ive/mookive_backend/movieInPlaylist/application/dto/response/MovieInPlaylistResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package com.mookive.mookive_backend.movieInPlaylist.application.dto.response; | ||
|
||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
public class MovieInPlaylistResponse { | ||
|
||
@Getter | ||
@NoArgsConstructor | ||
public static class MovieInPlaylistDefaultResponse { | ||
private String title; | ||
private String poster; | ||
private String rating; | ||
|
||
@Builder | ||
public MovieInPlaylistDefaultResponse(String title, String poster, String rating) { | ||
this.title = title; | ||
this.poster = poster; | ||
this.rating = rating; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
...ookive/mookive_backend/movieInPlaylist/application/service/MovieInPlayListGetService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package com.mookive.mookive_backend.movieInPlaylist.application.service; | ||
|
||
import com.mookive.mookive_backend.movieInPlaylist.application.dto.response.MovieInPlaylistResponse; | ||
import com.mookive.mookive_backend.movieInPlaylist.application.mapper.MovieInPlaylistMapper; | ||
import com.mookive.mookive_backend.movieInPlaylist.domain.entity.MovieInPlaylist; | ||
import com.mookive.mookive_backend.movieInPlaylist.domain.service.MovieInPlaylistQueryService; | ||
import com.mookive.mookive_backend.playlist.domain.entity.Playlist; | ||
import com.mookive.mookive_backend.playlist.domain.service.PlaylistQueryService; | ||
import com.mookive.mookive_backend.review.domain.entity.Review; | ||
import com.mookive.mookive_backend.review.domain.service.ReviewQueryService; | ||
import jakarta.transaction.Transactional; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Service; | ||
|
||
import java.util.List; | ||
import java.util.stream.Collectors; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
@Transactional | ||
public class MovieInPlayListGetService { | ||
|
||
private final MovieInPlaylistQueryService movieInPlaylistQueryService; | ||
private final PlaylistQueryService playlistQueryService; | ||
private final ReviewQueryService reviewQueryService; | ||
|
||
public List<MovieInPlaylistResponse.MovieInPlaylistDefaultResponse> getMovieInPlayList(Long playlistId) { | ||
Playlist playlist = playlistQueryService.findById(playlistId); | ||
Long userId = playlist.getUser().getId(); | ||
|
||
List<MovieInPlaylist> movieInPlaylistList = movieInPlaylistQueryService.findByPlaylistId(playlistId); | ||
List<MovieInPlaylistResponse.MovieInPlaylistDefaultResponse> movieInPlaylistDefaultResponseList = movieInPlaylistList.stream().map(movieInPlaylist -> | ||
{ | ||
Long movieId = movieInPlaylist.getMovie().getId(); | ||
Review review = reviewQueryService.findByUserIdAndMovieId(userId, movieId); | ||
String rating = review != null ? review.getRating() : null; | ||
return MovieInPlaylistMapper.mapToMovieInPlaylistDefaultResponse(movieInPlaylist, rating); | ||
}).collect(Collectors.toList()); | ||
|
||
return movieInPlaylistDefaultResponseList; | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
...m/mookive/mookive_backend/movieInPlaylist/domain/service/MovieInPlaylistQueryService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package com.mookive.mookive_backend.movieInPlaylist.domain.service; | ||
|
||
import com.mookive.mookive_backend.movieInPlaylist.domain.entity.MovieInPlaylist; | ||
import com.mookive.mookive_backend.movieInPlaylist.domain.respository.MovieInPlaylistRepository; | ||
import jakarta.transaction.Transactional; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Service; | ||
|
||
import java.util.List; | ||
|
||
@Service | ||
@Transactional | ||
@RequiredArgsConstructor | ||
public class MovieInPlaylistQueryService { | ||
|
||
private final MovieInPlaylistRepository movieInPlaylistRepository; | ||
|
||
public List<MovieInPlaylist> findByPlaylistId(Long playlistId) { | ||
return movieInPlaylistRepository.findByPlaylistId(playlistId); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters