-
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.
Feature/#67 유사곡 5개 반환
- Loading branch information
Showing
16 changed files
with
178 additions
and
94 deletions.
There are no files selected for viewing
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
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
24 changes: 24 additions & 0 deletions
24
src/main/java/play/pluv/music/domain/DestinationMusics.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,24 @@ | ||
package play.pluv.music.domain; | ||
|
||
import java.util.List; | ||
import lombok.Getter; | ||
import lombok.RequiredArgsConstructor; | ||
import play.pluv.playlist.domain.PlayListMusic; | ||
|
||
@Getter | ||
@RequiredArgsConstructor | ||
public class DestinationMusics { | ||
|
||
private final List<DestinationMusic> destinationMusics; | ||
|
||
public Boolean containEqual(final PlayListMusic playListMusic) { | ||
return destinationMusics.stream() | ||
.map(destinationMusic -> destinationMusic.isSame(playListMusic)) | ||
//하나라도 동일하면 true 반환 | ||
.reduce(false, (a, b) -> a || b); | ||
} | ||
|
||
public Boolean isEmpty() { | ||
return destinationMusics.isEmpty(); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
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
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
29 changes: 7 additions & 22 deletions
29
src/main/java/play/pluv/oauth/spotify/dto/SpotifySearchMusicResponse.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 |
---|---|---|
@@ -1,40 +1,25 @@ | ||
package play.pluv.oauth.spotify.dto; | ||
|
||
import static play.pluv.playlist.domain.MusicStreaming.SPOTIFY; | ||
|
||
import java.util.List; | ||
import java.util.Optional; | ||
import play.pluv.music.domain.DestinationMusic; | ||
import play.pluv.music.domain.MusicId; | ||
import play.pluv.music.domain.DestinationMusics; | ||
|
||
public record SpotifySearchMusicResponse( | ||
Track tracks | ||
) { | ||
|
||
public Optional<DestinationMusic> toMusic() { | ||
return tracks.toMusic(); | ||
public DestinationMusics toDestinationMusics() { | ||
return new DestinationMusics(tracks.toMusics()); | ||
} | ||
|
||
public record Track( | ||
List<SpotifyMusic> items | ||
) { | ||
|
||
public Optional<DestinationMusic> toMusic() { | ||
if (items.isEmpty()) { | ||
return Optional.empty(); | ||
} | ||
|
||
final SpotifyMusic spotifyMusic = items.get(0); | ||
|
||
return Optional.of(DestinationMusic.builder() | ||
.musicId(new MusicId(SPOTIFY, spotifyMusic.id())) | ||
.imageUrl(spotifyMusic.getImageUrl()) | ||
.artistNames(spotifyMusic.getArtistNames()) | ||
.title(spotifyMusic.name()) | ||
.isrcCode(spotifyMusic.getIsrcCode()) | ||
.build() | ||
); | ||
public List<DestinationMusic> toMusics() { | ||
return items.stream() | ||
.map(SpotifyMusic::toDestinationMusic) | ||
.toList(); | ||
} | ||
|
||
} | ||
} |
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
Oops, something went wrong.