基于springboot和vue的在线音乐平台设计,附源码

今天给大家介绍一个在线音乐平台,功能丰富、界面优美,实现了音乐平台需要的所有功能。

实现技术

后端

Spring Boot + MyBatis+MySql

前端

Vue + Vue-Router + Vuex + Axios + ElementUI

功能介绍

音乐播放、用户登录注册、用户信息编辑、头像修改、歌曲、歌单搜索、歌单打分、歌单、歌曲评论、歌单列表、歌手列表分页显示、歌词同步显示、音乐收藏、下载、拖动控制、音量控制、后台对用户、歌曲、歌手、歌单信息的管理。

代码展示

/** * 歌手控制类 */ @RestController @RequestMapping(“/singer”) public class SingerController { @Autowired private SingerService singerService; /** * 添加歌手 */ @RequestMapping(value = “/add”, method = RequestMethod.POST) public Object addSinger(HttpServletRequest request) { JSONObject jsonObject = new JSONObject(); String name = request.getParameter(“name”).trim(); //姓名 String sex = request.getParameter(“sex”).trim(); //性别 String pic = request.getParameter(“pic”).trim(); //头像 String birth = request.getParameter(“birth”).trim(); //生日 String location = request.getParameter(“location”).trim();//地区 String introduction = request.getParameter(“introduction”).trim();//简介 //把生日转换成Date格式 DateFormat dateFormat = new SimpleDateFormat(“yyyy-MM-dd”); Date birthDate = new Date(); try { birthDate = dateFormat.parse(birth); } catch (ParseException e) { e.printStackTrace(); } //保存到歌手的对象中 Singer singer = new Singer(); singer.setName(name); singer.setSex(new Byte(sex)); singer.setPic(pic); singer.setBirth(birthDate); singer.setLocation(location); singer.setIntroduction(introduction); boolean flag = singerService.insert(singer); if (flag) { //保存成功 jsonObject.put(Consts.CODE, 1); jsonObject.put(Consts.MSG, “添加成功”); return jsonObject; } jsonObject.put(Consts.CODE, 0); jsonObject.put(Consts.MSG, “添加失败”); return jsonObject; } /** * 修改歌手 */ @RequestMapping(value = “/update”, method = RequestMethod.POST) public Object updateSinger(HttpServletRequest request) { JSONObject jsonObject = new JSONObject(); String id = request.getParameter(“id”).trim(); //主键 String name = request.getParameter(“name”).trim(); //姓名 String sex = request.getParameter(“sex”).trim(); //性别 String birth = request.getParameter(“birth”).trim(); //生日 String location = request.getParameter(“location”).trim();//地区 String introduction = request.getParameter(“introduction”).trim();//简介 //把生日转换成Date格式 DateFormat dateFormat = new SimpleDateFormat(“yyyy-MM-dd”); Date birthDate = new Date(); try { birthDate = dateFormat.parse(birth); } catch (ParseException e) { e.printStackTrace(); } //保存到歌手的对象中 Singer singer = new Singer(); singer.setId(Integer.parseInt(id)); singer.setName(name); singer.setSex(new Byte(sex)); singer.setBirth(birthDate); singer.setLocation(location); singer.setIntroduction(introduction); boolean flag = singerService.update(singer); if (flag) { //保存成功 jsonObject.put(Consts.CODE, 1); jsonObject.put(Consts.MSG, “修改成功”); return jsonObject; } jsonObject.put(Consts.CODE, 0); jsonObject.put(Consts.MSG, “修改失败”); return jsonObject; } /** * 删除歌手 */ @RequestMapping(value = “/delete”, method = RequestMethod.GET) public Object deleteSinger(HttpServletRequest request) { String id = request.getParameter(“id”).trim(); //主键 boolean flag = singerService.delete(Integer.parseInt(id)); return flag; } /** * 根据主键查询整个对象 */ @RequestMapping(value = “/selectByPrimaryKey”, method = RequestMethod.GET) public Object selectByPrimaryKey(HttpServletRequest request) { String id = request.getParameter(“id”).trim(); //主键 return singerService.selectByPrimaryKey(Integer.parseInt(id)); } /** * 查询所有歌手 */ @RequestMapping(value = “/allSinger”, method = RequestMethod.GET) public Object allSinger(HttpServletRequest request) { return singerService.allSinger(); } /** * 根据歌手名字模糊查询列表 */ @RequestMapping(value = “/singerOfName”, method = RequestMethod.GET) public Object singerOfName(HttpServletRequest request) { String name = request.getParameter(“name”).trim(); //歌手名字 return singerService.singerOfName(“%” + name + “%”); } /** * 根据性别查询 */ @RequestMapping(value = “/singerOfSex”, method = RequestMethod.GET) public Object singerOfSex(HttpServletRequest request) { String sex = request.getParameter(“sex”).trim(); //性别 return singerService.singerOfSex(Integer.parseInt(sex)); } /** * 更新歌手图片 */ @RequestMapping(value = “/updateSingerPic”, method = RequestMethod.POST) public Object updateSingerPic(@RequestParam(“file”) MultipartFile avatorFile, @RequestParam(“id”) int id) { JSONObject jsonObject = new JSONObject(); if (avatorFile.isEmpty()) { jsonObject.put(Consts.CODE, 0); jsonObject.put(Consts.MSG, “文件上传失败”); return jsonObject; } //文件名=当前时间到毫秒+原来的文件名 String fileName = System.currentTimeMillis() + avatorFile.getOriginalFilename(); //文件路径 String filePath = System.getProperty(“user.dir”) + System.getProperty(“file.separator”) + “img” + System.getProperty(“file.separator”) + “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 flag = singerService.update(singer); if (flag) { jsonObject.put(Consts.CODE, 1); jsonObject.put(Consts.MSG, “上传成功”); jsonObject.put(“pic”, storeAvatorPath); return jsonObject; } jsonObject.put(Consts.CODE, 0); jsonObject.put(Consts.MSG, “上传失败”); return jsonObject; } catch (IOException e) { jsonObject.put(Consts.CODE, 0); jsonObject.put(Consts.MSG, “上传失败” + e.getMessage()); } finally { return jsonObject; } } }

获取源码请关注后私信“在线音乐”

© 版权声明
THE END
喜欢就支持一下吧
点赞9 分享
评论 抢沙发
头像
欢迎您留下宝贵的见解!
提交
头像

昵称

取消
昵称表情代码图片