feat(playlist): 优化歌单详情页面加载逻辑

- 将评论获取移至歌单详情获取成功后
- 添加评论数到歌单 DTO
- 优化前端歌单详情展示
This commit is contained in:
ikmkj
2025-07-29 20:27:57 +08:00
parent b0efe29b3b
commit 34a3358ea4
2 changed files with 10 additions and 1 deletions

View File

@@ -75,6 +75,9 @@ public class PlaylistServiceImpl implements PlaylistService {
@Autowired
private PlayHistoryRepository playHistoryRepository;
@Autowired
private CommentRepository commentRepository;
@Autowired
private FileService fileService;
@@ -590,6 +593,10 @@ public class PlaylistServiceImpl implements PlaylistService {
playlistDTO.setSongCount(0);
}
// 设置评论数 (targetType=2 代表歌单)
long commentCount = commentRepository.countByTargetIdAndTargetType(playlist.getId(), 2);
playlistDTO.setCommentCount((int) commentCount);
// 检查当前登录用户是否已收藏该歌单
if (StpUtil.isLogin()) {
Long userId = StpUtil.getLoginIdAsLong();