Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.back.web7_9_codecrete_be.domain.artists.dto.response;

import java.util.List;

// Spotify 아티스트 상세 정보 캐시용 DTO - Redis에 저장하기 위한 데이터 구조

public record SpotifyArtistDetailCache(
// 아티스트 기본 정보
String artistName,
String profileImageUrl,
double popularity,

// Top Tracks (상위 10개)
List<TopTrackResponse> topTracks,

// 앨범 목록 (최대 20개)
List<AlbumResponse> albums,
int totalAlbums
) {
}

Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import org.springframework.data.domain.Slice;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import java.util.List;
Expand All @@ -14,6 +15,15 @@ public interface ArtistRepository extends JpaRepository<Artist, Long> {
boolean existsBySpotifyArtistId(String spotifyArtistId);
java.util.Optional<Artist> findBySpotifyArtistId(String spotifyArtistId);

// 아티스트 상세 조회용 - artistGenres와 genre를 fetch join하여 N+1 문제 방지
@Query("""
SELECT DISTINCT a FROM Artist a
LEFT JOIN FETCH a.artistGenres ag
LEFT JOIN FETCH ag.genre
WHERE a.id = :id
""")
java.util.Optional<Artist> findByIdWithArtistGenres(@Param("id") Long id);

@Query("SELECT a FROM Artist a WHERE a.nameKo IS NULL ORDER BY a.id ASC")
List<Artist> findByNameKoIsNullOrderByIdAsc(Pageable pageable);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import com.back.web7_9_codecrete_be.domain.artists.repository.ArtistRepository;
import com.back.web7_9_codecrete_be.domain.artists.repository.ArtistLikeRepository;
import com.back.web7_9_codecrete_be.domain.artists.repository.ConcertArtistRepository;
import com.back.web7_9_codecrete_be.domain.artists.service.spotifyService.SpotifyService;
import com.back.web7_9_codecrete_be.domain.concerts.entity.Concert;
import com.back.web7_9_codecrete_be.domain.concerts.repository.ConcertRepository;
import com.back.web7_9_codecrete_be.domain.concerts.service.ConcertService;
Expand Down Expand Up @@ -46,7 +45,7 @@ public Artist findArtist(Long artistId) {

@Transactional
public int setArtist() {
return spotifyService.seedKoreanArtists300();
return spotifyService.seedKoreanArtists();
}

@Transactional
Expand Down Expand Up @@ -97,7 +96,7 @@ public Slice<ArtistListResponse> listArtist(Pageable pageable, User user, Artist

@Transactional(readOnly = true)
public ArtistDetailResponse getArtistDetail(Long artistId) {
Artist artist = artistRepository.findById(artistId)
Artist artist = artistRepository.findByIdWithArtistGenres(artistId)
.orElseThrow(() -> new BusinessException(ArtistErrorCode.ARTIST_NOT_FOUND));

if (artist.getSpotifyArtistId() == null) {
Expand Down
Loading