feat(music-houduan): 添加歌单收藏和评论数量字段
- 在 Playlist 实体中添加 collectCount 和 commentCount 字段- 修改 SingerServiceImpl 中获取歌手粉丝数量的逻辑 - 在 UserSingerRepository 中添加按歌手 ID统计粉丝数量的方法
This commit is contained in:
@@ -59,6 +59,18 @@ public class Playlist {
|
||||
@Column
|
||||
private Integer isOfficial;
|
||||
|
||||
/**
|
||||
* 收藏数
|
||||
*/
|
||||
@Column
|
||||
private Integer collectCount;
|
||||
|
||||
/**
|
||||
* 评论数
|
||||
*/
|
||||
@Column
|
||||
private Integer commentCount;
|
||||
|
||||
/**
|
||||
* 播放次数
|
||||
*/
|
||||
|
||||
@@ -26,6 +26,15 @@ public interface UserSingerRepository extends JpaRepository<UserSinger, Long> {
|
||||
*/
|
||||
boolean existsByUserAndSinger(User user, Singer singer);
|
||||
|
||||
/**
|
||||
* 统计收藏指定歌手的用户数量
|
||||
*
|
||||
* @param singerId 歌手ID
|
||||
* @return 粉丝数量
|
||||
*/
|
||||
Long countBySingerId(Long singerId);
|
||||
|
||||
|
||||
/**
|
||||
* 判断用户是否已收藏歌手
|
||||
*
|
||||
|
||||
@@ -360,8 +360,11 @@ public class SingerServiceImpl implements SingerService {
|
||||
Long musicCount = musicRepository.countBySingersContaining(singer);
|
||||
singerDTO.setMusicCount(musicCount);
|
||||
|
||||
// // 设置粉丝数量
|
||||
// Long fansCount = userSingerRepository.count();
|
||||
// singerDTO.setFansCount(fansCount);
|
||||
// 设置粉丝数量
|
||||
Long fansCount = userSingerRepository.count();
|
||||
Long fansCount = userSingerRepository.countBySingerId(singer.getId());
|
||||
singerDTO.setFansCount(fansCount);
|
||||
|
||||
// 检查当前登录用户是否已收藏该歌手
|
||||
|
||||
Reference in New Issue
Block a user