feat(playlist): 优化歌单页面展示逻辑
- 移除歌单首歌曲数量的冗余展示 - 增加歌单总歌曲数量的展示 - 更新歌单列表和歌单详情页面的样式 - 在后端增加@EntityGraph注解,优化数据查询性能
This commit is contained in:
@@ -7,6 +7,8 @@ import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||
import org.springframework.data.jpa.domain.Specification;
|
||||
import org.springframework.data.jpa.repository.EntityGraph;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@@ -18,6 +20,9 @@ import java.util.List;
|
||||
@Repository
|
||||
public interface PlaylistRepository extends JpaRepository<Playlist, Long>, JpaSpecificationExecutor<Playlist> {
|
||||
|
||||
@EntityGraph(attributePaths = {"musics", "creator", "type"})
|
||||
Page<Playlist> findAll(Specification<Playlist> spec, Pageable pageable);
|
||||
|
||||
@Query("SELECT pt.name, COUNT(p) FROM Playlist p JOIN p.type pt GROUP BY pt.name")
|
||||
List<Object[]> countByPlaylistType();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user