44import com .back .web7_9_codecrete_be .domain .artists .dto .response .ArtistDetailResponse ;
55import com .back .web7_9_codecrete_be .domain .artists .dto .response .RelatedArtistResponse ;
66import com .back .web7_9_codecrete_be .domain .artists .dto .response .TopTrackResponse ;
7+ import com .back .web7_9_codecrete_be .domain .artists .entity .Artist ;
8+ import com .back .web7_9_codecrete_be .domain .artists .entity .ArtistType ;
79import com .back .web7_9_codecrete_be .domain .artists .entity .Genre ;
810import com .back .web7_9_codecrete_be .domain .artists .repository .ArtistRepository ;
911import com .back .web7_9_codecrete_be .domain .artists .repository .GenreRepository ;
1921import se .michaelthelin .spotify .enums .AlbumType ;
2022import se .michaelthelin .spotify .exceptions .detailed .NotFoundException ;
2123import se .michaelthelin .spotify .model_objects .specification .AlbumSimplified ;
22- import se .michaelthelin .spotify .model_objects .specification .Artist ;
2324import se .michaelthelin .spotify .model_objects .specification .Image ;
2425import se .michaelthelin .spotify .model_objects .specification .Paging ;
2526import se .michaelthelin .spotify .model_objects .specification .Track ;
@@ -63,7 +64,7 @@ public int seedKoreanArtists300() {
6364 int offset = 0 ;
6465
6566 while (totalSaved < targetCount ) {
66- Paging <Artist > paging = api .searchArtists (q )
67+ Paging <se . michaelthelin . spotify . model_objects . specification . Artist > paging = api .searchArtists (q )
6768 .limit (limit )
6869 .offset (offset )
6970 .build ()
@@ -85,10 +86,10 @@ public int seedKoreanArtists300() {
8586 String mainGenreName = pickMainGenreName (spotifyArtist );
8687 Genre genre = findOrCreateGenreByName (mainGenreName , null );
8788
88- String artistType = inferArtistType (spotifyArtist );
89+ String artistTypeStr = inferArtistType (spotifyArtist );
90+ ArtistType artistType = ArtistType .valueOf (artistTypeStr );
8991
90- com .back .web7_9_codecrete_be .domain .artists .entity .Artist artistEntity =
91- new com .back .web7_9_codecrete_be .domain .artists .entity .Artist (
92+ Artist artistEntity = new Artist (
9293 spotifyId ,
9394 name .trim (),
9495 null , // artistGroup
@@ -127,7 +128,7 @@ public int seedKoreanArtists300() {
127128 "korean indie" , "korean rock"
128129 );
129130
130- private boolean isLikelyKoreanMusic (Artist a ) {
131+ private boolean isLikelyKoreanMusic (se . michaelthelin . spotify . model_objects . specification . Artist a ) {
131132 String [] genres = a .getGenres ();
132133 if (genres != null ) {
133134 for (String g : genres ) {
@@ -142,7 +143,7 @@ private boolean isLikelyKoreanMusic(Artist a) {
142143 return name != null && name .matches (".*[가-힣].*" );
143144 }
144145
145- private String pickMainGenreName (Artist a ) {
146+ private String pickMainGenreName (se . michaelthelin . spotify . model_objects . specification . Artist a ) {
146147 String [] genres = a .getGenres ();
147148 if (genres == null || genres .length == 0 ) return "k-pop" ;
148149
@@ -161,7 +162,7 @@ private String pickMainGenreName(Artist a) {
161162 return "k-pop" ;
162163 }
163164
164- private String inferArtistType (Artist a ) {
165+ private String inferArtistType (se . michaelthelin . spotify . model_objects . specification . Artist a ) {
165166 String [] genres = a .getGenres ();
166167 if (genres != null ) {
167168 for (String g : genres ) {
@@ -182,15 +183,15 @@ private Genre findOrCreateGenreByName(String genreName, String genreGroup) {
182183 public ArtistDetailResponse getArtistDetail (
183184 String spotifyArtistId ,
184185 String artistGroup ,
185- String artistType ,
186+ ArtistType artistType ,
186187 long likeCount ,
187188 long artistId ,
188189 Long genreId
189190 ) {
190191 try {
191192 SpotifyApi api = spotifyClient .getAuthorizedApi ();
192193
193- Artist artist = api .getArtist (spotifyArtistId ).build ().execute (); // 메인 정보는 실패 시 예외 발생
194+ se . michaelthelin . spotify . model_objects . specification . Artist artist = api .getArtist (spotifyArtistId ).build ().execute (); // 메인 정보는 실패 시 예외 발생
194195
195196 Track [] topTracks = safeGetTopTracks (api , spotifyArtistId );
196197 Paging <AlbumSimplified > albums = safeGetAlbums (api , spotifyArtistId );
@@ -210,8 +211,8 @@ public ArtistDetailResponse getArtistDetail(
210211 pickImageUrl (artist .getImages ()),
211212 likeCount ,
212213 albums != null ? albums .getTotal () : 0 ,
213- artist .getPopularity (), // (너가 별점으로 바꾸고 싶으면 여기 가공)
214- "" , // Spotify에서는 설명을 제공하지 않아 공란 처리
214+ artist .getPopularity (), // 별점으로 수정
215+ "" , // 설명
215216 toAlbumResponses (albums != null ? albums .getItems () : null , spotifyArtistId ),
216217 toTopTrackResponses (topTracks ),
217218 relatedResponses
@@ -252,14 +253,9 @@ private Paging<AlbumSimplified> safeGetAlbums(SpotifyApi api, String artistId) {
252253 }
253254 }
254255
255- /**
256- * ✅ related artists
257- * - 정상 호출
258- * - related가 비거나 404면 fallback(장르 기반 검색)으로 대체
259- */
260256 private List <RelatedArtistResponse > safeGetRelated (
261257 SpotifyApi api ,
262- Artist me ,
258+ se . michaelthelin . spotify . model_objects . specification . Artist me ,
263259 String artistGroup ,
264260 long artistId ,
265261 Long genreId
@@ -271,7 +267,7 @@ private List<RelatedArtistResponse> safeGetRelated(
271267 }
272268
273269 try {
274- Artist [] related = api .getArtistsRelatedArtists (id ).build ().execute ();
270+ se . michaelthelin . spotify . model_objects . specification . Artist [] related = api .getArtistsRelatedArtists (id ).build ().execute ();
275271 if (related != null && related .length > 0 ) {
276272 log .info ("Spotify related artists fetched: size={} spotifyArtistId={}" , related .length , id );
277273 return toRelatedArtistResponses (related );
@@ -365,7 +361,7 @@ private List<TopTrackResponse> toTopTrackResponses(Track[] tracks) {
365361 .collect (toList ());
366362 }
367363
368- private List <RelatedArtistResponse > toRelatedArtistResponses (Artist [] artists ) {
364+ private List <RelatedArtistResponse > toRelatedArtistResponses (se . michaelthelin . spotify . model_objects . specification . Artist [] artists ) {
369365 if (artists == null ) return List .of ();
370366 return Stream .of (artists )
371367 .filter (Objects ::nonNull )
0 commit comments