Skip to content

Commit

Permalink
merge: 히스토리 피드에서 이전하기
Browse files Browse the repository at this point in the history
Feature/#117 히스토리 피드에서 이전하기
  • Loading branch information
hong-sile authored Aug 28, 2024
2 parents 13f4334 + 86ccf1f commit 6eec9ca
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,21 @@
public record MusicResponse(
String title,
String imageUrl,
String artistNames
String artistNames,
String isrcCode
) {

public static MusicResponse from(final TransferredMusic transferredMusic) {
return new MusicResponse(
transferredMusic.getTitle(), transferredMusic.getImageUrl(),
transferredMusic.getArtistNames()
transferredMusic.getArtistNames(), transferredMusic.getIsrcCode()
);
}

public static MusicResponse from(final TransferFailMusic transferFailMusic) {
return new MusicResponse(
transferFailMusic.getTitle(), transferFailMusic.getImageUrl(),
transferFailMusic.getArtistNames()
transferFailMusic.getArtistNames(), null
);
}

Expand Down
10 changes: 7 additions & 3 deletions src/main/java/play/pluv/history/domain/TransferredMusic.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,21 @@ public class TransferredMusic extends BaseEntity {
private String imageUrl;
@Getter
private String artistNames;
@Getter
private String isrcCode;
@Embedded
private HistoryMusicId musicId;

@Builder
public TransferredMusic(final Long historyId, final String title, final String imageUrl,
final String artistNames,
final HistoryMusicId musicId) {
public TransferredMusic(
final Long historyId, final String title, final String imageUrl,
final String artistNames, final String isrcCode, final HistoryMusicId musicId
) {
this.historyId = historyId;
this.title = title;
this.imageUrl = imageUrl;
this.artistNames = artistNames;
this.isrcCode = isrcCode;
this.musicId = musicId;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public TransferredMusic toTransferredMusic(final Long historyId) {
.imageUrl(imageUrl)
.title(title)
.musicId(musicId)
.isrcCode(isrcCode)
.build();
}
}
2 changes: 2 additions & 0 deletions src/test/java/play/pluv/api/FeedApiTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,8 @@ public class FeedApiTest extends ApiTest {
fieldWithPath("data[]").type(ARRAY).description("이전한 음악들"),
fieldWithPath("data[].title").type(STRING).description("음악 이름"),
fieldWithPath("data[].imageUrl").type(STRING).description("음악 이미지 url"),
fieldWithPath("data[].isrcCode").type(STRING).description("음악의 isrc Code")
.optional(),
fieldWithPath("data[].artistNames").type(STRING).description("가수들")
)
));
Expand Down
3 changes: 3 additions & 0 deletions src/test/java/play/pluv/api/HistoryApiTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ public class HistoryApiTest extends ApiTest {
fieldWithPath("msg").type(STRING).description("상태 코드에 해당하는 메시지"),
fieldWithPath("data[]").type(ARRAY).description("이전하지 못한 음악들"),
fieldWithPath("data[].title").type(STRING).description("음악 이름"),
fieldWithPath("data[].isrcCode").type(STRING).description("null값").optional(),
fieldWithPath("data[].imageUrl").type(STRING).description("음악 이미지 url"),
fieldWithPath("data[].artistNames").type(STRING).description("가수들")
)
Expand Down Expand Up @@ -155,6 +156,8 @@ public class HistoryApiTest extends ApiTest {
fieldWithPath("msg").type(STRING).description("상태 코드에 해당하는 메시지"),
fieldWithPath("data[]").type(ARRAY).description("이전한 음악들"),
fieldWithPath("data[].title").type(STRING).description("음악 이름"),
fieldWithPath("data[].isrcCode").type(STRING).description("음악의 isrc Code")
.optional(),
fieldWithPath("data[].imageUrl").type(STRING).description("음악 이미지 url"),
fieldWithPath("data[].artistNames").type(STRING).description("가수들")
)
Expand Down
5 changes: 2 additions & 3 deletions src/test/java/play/pluv/fixture/HistoryEntityFixture.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

import java.time.LocalDateTime;
import java.util.List;
import play.pluv.feed.application.dto.FeedDetailResponse;
import play.pluv.history.domain.History;
import play.pluv.history.domain.HistoryMusicId;
import play.pluv.history.domain.TransferFailMusic;
Expand Down Expand Up @@ -40,9 +39,9 @@ public class HistoryEntityFixture {
public static List<TransferredMusic> 이전한_음악들(final Long historyId) {
return List.of(
new TransferredMusic(historyId, "다시 사랑한다 말할까", "imagerUrl", "김동률",
new HistoryMusicId(SPOTIFY, "ab")),
"isrc", new HistoryMusicId(SPOTIFY, "ab")),
new TransferredMusic(historyId, "오래된 노래", "imagerUrl", "김동률",
new HistoryMusicId(SPOTIFY, "cd"))
"isrc", new HistoryMusicId(SPOTIFY, "cd"))
);
}

Expand Down

0 comments on commit 6eec9ca

Please sign in to comment.