增加分类筛选等功能
This commit is contained in:
@@ -49,9 +49,9 @@ public class CategoryInfoController extends BaseController
|
|||||||
|
|
||||||
// 根据分类获取分类音乐
|
// 根据分类获取分类音乐
|
||||||
@GetMapping("/cate/music/{categoryId}")
|
@GetMapping("/cate/music/{categoryId}")
|
||||||
public TableDataInfo getCategoryMusic(@PathVariable String categoryId){
|
public TableDataInfo getCategoryMusic(@PathVariable String categoryId,MusicInfo musicInfo){
|
||||||
startPage();
|
startPage();
|
||||||
List<MusicInfo> list = musicInfoService.selectMusicInfoByCid(categoryId);
|
List<MusicInfo> list = musicInfoService.selectMusicInfoByCid(categoryId,musicInfo);
|
||||||
return getDataTable(list);
|
return getDataTable(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -47,9 +47,9 @@ public class IndexController extends BaseController {
|
|||||||
|
|
||||||
// 根据分类获取分类音乐 TODO: 分类播放
|
// 根据分类获取分类音乐 TODO: 分类播放
|
||||||
@GetMapping("/cate/music/{categoryId}")
|
@GetMapping("/cate/music/{categoryId}")
|
||||||
public TableDataInfo getCategoryMusic(@PathVariable String categoryId){
|
public TableDataInfo getCategoryMusic(@PathVariable String categoryId,MusicInfo musicInfo){
|
||||||
startPage();
|
startPage();
|
||||||
List<MusicInfo> list = musicInfoService.selectMusicInfoByCid(categoryId);
|
List<MusicInfo> list = musicInfoService.selectMusicInfoByCid(categoryId,musicInfo);
|
||||||
return getDataTableData(list);
|
return getDataTableData(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -60,6 +60,23 @@ public class MusicController extends BaseController {
|
|||||||
//musicService.createPlaylist();
|
//musicService.createPlaylist();
|
||||||
return getDataTableData(list);
|
return getDataTableData(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询我喜欢的数量和图片
|
||||||
|
*/
|
||||||
|
@GetMapping("/like/num")
|
||||||
|
public AjaxResult likeNum(){
|
||||||
|
Long userId = SecurityUtils.getUserId();
|
||||||
|
// 查询我喜欢的数量
|
||||||
|
int count = musicService.findLikeNumsByUserId(userId);
|
||||||
|
// 获取一张音乐图片
|
||||||
|
String imgUrl = musicService.findLikeMusicImageByUserId(userId);
|
||||||
|
AjaxResult ajax = AjaxResult.success();
|
||||||
|
ajax.put("count", count);
|
||||||
|
ajax.put("imgUrl", imgUrl);
|
||||||
|
return ajax;
|
||||||
|
}
|
||||||
|
|
||||||
// 删除我喜欢的音乐 cancel/like
|
// 删除我喜欢的音乐 cancel/like
|
||||||
@RequestMapping("/cancel/like/{musicId}")
|
@RequestMapping("/cancel/like/{musicId}")
|
||||||
public AjaxResult cancelLikeMusic(@PathVariable String musicId){
|
public AjaxResult cancelLikeMusic(@PathVariable String musicId){
|
||||||
|
|||||||
@@ -108,13 +108,20 @@ public class UserHistoryController extends BaseController
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询历史数量
|
* 查询历史数量和图片
|
||||||
*/
|
*/
|
||||||
|
@GetMapping("/num")
|
||||||
public AjaxResult historyNum(){
|
public AjaxResult historyNum(){
|
||||||
Long userId = SecurityUtils.getUserId();
|
Long userId = SecurityUtils.getUserId();
|
||||||
// 查询历史数量
|
// 查询历史数量
|
||||||
//userHistoryService.findNumsByUserId();
|
int count = userHistoryService.findNumsByUserId(userId);
|
||||||
return null;
|
// 获取一张音乐图片
|
||||||
|
String imgUrl = userHistoryService.findHistoryMusicImageByUserId(userId);
|
||||||
|
|
||||||
|
AjaxResult ajax = AjaxResult.success();
|
||||||
|
ajax.put("count", count);
|
||||||
|
ajax.put("imgUrl", imgUrl);
|
||||||
|
return ajax;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ public interface MusicInfoMapper
|
|||||||
|
|
||||||
MusicInfo selectByCate(CategoryInfo categoryInfo);
|
MusicInfo selectByCate(CategoryInfo categoryInfo);
|
||||||
|
|
||||||
List<MusicInfo> selectMusicInfoByCid(String categoryId);
|
List<MusicInfo> selectMusicInfoByCid(@Param("categoryId") String categoryId,@Param("musicInfo") MusicInfo musicInfo);
|
||||||
|
|
||||||
List<MusicInfo> selectMusicInfoByIds(List<Long> musicIdList);
|
List<MusicInfo> selectMusicInfoByIds(List<Long> musicIdList);
|
||||||
|
|
||||||
@@ -91,4 +91,12 @@ public interface MusicInfoMapper
|
|||||||
MusicInfo selectByPath(String path);
|
MusicInfo selectByPath(String path);
|
||||||
|
|
||||||
List<MusicInfo> selectMusicInfoByReId(String reId);
|
List<MusicInfo> selectMusicInfoByReId(String reId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据用户ID查询喜欢的音乐中的一张图片
|
||||||
|
*
|
||||||
|
* @param userId 用户ID
|
||||||
|
* @return 音乐图片URL
|
||||||
|
*/
|
||||||
|
String selectLikeMusicImageByUserId(@Param("userId") Long userId);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -62,4 +62,20 @@ public interface UserHistoryMapper
|
|||||||
public int deleteUserHistoryByIds(String[] ids);
|
public int deleteUserHistoryByIds(String[] ids);
|
||||||
|
|
||||||
int deleteUserHistoryByMusicId(@Param("musicIds") String[] musicIds,@Param("userId") Long userId);
|
int deleteUserHistoryByMusicId(@Param("musicIds") String[] musicIds,@Param("userId") Long userId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据用户ID查询历史记录数量
|
||||||
|
*
|
||||||
|
* @param userId 用户ID
|
||||||
|
* @return 历史记录数量
|
||||||
|
*/
|
||||||
|
int selectHistoryNumByUserId(@Param("userId") Long userId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据用户ID查询历史音乐中的一张图片
|
||||||
|
*
|
||||||
|
* @param userId 用户ID
|
||||||
|
* @return 音乐图片URL
|
||||||
|
*/
|
||||||
|
String selectHistoryMusicImageByUserId(@Param("userId") Long userId);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -62,4 +62,12 @@ public interface UserLikeMusicMapper
|
|||||||
public int deleteUserLikeMusicByIds(String[] ids);
|
public int deleteUserLikeMusicByIds(String[] ids);
|
||||||
|
|
||||||
UserLikeMusic selectUserLikeMusicAndUserId(@Param("userId") Long userId,@Param("musicId") String musicId);
|
UserLikeMusic selectUserLikeMusicAndUserId(@Param("userId") Long userId,@Param("musicId") String musicId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据用户ID查询喜欢的音乐数量
|
||||||
|
*
|
||||||
|
* @param userId 用户ID
|
||||||
|
* @return 喜欢的音乐数量
|
||||||
|
*/
|
||||||
|
int selectLikeMusicCountByUserId(@Param("userId") Long userId);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ public interface IMusicInfoService
|
|||||||
|
|
||||||
List<MusicInfo> findMusicByCate(CategoryInfo categoryInfo);
|
List<MusicInfo> findMusicByCate(CategoryInfo categoryInfo);
|
||||||
|
|
||||||
List<MusicInfo> selectMusicInfoByCid(String categoryId);
|
List<MusicInfo> selectMusicInfoByCid(String categoryId,MusicInfo musicInfo);
|
||||||
|
|
||||||
List<MusicInfo> findMusicByCollectId(String collectId);
|
List<MusicInfo> findMusicByCollectId(String collectId);
|
||||||
|
|
||||||
@@ -100,4 +100,20 @@ public interface IMusicInfoService
|
|||||||
* @return 下一首音乐ID
|
* @return 下一首音乐ID
|
||||||
*/
|
*/
|
||||||
String getNextMusicId(Long userId, Integer playMode, Integer playlistType, String categoryId, String collectId,String reId, String currentMusicId);
|
String getNextMusicId(Long userId, Integer playMode, Integer playlistType, String categoryId, String collectId,String reId, String currentMusicId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据用户ID查询喜欢的音乐数量
|
||||||
|
*
|
||||||
|
* @param userId 用户ID
|
||||||
|
* @return 喜欢的音乐数量
|
||||||
|
*/
|
||||||
|
int findLikeNumsByUserId(Long userId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取用户喜欢的音乐中的一张图片
|
||||||
|
*
|
||||||
|
* @param userId 用户ID
|
||||||
|
* @return 音乐图片URL
|
||||||
|
*/
|
||||||
|
String findLikeMusicImageByUserId(Long userId);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -63,4 +63,20 @@ public interface IUserHistoryService
|
|||||||
int insertHistory(Long userId, String musicId);
|
int insertHistory(Long userId, String musicId);
|
||||||
|
|
||||||
int deleteUserHistoryByMusicId(String[] musicId);
|
int deleteUserHistoryByMusicId(String[] musicId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据用户ID查询历史记录数量
|
||||||
|
*
|
||||||
|
* @param userId 用户ID
|
||||||
|
* @return 历史记录数量
|
||||||
|
*/
|
||||||
|
int findNumsByUserId(Long userId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取用户历史音乐中的一张图片
|
||||||
|
*
|
||||||
|
* @param userId 用户ID
|
||||||
|
* @return 音乐图片URL
|
||||||
|
*/
|
||||||
|
String findHistoryMusicImageByUserId(Long userId);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -129,8 +129,8 @@ public class MusicInfoServiceImpl implements IMusicInfoService
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<MusicInfo> selectMusicInfoByCid(String categoryId) {
|
public List<MusicInfo> selectMusicInfoByCid(String categoryId,MusicInfo musicInfo) {
|
||||||
return musicInfoMapper.selectMusicInfoByCid(categoryId);
|
return musicInfoMapper.selectMusicInfoByCid(categoryId,musicInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -284,7 +284,7 @@ public class MusicInfoServiceImpl implements IMusicInfoService
|
|||||||
if (categoryId == null || categoryId.isEmpty()) {
|
if (categoryId == null || categoryId.isEmpty()) {
|
||||||
return null; // 分类播放必须提供分类ID
|
return null; // 分类播放必须提供分类ID
|
||||||
}
|
}
|
||||||
musicList = musicInfoMapper.selectMusicInfoByCid(categoryId);
|
musicList = musicInfoMapper.selectMusicInfoByCid(categoryId,new MusicInfo());
|
||||||
break;
|
break;
|
||||||
case 3: // 推荐播放
|
case 3: // 推荐播放
|
||||||
if (reId == null || reId.isEmpty()) {
|
if (reId == null || reId.isEmpty()) {
|
||||||
@@ -361,6 +361,28 @@ public class MusicInfoServiceImpl implements IMusicInfoService
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据用户ID查询喜欢的音乐数量
|
||||||
|
*
|
||||||
|
* @param userId 用户ID
|
||||||
|
* @return 喜欢的音乐数量
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public int findLikeNumsByUserId(Long userId) {
|
||||||
|
return userLikeMusicMapper.selectLikeMusicCountByUserId(userId);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取用户喜欢的音乐中的一张图片
|
||||||
|
*
|
||||||
|
* @param userId 用户ID
|
||||||
|
* @return 音乐图片URL
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public String findLikeMusicImageByUserId(Long userId) {
|
||||||
|
return musicInfoMapper.selectLikeMusicImageByUserId(userId);
|
||||||
|
}
|
||||||
|
|
||||||
//TODO: 待完善
|
//TODO: 待完善
|
||||||
public Map<String, String> getMixMusicInfo(String musicId){
|
public Map<String, String> getMixMusicInfo(String musicId){
|
||||||
MusicInfo musicInfo = musicInfoMapper.selectByMusicId(musicId);
|
MusicInfo musicInfo = musicInfoMapper.selectByMusicId(musicId);
|
||||||
|
|||||||
@@ -103,4 +103,26 @@ public class UserHistoryServiceImpl implements IUserHistoryService
|
|||||||
Long userId = SecurityUtils.getUserId();
|
Long userId = SecurityUtils.getUserId();
|
||||||
return userHistoryMapper.deleteUserHistoryByMusicId(musicIds,userId);
|
return userHistoryMapper.deleteUserHistoryByMusicId(musicIds,userId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据用户ID查询历史记录数量
|
||||||
|
*
|
||||||
|
* @param userId 用户ID
|
||||||
|
* @return 历史记录数量
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public int findNumsByUserId(Long userId) {
|
||||||
|
return userHistoryMapper.selectHistoryNumByUserId(userId);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取用户历史音乐中的一张图片
|
||||||
|
*
|
||||||
|
* @param userId 用户ID
|
||||||
|
* @return 音乐图片URL
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public String findHistoryMusicImageByUserId(Long userId) {
|
||||||
|
return userHistoryMapper.selectHistoryMusicImageByUserId(userId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -126,7 +126,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="selectMusicInfoByCid" resultMap="MusicInfoResult">
|
<select id="selectMusicInfoByCid" resultMap="MusicInfoResult">
|
||||||
SELECT m.* FROM music_category mc left JOIN music_info m on mc.music_id = m.music_id WHERE mc.category_id = #{categoryId} and m.shelf=1 and m.is_del=0
|
SELECT m.* FROM music_category mc left JOIN music_info m on mc.music_id = m.music_id
|
||||||
|
WHERE mc.category_id = #{categoryId} and m.shelf=1 and m.is_del=0
|
||||||
|
<if test="musicInfo.vip != null and musicInfo.vip != ''"> and m.vip = #{musicInfo.vip}</if>
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="selectMusicInfoByIds" resultMap="MusicInfoResult">
|
<select id="selectMusicInfoByIds" resultMap="MusicInfoResult">
|
||||||
@@ -186,4 +188,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
<select id="selectMusicInfoByReId" resultMap="MusicInfoResult">
|
<select id="selectMusicInfoByReId" resultMap="MusicInfoResult">
|
||||||
SELECT * FROM music_recommend mr left join music_info mi on mi.music_id=mr.music_id WHERE mi.is_del=0 and mr.recommend_id =#{reId}
|
SELECT * FROM music_recommend mr left join music_info mi on mi.music_id=mr.music_id WHERE mi.is_del=0 and mr.recommend_id =#{reId}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<select id="selectLikeMusicImageByUserId" resultType="java.lang.String">
|
||||||
|
SELECT mi.img_addr FROM user_like_music ulm
|
||||||
|
LEFT JOIN music_info mi ON ulm.music_id = mi.music_id
|
||||||
|
WHERE ulm.user_id = #{userId} AND mi.is_del = 0 AND mi.img_addr IS NOT NULL AND mi.img_addr != ''
|
||||||
|
LIMIT 1
|
||||||
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
@@ -66,4 +66,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
</foreach>
|
</foreach>
|
||||||
and user_id=#{userId}
|
and user_id=#{userId}
|
||||||
</delete>
|
</delete>
|
||||||
|
|
||||||
|
<select id="selectHistoryNumByUserId" resultType="int">
|
||||||
|
select count(1) from user_history where user_id = #{userId}
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="selectHistoryMusicImageByUserId" resultType="java.lang.String">
|
||||||
|
SELECT mi.img_addr FROM user_history uh
|
||||||
|
LEFT JOIN music_info mi ON uh.music_id = mi.music_id
|
||||||
|
WHERE uh.user_id = #{userId} AND mi.is_del = 0 AND mi.img_addr IS NOT NULL AND mi.img_addr != ''
|
||||||
|
LIMIT 1
|
||||||
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
@@ -62,4 +62,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
<select id="selectUserLikeMusicAndUserId" resultType="com.ruoyi.common.core.domain.entity.UserLikeMusic">
|
<select id="selectUserLikeMusicAndUserId" resultType="com.ruoyi.common.core.domain.entity.UserLikeMusic">
|
||||||
SELECT user_id as userId,music_id as musicId FROM user_like_music where user_id=#{userId} and music_id=#{musicId}
|
SELECT user_id as userId,music_id as musicId FROM user_like_music where user_id=#{userId} and music_id=#{musicId}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<select id="selectLikeMusicCountByUserId" resultType="int">
|
||||||
|
SELECT count(1) FROM user_like_music WHERE user_id = #{userId}
|
||||||
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
Reference in New Issue
Block a user