Skip to content

Commit

Permalink
feat: 음악 반환값 변경(#35)
Browse files Browse the repository at this point in the history
  • Loading branch information
hong-sile committed Jul 26, 2024
1 parent b5fe2b3 commit ef9cfe8
Show file tree
Hide file tree
Showing 10 changed files with 16 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public record MusicSearchRequest(
) {

public record MusicQuery(
String musicName, String artistName, String isrcCode
String title, String artistName, String isrcCode
) {

public SourceMusic toDomain() {
Expand All @@ -18,7 +18,7 @@ public SourceMusic toDomain() {
.toList();

return SourceMusic.builder()
.name(musicName)
.title(title)
.artistNames(names)
.isrcCode(isrcCode)
.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,21 +37,21 @@ public static MusicSearchResponse createNotFound(final SourceMusic sourceMusic)
}

public record SourceMusicResponse(
String name,
String title,
String artistName
) {

public static SourceMusicResponse from(final SourceMusic sourceMusic) {
return new SourceMusicResponse(
sourceMusic.getName(),
sourceMusic.getTitle(),
String.join(",", sourceMusic.getArtistNames())
);
}
}

public record DestinationMusicResponse(
String id,
String name,
String title,
String artistName,
String imageUrl
) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/play/pluv/music/domain/DestinationMusic.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,6 @@ private Boolean compareName(final SourceMusic sourceMusic) {
final Set<String> set1 = new HashSet<>(artistNames);
final Set<String> set2 = new HashSet<>(sourceMusic.getArtistNames());

return Objects.equals(sourceMusic.getName(), name) && set1.equals(set2);
return Objects.equals(sourceMusic.getTitle(), name) && set1.equals(set2);
}
}
2 changes: 1 addition & 1 deletion src/main/java/play/pluv/music/domain/SourceMusic.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
public class SourceMusic {

@Getter
private final String name;
private final String title;
@Getter
private final List<String> artistNames;
//Nullable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ private MultiValueMap<String, String> createRequestParamForSearchMusic(final Sou
final String query = music.getIsrcCode()
.map(isrc -> format(MUSIC_QUERY_FORMAT_ISRC, isrc))
.orElseGet(() ->
format(MUSIC_QUERY_FORMAT_NAME_ARTIST, music.getName(), artistName)
format(MUSIC_QUERY_FORMAT_NAME_ARTIST, music.getTitle(), artistName)
);

param.add("q", query);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public PlayListMusic toMusic() {
return PlayListMusic.builder()
.artistNames(track.getArtistNames())
.isrcCode(track.getIsrcCode())
.name(track.name())
.title(track.name())
.imageUrl(track.getImageUrl())
.build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

@Builder
public record PlayListMusicResponse(
String name, String artistNames, String isrcCode, String imageUrl
String title, String artistNames, String isrcCode, String imageUrl
) {

public static List<PlayListMusicResponse> createList(final List<PlayListMusic> musics) {
Expand All @@ -17,7 +17,7 @@ public static List<PlayListMusicResponse> createList(final List<PlayListMusic> m

private static PlayListMusicResponse from(final PlayListMusic playListMusic){
return PlayListMusicResponse.builder()
.name(playListMusic.getName())
.title(playListMusic.getTitle())
.artistNames(String.join(",",playListMusic.getArtistNames()))
.imageUrl(playListMusic.getImageUrl())
.isrcCode(playListMusic.getIsrcCode().get())
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/play/pluv/playlist/domain/PlayListMusic.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
public class PlayListMusic {

@Getter
private final String name;
private final String title;
@Getter
private final List<String> artistNames;
//Nullable
Expand Down
6 changes: 3 additions & 3 deletions src/test/java/play/pluv/api/MusicApiTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public class MusicApiTest extends ApiTest {
requestFields(
fieldWithPath("destinationAccessToken").type(STRING)
.description("플레이리스트 제공자의 accessToken"),
fieldWithPath("musics[].musicName").type(STRING).description("음악 이름"),
fieldWithPath("musics[].title").type(STRING).description("음악 이름"),
fieldWithPath("musics[].artistName").type(STRING).description("가수 이름들"),
fieldWithPath("musics[].isrcCode").type(STRING).description("음악의 isrc코드").optional()
),
Expand All @@ -58,13 +58,13 @@ public class MusicApiTest extends ApiTest {
fieldWithPath("msg").type(STRING).description("상태 코드에 해당하는 메시지"),
fieldWithPath("data[].isEqual").type(BOOLEAN).description("동일한 음악인지"),
fieldWithPath("data[].isFound").type(BOOLEAN).description("찾았는지"),
fieldWithPath("data[].sourceMusic.name").type(STRING).description("검색하려는 음악의 이름"),
fieldWithPath("data[].sourceMusic.title").type(STRING).description("검색하려는 음악의 이름"),
fieldWithPath("data[].sourceMusic.artistName").type(STRING)
.description("검색하려는 음악의 가수 이름"),
fieldWithPath("data[].destinationMusic").type(OBJECT).description("조회된 음악 정보")
.optional(),
fieldWithPath("data[].destinationMusic.id").type(STRING).description("조회된 음악 id"),
fieldWithPath("data[].destinationMusic.name").type(STRING)
fieldWithPath("data[].destinationMusic.title").type(STRING)
.description("조회된 음악의 이름"),
fieldWithPath("data[].destinationMusic.artistName").type(STRING)
.description("조회된 음악의 가수 이름"),
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/play/pluv/api/PlayListApiTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ public class PlayListApiTest extends ApiTest {
responseFields(
fieldWithPath("code").type(NUMBER).description("상태 코드"),
fieldWithPath("msg").type(STRING).description("상태 코드에 해당하는 메시지"),
fieldWithPath("data[].name").type(STRING).description("음악의 이름"),
fieldWithPath("data[].title").type(STRING).description("음악의 이름"),
fieldWithPath("data[].artistNames").type(STRING).description("음악의 가수 이름"),
fieldWithPath("data[].isrcCode").type(STRING).description("조회된 음악의 isrcCode").optional(),
fieldWithPath("data[].imageUrl").type(STRING).description("음악의 이미지 url")
Expand Down

0 comments on commit ef9cfe8

Please sign in to comment.