基于javaweb+mysql的springboot精美网上音乐平台(前后端分离+java+vue+springboot+ssm+mysql+maven)
私信源码获取及调试交流
运行环境
Java≥8、MySQL≥5.7、Node.js≥10
开发工具
后端:eclipse/idea/myeclipse/sts等均可配置运行
前端:WebStorm/VSCode/HBuilderX等均可
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
功能说明
基于javaweb+mysql的SpringBoot精美网上音乐平台(前后端分离+java+vue+springboot+ssm+mysql+maven)
一、项目简述
本系统功能包括: 音乐播放 用户登录注册 用户信息编辑、头像修改 歌曲、歌单搜索 歌单打分 歌单、歌曲评论 歌单列表、歌手列表分页显示 歌词同步显不 音乐收藏、下载、拖动控制、音粉制 后台对用户、歌曲、歌手、歌单信息的管理
二、项目运行
环境配置: Jdk1.8 + Mysql + HBuilderX (Webstorm也 行)+ Eclispe (IntelliJ IDEA,Eclispe,MyEclispe,Sts都支 持)。
项目技术: Springboot + Maven + Mybatis + Vue, B/S 模式+ Maven等等
}
} catch (IOException e) {
jsonObject.put("code", 0);
jsonObject.put("msg", "上传失败" + e.getMessage());
return jsonObject;
} finally {
return jsonObject;
}
}
}
@RestController
@Controller
public class CommentController {
@Autowired
private CommentServiceImpl commentService;
// 提交评论
@ResponseBody
@RequestMapping(value = "/comment/add", method = RequestMethod.POST)
public Object addComment(HttpServletRequest req){
JSONObject jsonObject = new JSONObject();
}
// 更新歌曲图片
@ResponseBody
@RequestMapping(value = "/song/img/update", method = RequestMethod.POST)
public Object updateSongPic(@RequestParam("file") MultipartFile urlFile, @RequestParam("id") int id) {
JSONObject jsonObject = new JSONObject();
if (urlFile.isEmpty()) {
jsonObject.put("code", 0);
jsonObject.put("msg", "音乐上传失败!");
return jsonObject;
}
String fileName = System.currentTimeMillis() + urlFile.getOriginalFilename();
String filePath = System.getProperty("user.dir") + System.getProperty("file.separator") + "img" + System.getProperty("file.separator") + "songPic";
File file1 = new File(filePath);
if (!file1.exists()) {
file1.mkdir();
}
File dest = new File(filePath + System.getProperty("file.separator") + fileName);
String storeUrlPath = "/img/songPic/" + fileName;
try {
urlFile.transferTo(dest);
Song song = new Song();
song.setId(id);
song.setPic(storeUrlPath);
boolean res = songService.updateSongPic(song);
if (res) {
jsonObject.put("code", 1);
jsonObject.put("avator", storeUrlPath);
jsonObject.put("msg", "上传成功");
return jsonObject;
} else {
jsonObject.put("code", 0);
jsonObject.put("msg", "上传失败");
return jsonObject;
}
} catch (IOException e) {
jsonObject.put("code", 0);
jsonObject.put("msg", "上传失败" + e.getMessage());
return jsonObject;
} finally {
return jsonObject;
}
}
// 更新歌曲URL
SongList songList = new SongList();
songList.setId(Integer.parseInt(id));
songList.setTitle(title);
songList.setPic(pic);
songList.setIntroduction(introduction);
songList.setStyle(style);
boolean res = songListService.updateSongListMsg(songList);
if (res) {
jsonObject.put("code", 1);
jsonObject.put("msg", "修改成功");
return jsonObject;
} else {
jsonObject.put("code", 0);
jsonObject.put("msg", "修改失败");
return jsonObject;
}
}
// 更新歌单图片
@ResponseBody
@RequestMapping(value = "/songList/img/update", method = RequestMethod.POST)
public Object updateSongListPic(@RequestParam("file") MultipartFile avatorFile, @RequestParam("id") int id) {
JSONObject jsonObject = new JSONObject();
if (avatorFile.isEmpty()) {
jsonObject.put("code", 0);
jsonObject.put("msg", "文件上传失败!");
return jsonObject;
}
String fileName = System.currentTimeMillis() + avatorFile.getOriginalFilename();
String filePath = UploadConfig.uploadPath + "/img/songListPic/";
File file1 = new File(filePath);
if (!file1.exists()) {
file1.mkdir();
}
File dest = new File(filePath + System.getProperty("file.separator") + fileName);
String storeAvatorPath = "/img/songListPic/" + fileName;
try {
avatorFile.transferTo(dest);
SongList songList = new SongList();
songList.setId(id);
songList.setPic(storeAvatorPath);
boolean res = songListService.updateSongListImg(songList);
if (res) {
jsonObject.put("code", 1);
jsonObject.put("avator", storeAvatorPath);
jsonObject.put("msg", "上传成功");
return jsonObject;
} else {
jsonObject.put("code", 0);
jsonObject.put("msg", "上传失败");
return jsonObject;
}
File dest = new File(filePath + System.getProperty("file.separator") + fileName);
String storeAvatorPath = "/img/singerPic/" + fileName;
try {
avatorFile.transferTo(dest);
Singer singer = new Singer();
singer.setId(id);
singer.setPic(storeAvatorPath);
boolean res = singerService.updateSingerPic(singer);
if (res) {
jsonObject.put("code", 1);
jsonObject.put("pic", storeAvatorPath);
jsonObject.put("msg", "上传成功");
return jsonObject;
} else {
jsonObject.put("code", 0);
jsonObject.put("msg", "上传失败");
return jsonObject;
}
} catch (IOException e) {
jsonObject.put("code", 0);
jsonObject.put("msg", "上传失败" + e.getMessage());
return jsonObject;
} finally {
return jsonObject;
}
}
}
public Object listSongOfSongId(HttpServletRequest req){
String songListId = req.getParameter("songListId");
return listSongService.listSongOfSongId(Integer.parseInt(songListId));
}
// 删除歌单里的歌曲
@RequestMapping(value = "/ListSong/delete", method = RequestMethod.GET)
public Object deleteListSong(HttpServletRequest req){
String songId = req.getParameter("songId");
return listSongService.deleteListSong(Integer.parseInt(songId));
}
// 更新歌单里面的歌曲信息
@ResponseBody
@RequestMapping(value = "/listSong/update", method = RequestMethod.POST)
public Object updateListSongMsg(HttpServletRequest req){
JSONObject jsonObject = new JSONObject();
String id = req.getParameter("id").trim();
String song_id = req.getParameter("songId").trim();
String song_list_id = req.getParameter("songListId").trim();
ListSong listsong = new ListSong();
listsong.setId(Integer.parseInt(id));
listsong.setSongId(Integer.parseInt(song_id));
listsong.setSongListId(Integer.parseInt(song_list_id));
boolean res = listSongService.updateListSongMsg(listsong);
if (res){
jsonObject.put("code", 1);
jsonObject.put("msg", "修改成功");
return jsonObject;
}else {
jsonObject.put("code", 0);
jsonObject.put("msg", "修改失败");
return jsonObject;
}
}
}
}
@RestController
@Controller
public class CommentController {
@Autowired
private CommentServiceImpl commentService;
// 提交评论
@ResponseBody
@RequestMapping(value = "/comment/add", method = RequestMethod.POST)
public Object addComment(HttpServletRequest req){
JSONObject jsonObject = new JSONObject();
String user_id = req.getParameter("userId");
String type = req.getParameter("type");
if (res) {
jsonObject.put("code", 1);
jsonObject.put("avator", storeAvatorPath);
jsonObject.put("msg", "上传成功");
return jsonObject;
} else {
jsonObject.put("code", 0);
jsonObject.put("msg", "上传失败");
return jsonObject;
}
} catch (IOException e) {
jsonObject.put("code", 0);
jsonObject.put("msg", "上传失败" + e.getMessage());
return jsonObject;
} finally {
return jsonObject;
}
}
}
@ResponseBody
@RequestMapping(value = "/song/update", method = RequestMethod.POST)
public Object updateSongMsg(HttpServletRequest req) {
JSONObject jsonObject = new JSONObject();
String id = req.getParameter("id").trim();
String singer_id = req.getParameter("singerId").trim();
String name = req.getParameter("name").trim();
String introduction = req.getParameter("introduction").trim();
String lyric = req.getParameter("lyric").trim();
Song song = new Song();
song.setId(Integer.parseInt(id));
song.setSingerId(Integer.parseInt(singer_id));
song.setName(name);
song.setIntroduction(introduction);
song.setUpdateTime(new Date());
song.setLyric(lyric);
boolean res = songService.updateSongMsg(song);
if (res) {
jsonObject.put("code", 1);
jsonObject.put("msg", "修改成功");
return jsonObject;
} else {
jsonObject.put("code", 0);
jsonObject.put("msg", "修改失败");
return jsonObject;
}
}
// 更新歌曲图片
@ResponseBody
@RequestMapping(value = "/song/img/update", method = RequestMethod.POST)
public Object updateSongPic(@RequestParam("file") MultipartFile urlFile, @RequestParam("id") int id) {
JSONObject jsonObject = new JSONObject();
if (urlFile.isEmpty()) {
jsonObject.put("code", 0);
jsonObject.put("msg", "音乐上传失败!");
return jsonObject;
}
String fileName = System.currentTimeMillis() + urlFile.getOriginalFilename();
String filePath = System.getProperty("user.dir") + System.getProperty("file.separator") + "img" + System.getProperty("file.separator") + "songPic";
File file1 = new File(filePath);
if (!file1.exists()) {
file1.mkdir();
}
File dest = new File(filePath + System.getProperty("file.separator") + fileName);
e.printStackTrace();
}
singer.setId(Integer.parseInt(id));
singer.setName(name);
singer.setSex(new Byte(sex));
singer.setPic(pic);
singer.setBirth(myBirth);
singer.setLocation(location);
singer.setIntroduction(introduction);
boolean res = singerService.updateSingerMsg(singer);
if (res) {
jsonObject.put("code", 1);
jsonObject.put("msg", "修改成功");
return jsonObject;
} else {
jsonObject.put("code", 0);
jsonObject.put("msg", "修改失败");
return jsonObject;
}
}
// 更新歌手头像
@ResponseBody
@RequestMapping(value = "/singer/avatar/update", method = RequestMethod.POST)
public Object updateSingerPic(@RequestParam("file") MultipartFile avatorFile, @RequestParam("id") int id) {
JSONObject jsonObject = new JSONObject();
if (avatorFile.isEmpty()) {
jsonObject.put("code", 0);
jsonObject.put("msg", "文件上传失败!");
return jsonObject;
}
String fileName = System.currentTimeMillis() + avatorFile.getOriginalFilename();
String filePath = UploadConfig.uploadPath + "/img/singerPic/";
File file1 = new File(filePath);
if (!file1.exists()) {
file1.mkdir();
}
File dest = new File(filePath + System.getProperty("file.separator") + fileName);
String storeAvatorPath = "/img/singerPic/" + fileName;
try {
avatorFile.transferTo(dest);
Singer singer = new Singer();
singer.setId(id);
singer.setPic(storeAvatorPath);
boolean res = singerService.updateSingerPic(singer);
if (res) {
jsonObject.put("code", 1);
jsonObject.put("pic", storeAvatorPath);
return singerService.singerOfSex(Integer.parseInt(sex));
}
// 删除歌手
@RequestMapping(value = "/singer/delete", method = RequestMethod.GET)
public Object deleteSinger(HttpServletRequest req) {
String id = req.getParameter("id");
return singerService.deleteSinger(Integer.parseInt(id));
}
// 更新歌手信息
@ResponseBody
@RequestMapping(value = "/singer/update", method = RequestMethod.POST)
public Object updateSingerMsg(HttpServletRequest req) {
JSONObject jsonObject = new JSONObject();
String id = req.getParameter("id").trim();
String name = req.getParameter("name").trim();
String sex = req.getParameter("sex").trim();
String pic = req.getParameter("pic").trim();
String birth = req.getParameter("birth").trim();
String location = req.getParameter("location").trim();
String introduction = req.getParameter("introduction").trim();
Singer singer = new Singer();
DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
Date myBirth = new Date();
try {
myBirth = dateFormat.parse(birth);
} catch (Exception e) {
e.printStackTrace();
}
singer.setId(Integer.parseInt(id));
singer.setName(name);
singer.setSex(new Byte(sex));
singer.setPic(pic);
singer.setBirth(myBirth);
singer.setLocation(location);
singer.setIntroduction(introduction);
boolean res = singerService.updateSingerMsg(singer);
if (res) {
jsonObject.put("code", 1);
jsonObject.put("msg", "修改成功");
return jsonObject;
} else {
jsonObject.put("code", 0);
jsonObject.put("msg", "修改失败");
return jsonObject;
}
}
// 更新歌手头像
@ResponseBody
@RequestMapping(value = "/singer/avatar/update", method = RequestMethod.POST)
}else {
jsonObject.put("code", 0);
jsonObject.put("msg", "评价失败");
return jsonObject;
}
}
// 获取指定歌单的评分
@RequestMapping(value = "/rank", method = RequestMethod.GET)
public Object rankOfSongListId(HttpServletRequest req){
String songListId = req.getParameter("songListId");
return rankService.rankOfSongListId(Long.parseLong(songListId));
}
}
@RestController
@Controller
public class AdminController {
@Autowired
private AdminServiceImpl adminService;
// 判断是否登录成功
@ResponseBody
@RequestMapping(value = "/admin/login/status", method = RequestMethod.POST)
public Object loginStatus(HttpServletRequest req, HttpSession session){
JSONObject jsonObject = new JSONObject();
String name = req.getParameter("name");
String password = req.getParameter("password");
boolean res = adminService.veritypasswd(name, password);
File file1 = new File(filePath);
if (!file1.exists()) {
file1.mkdir();
}
File dest = new File(filePath + System.getProperty("file.separator") + fileName);
String storeUrlPath = "/img/songPic/" + fileName;
try {
urlFile.transferTo(dest);
Song song = new Song();
song.setId(id);
song.setPic(storeUrlPath);
boolean res = songService.updateSongPic(song);
if (res) {
jsonObject.put("code", 1);
jsonObject.put("avator", storeUrlPath);
jsonObject.put("msg", "上传成功");
return jsonObject;
} else {
jsonObject.put("code", 0);
jsonObject.put("msg", "上传失败");
return jsonObject;
}
} catch (IOException e) {
jsonObject.put("code", 0);
jsonObject.put("msg", "上传失败" + e.getMessage());
return jsonObject;
} finally {
return jsonObject;
}
}
// 更新歌曲URL
@ResponseBody
@RequestMapping(value = "/song/url/update", method = RequestMethod.POST)
public Object updateSongUrl(@RequestParam("file") MultipartFile urlFile, @RequestParam("id") int id) {
JSONObject jsonObject = new JSONObject();
if (urlFile.isEmpty()) {
jsonObject.put("code", 0);
jsonObject.put("msg", "音乐上传失败!");
return jsonObject;
}
String fileName = urlFile.getOriginalFilename();
String filePath = System.getProperty("user.dir") + System.getProperty("file.separator") + "song";
File file1 = new File(filePath);
if (!file1.exists()) {
file1.mkdir();
}
} else {
consumer.setEmail(email);
}
consumer.setBirth(myBirth);
consumer.setIntroduction(introduction);
consumer.setLocation(location);
consumer.setAvator(avator);
consumer.setCreateTime(new Date());
consumer.setUpdateTime(new Date());
boolean res = consumerService.addUser(consumer);
if (res) {
jsonObject.put("code", 1);
jsonObject.put("msg", "注册成功");
return jsonObject;
} else {
jsonObject.put("code", 0);
jsonObject.put("msg", "注册失败");
return jsonObject;
}
}
// 判断是否登录成功
@ResponseBody
@RequestMapping(value = "/user/login/status", method = RequestMethod.POST)
public Object loginStatus(HttpServletRequest req, HttpSession session) {
JSONObject jsonObject = new JSONObject();
String username = req.getParameter("username");
String password = req.getParameter("password");
// System.out.println(username+" "+password);
boolean res = consumerService.veritypasswd(username, password);
if (res) {
jsonObject.put("code", 1);
jsonObject.put("msg", "登录成功");
jsonObject.put("userMsg", consumerService.loginStatus(username));
session.setAttribute("username", username);
return jsonObject;
} else {
jsonObject.put("code", 0);
jsonObject.put("msg", "用户名或密码错误");
return jsonObject;
}
Consumer consumer = new Consumer();
DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
Date myBirth = new Date();
try {
myBirth = dateFormat.parse(birth);
} catch (Exception e) {
e.printStackTrace();
}
consumer.setUsername(username);
consumer.setPassword(password);
consumer.setSex(new Byte(sex));
if (phone_num == "") {
consumer.setPhoneNum(null);
} else {
consumer.setPhoneNum(phone_num);
}
if (email == "") {
consumer.setEmail(null);
} else {
consumer.setEmail(email);
}
consumer.setBirth(myBirth);
consumer.setIntroduction(introduction);
consumer.setLocation(location);
consumer.setAvator(avator);
consumer.setCreateTime(new Date());
consumer.setUpdateTime(new Date());
boolean res = consumerService.addUser(consumer);
if (res) {
jsonObject.put("code", 1);
jsonObject.put("msg", "注册成功");
return jsonObject;
} else {
jsonObject.put("code", 0);
jsonObject.put("msg", "注册失败");
return jsonObject;
}
}
// 判断是否登录成功
@ResponseBody
@RequestMapping(value = "/user/login/status", method = RequestMethod.POST)
public Object loginStatus(HttpServletRequest req, HttpSession session) {
JSONObject jsonObject = new JSONObject();
String username = req.getParameter("username");
String password = req.getParameter("password");
// System.out.println(username+" "+password);
boolean res = consumerService.veritypasswd(username, password);
if (res) {
}
// 删除歌单里的歌曲
@RequestMapping(value = "/ListSong/delete", method = RequestMethod.GET)
public Object deleteListSong(HttpServletRequest req){
String songId = req.getParameter("songId");
return listSongService.deleteListSong(Integer.parseInt(songId));
}
// 更新歌单里面的歌曲信息
@ResponseBody
@RequestMapping(value = "/listSong/update", method = RequestMethod.POST)
public Object updateListSongMsg(HttpServletRequest req){
JSONObject jsonObject = new JSONObject();
String id = req.getParameter("id").trim();
String song_id = req.getParameter("songId").trim();
String song_list_id = req.getParameter("songListId").trim();
ListSong listsong = new ListSong();
listsong.setId(Integer.parseInt(id));
listsong.setSongId(Integer.parseInt(song_id));
listsong.setSongListId(Integer.parseInt(song_list_id));
boolean res = listSongService.updateListSongMsg(listsong);
if (res){
jsonObject.put("code", 1);
jsonObject.put("msg", "修改成功");
return jsonObject;
}else {
jsonObject.put("code", 0);
jsonObject.put("msg", "修改失败");
return jsonObject;
}
}
}
@RestController
@Controller
public class RankController {
@Autowired
Rank rank = new Rank();
rank.setSongListId(Long.parseLong(songListId));
rank.setConsumerId(Long.parseLong(consumerId));
rank.setScore(Integer.parseInt(score));
boolean res = rankService.addRank(rank);
if (res){
jsonObject.put("code", 1);
jsonObject.put("msg", "评价成功");
return jsonObject;
}else {
jsonObject.put("code", 0);
jsonObject.put("msg", "评价失败");
return jsonObject;
}
}
// 获取指定歌单的评分
@RequestMapping(value = "/rank", method = RequestMethod.GET)
public Object rankOfSongListId(HttpServletRequest req){
String songListId = req.getParameter("songListId");
return rankService.rankOfSongListId(Long.parseLong(songListId));
}
}
@RestController
@Controller
public class AdminController {
}
comment.setContent(content);
comment.setType(new Byte(type));
comment.setUp(Integer.parseInt(up));
boolean res = commentService.updateCommentMsg(comment);
if (res){
jsonObject.put("code", 1);
jsonObject.put("msg", "修改成功");
return jsonObject;
}else {
jsonObject.put("code", 0);
jsonObject.put("msg", "修改失败");
return jsonObject;
}
}
}
@RestController
@Controller
public class CollectController {
@Autowired
private CollectServiceImpl collectService;
// 添加收藏的歌曲
@ResponseBody
@RequestMapping(value = "/collection/add", method = RequestMethod.POST)