赞
踩
请求:
{
post,
/lovemusic/likeMusic
data: id//音乐id
}
响应:
{
"status": 0,
"message": "点赞音乐成功",
"data": true
}
步骤:
1.查询是否已经收藏过(收藏过返回false)
2.插入成功(true)
3.插入失败(false)
数据库
MAPPER
Service
Controller
此处查询需要满足几个功能:
1. 支持模糊查询
2. 支持传入参数为空
mapper
service
controller
音乐播放与之前的一样
请求:
{
post,
/lovemusic/deletelovemusic,
data:{id:id}
}
响应:
{
"status": 0,
"message": "取消收藏成功!",
"data": true
}
- public Boolean deleteLikeMusic(Integer likeuserId,Integer likemusicId){
- if(loveMusicMapper.deleteLikeMusic(likeuserId,likemusicId)<1){
- return false;
- }
- return true;
- }
- @RequestMapping("/deletelovemusic")
- public Result deleteLikeMusic(@RequestParam(required = false) Integer musicId,HttpSession httpSession){
- if(musicId==null){
- return Result.fail(Constant.RESULT_CODE_FAIL,"你没有选中任何音乐取消收藏");
- }
- User user=(User) httpSession.getAttribute(Constant.USERINFO_SESSION_KEY);
- Integer userId=user.getUserId();
- if(loveMusicService.deleteLikeMusic(userId,musicId)){
- return Result.success(true);
- }
- return Result.fail(Constant.RESULT_CODE_FAIL,"删除失败");
- }
待完善!!!
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。