Skip to content

Commit 1915f33

Browse files
committed
refactor: 아티스트 목록 조회 Entity 및 DTO 수정
1 parent ad0fbbd commit 1915f33

3 files changed

Lines changed: 21 additions & 2 deletions

File tree

src/main/java/com/back/web7_9_codecrete_be/domain/artists/dto/response/ArtistListResponse.java

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,32 @@
44
import io.swagger.v3.oas.annotations.media.Schema;
55

66
public record ArtistListResponse(
7+
@Schema(description = "아티스트 아이디입니다.")
8+
Long id,
9+
710
@Schema(description = "아티스트 이름입니다.")
811
String artistName,
912

1013
@Schema(description = "아티스트 소속 그룹입니다. 아티스트 이름이 그룹인 경우, null 로 처리됩니다.")
1114
String artistGroup,
1215

1316
@Schema(description = "장르 이름입니다.")
14-
String genreName
17+
String genreName,
18+
19+
@Schema(description = "받은 좋아요 수(찜한 사람 수) 입니다.")
20+
int likeCount,
21+
22+
@Schema(description = "아티스트 프로필 사진 URL 입니다.")
23+
String imageUrl
1524
) {
1625
public static ArtistListResponse from(Artist artist) {
1726
return new ArtistListResponse(
27+
artist.getId(),
1828
artist.getArtistName(),
1929
artist.getArtistGroup(),
20-
artist.getGenre().getGenreName()
30+
artist.getGenre().getGenreName(),
31+
artist.getLikeCount(),
32+
artist.getImageUrl()
2133
);
2234
}
2335
}

src/main/java/com/back/web7_9_codecrete_be/domain/artists/entity/Artist.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ public class Artist {
4040
@Column(name = "like_count", nullable = false)
4141
private int likeCount = 0;
4242

43+
@Column(name = "image_url")
44+
private String imageUrl;
45+
4346
public Artist(String spotifyArtistId, String artistName, String artistGroup, ArtistType artistType, Genre genre) {
4447
this.spotifyArtistId = spotifyArtistId;
4548
this.artistName = artistName;

src/main/java/com/back/web7_9_codecrete_be/domain/artists/service/SpotifyService.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,13 +89,17 @@ public int seedKoreanArtists300() {
8989
String artistTypeStr = inferArtistType(spotifyArtist);
9090
ArtistType artistType = ArtistType.valueOf(artistTypeStr);
9191

92+
// Spotify에서 이미지 URL 가져오기
93+
String imageUrl = pickImageUrl(spotifyArtist.getImages());
94+
9295
Artist artistEntity = new Artist(
9396
spotifyId,
9497
name.trim(),
9598
null, // artistGroup
9699
artistType,
97100
genre
98101
);
102+
artistEntity.setImageUrl(imageUrl);
99103

100104
artistRepository.save(artistEntity);
101105
totalSaved++;

0 commit comments

Comments
 (0)