做平面的網(wǎng)站凡科建站怎么用
文章目錄
- 音樂系統(tǒng)
- 一、項(xiàng)目演示
- 二、項(xiàng)目介紹
- 三、萬字項(xiàng)目文檔
- 四、部分功能截圖
- 五、部分代碼展示
- 六、底部獲取項(xiàng)目源碼和萬字論文參考(9.9¥帶走)
音樂系統(tǒng)
一、項(xiàng)目演示
在線音樂系統(tǒng)
二、項(xiàng)目介紹
基于springboot+vue的前后端分離在線音樂系統(tǒng)
登錄角色 : 用戶、管理員
用戶:歌單分類分頁界面,歌手分類分頁界面,我的音樂查看收藏歌曲,搜索音樂,可根據(jù)歌手、歌曲、歌單名進(jìn)行搜索;頭像修改、用戶信息修改,歌曲播放,進(jìn)度條拉伸,歌詞加載,歌曲收藏,歌曲下載,登錄、注冊(cè)等
管理員:系統(tǒng)首頁展示統(tǒng)計(jì)數(shù)據(jù),用戶管理,歌手管理,歌曲管理(修改音源,歌詞,后臺(tái)評(píng)論),上傳音樂
項(xiàng)目技術(shù)
語言:java
前端技術(shù):Vue、 ELementUI、echarts
后端技術(shù):SpringBoot、Mybatis-Plus
數(shù)據(jù)庫:MySQL
三、萬字項(xiàng)目文檔
四、部分功能截圖
五、部分代碼展示
package com.rabbiter.music.controller;import com.alibaba.fastjson.JSONObject;
import com.rabbiter.music.pojo.Collect;
import com.rabbiter.music.service.CollectService;
import com.rabbiter.music.utils.Consts;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;/*** 收藏控制類*/
@RestController
@RequestMapping("/collect")
@Api(tags = "收藏")
public class CollectController {@Autowiredprivate CollectService CollectService;/*** 添加收藏*/@ApiOperation(value = "添加收藏、取消收藏")@RequestMapping(value = "/add",method = RequestMethod.POST)public Object addCollect(HttpServletRequest request){JSONObject jsonObject = new JSONObject();String userId = request.getParameter("userId"); //用戶idString type = request.getParameter("type"); //收藏類型(0歌曲1歌單)String songId = request.getParameter("songId"); //歌曲idif(songId==null||songId.equals("")){jsonObject.put(Consts.CODE,0);jsonObject.put(Consts.MSG,"收藏歌曲為空");return jsonObject;}if(CollectService.existSongId(Integer.parseInt(userId),Integer.parseInt(songId))){CollectService.deleteByUserIdSongId(Integer.parseInt(userId),Integer.parseInt(songId));jsonObject.put(Consts.CODE,2);jsonObject.put(Consts.MSG,"取消收藏成功");return jsonObject;}//保存到收藏的對(duì)象中Collect Collect = new Collect();Collect.setUserId(Integer.parseInt(userId));Collect.setType(new Byte(type));Collect.setSongId(Integer.parseInt(songId));boolean flag = CollectService.insert(Collect);if(flag){ //保存成功jsonObject.put(Consts.CODE,1);jsonObject.put(Consts.MSG,"收藏成功");return jsonObject;}jsonObject.put(Consts.CODE,0);jsonObject.put(Consts.MSG,"收藏失敗");return jsonObject;}/*** 刪除收藏*/@ApiOperation(value = "取消收藏")@RequestMapping(value = "/delete",method = RequestMethod.GET)public Object deleteCollect(HttpServletRequest request){String userId = request.getParameter("userId"); //用戶idString songId = request.getParameter("songId"); //歌曲idboolean flag = CollectService.deleteByUserIdSongId(Integer.parseInt(userId),Integer.parseInt(songId));return flag;}/*** 查詢所有收藏*/@ApiOperation(value = "查看所有收藏")@RequestMapping(value = "/allCollect",method = RequestMethod.GET)public Object allCollect(HttpServletRequest request){return CollectService.allCollect();}/*** 查詢某個(gè)用戶的收藏列表*/@ApiOperation(value = "用戶的收藏列表")@RequestMapping(value = "/collectOfUserId",method = RequestMethod.GET)public Object collectOfUserId(HttpServletRequest request){String userId = request.getParameter("userId"); //用戶idreturn CollectService.collectOfUserId(Integer.parseInt(userId));}}
package com.rabbiter.music.controller;import com.alibaba.fastjson.JSONObject;
import com.rabbiter.music.pojo.Consumer;
import com.rabbiter.music.service.ConsumerService;
import com.rabbiter.music.utils.Consts;
import com.rabbiter.music.utils.PathUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletRequest;
import java.io.File;
import java.io.IOException;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;/*** 前端用戶控制類*/
@RestController
@RequestMapping("/consumer")
@Api(tags = "用戶")
public class ConsumerController {@Autowiredprivate ConsumerService consumerService;/*** 添加前端用戶*/@ApiOperation(value = "注冊(cè)、添加前端用戶")@RequestMapping(value = "/add",method = RequestMethod.POST)public Object addConsumer(HttpServletRequest request){JSONObject jsonObject = new JSONObject();String username = request.getParameter("username").trim(); //賬號(hào)String password = request.getParameter("password").trim(); //密碼String sex = request.getParameter("sex").trim(); //性別String phoneNum = request.getParameter("phoneNum").trim(); //手機(jī)號(hào)String email = request.getParameter("email").trim(); //電子郵箱String birth = request.getParameter("birth").trim(); //生日String introduction = request.getParameter("introduction").trim();//簽名String location = request.getParameter("location").trim(); //地區(qū)String avator = request.getParameter("avator").trim(); //頭像地址if(username==null||username.equals("")){jsonObject.put(Consts.CODE,0);jsonObject.put(Consts.MSG,"用戶名不能為空");return jsonObject;}Consumer consumer1 = consumerService.getByUsername(username);if(consumer1!=null){jsonObject.put(Consts.CODE,0);jsonObject.put(Consts.MSG,"用戶名已存在");return jsonObject;}if(password==null||password.equals("")){jsonObject.put(Consts.CODE,0);jsonObject.put(Consts.MSG,"密碼不能為空");return jsonObject;}//把生日轉(zhuǎn)換成Date格式DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");Date birthDate = new Date();try {birthDate = dateFormat.parse(birth);} catch (ParseException e) {e.printStackTrace();}//保存到前端用戶的對(duì)象中Consumer consumer = new Consumer();consumer.setUsername(username);consumer.setPassword(password);consumer.setSex(new Byte(sex));consumer.setPhoneNum(phoneNum);consumer.setEmail(email);consumer.setBirth(birthDate);consumer.setIntroduction(introduction);consumer.setLocation(location);consumer.setAvator(avator);boolean flag = consumerService.insert(consumer);if(flag){ //保存成功jsonObject.put(Consts.CODE,1);jsonObject.put(Consts.MSG,"添加成功");return jsonObject;}jsonObject.put(Consts.CODE,0);jsonObject.put(Consts.MSG,"添加失敗");return jsonObject;}/*** 修改前端用戶*/@ApiOperation(value = "修改前端用戶")@RequestMapping(value = "/update",method = RequestMethod.POST)public Object updateConsumer(HttpServletRequest request){JSONObject jsonObject = new JSONObject();String id = request.getParameter("id").trim(); //主鍵String username = request.getParameter("username").trim(); //賬號(hào)String password = request.getParameter("password").trim(); //密碼String sex = request.getParameter("sex").trim(); //性別String phoneNum = request.getParameter("phoneNum").trim(); //手機(jī)號(hào)String email = request.getParameter("email").trim(); //電子郵箱String birth = request.getParameter("birth").trim(); //生日String introduction = request.getParameter("introduction").trim();//簽名String location = request.getParameter("location").trim(); //地區(qū)if(username==null||username.equals("")){jsonObject.put(Consts.CODE,0);jsonObject.put(Consts.MSG,"用戶名不能為空");return jsonObject;}if(password==null||password.equals("")){jsonObject.put(Consts.CODE,0);jsonObject.put(Consts.MSG,"密碼不能為空");return jsonObject;}//把生日轉(zhuǎn)換成Date格式DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");Date birthDate = new Date();try {birthDate = dateFormat.parse(birth);} catch (ParseException e) {e.printStackTrace();}//保存到前端用戶的對(duì)象中Consumer consumer = new Consumer();consumer.setId(Integer.parseInt(id));consumer.setUsername(username);consumer.setPassword(password);consumer.setSex(new Byte(sex));consumer.setPhoneNum(phoneNum);consumer.setEmail(email);consumer.setBirth(birthDate);consumer.setIntroduction(introduction);consumer.setLocation(location);boolean flag = consumerService.update(consumer);if(flag){ //保存成功jsonObject.put(Consts.CODE,1);jsonObject.put(Consts.MSG,"修改成功");return jsonObject;}jsonObject.put(Consts.CODE,0);jsonObject.put(Consts.MSG,"修改失敗");return jsonObject;}/*** 刪除前端用戶*/@ApiOperation(value = "刪除前端用戶")@RequestMapping(value = "/delete",method = RequestMethod.GET)public Object deleteConsumer(HttpServletRequest request){String id = request.getParameter("id").trim(); //主鍵boolean flag = consumerService.delete(Integer.parseInt(id));return flag;}/*** 根據(jù)主鍵查詢整個(gè)對(duì)象*/@ApiOperation(value = "根據(jù)主鍵查詢整個(gè)對(duì)象")@RequestMapping(value = "/selectByPrimaryKey",method = RequestMethod.GET)public Object selectByPrimaryKey(HttpServletRequest request){String id = request.getParameter("id").trim(); //主鍵return consumerService.selectByPrimaryKey(Integer.parseInt(id));}/*** 查詢所有前端用戶*/@ApiOperation(value = "查詢所有前端用戶")@RequestMapping(value = "/allConsumer",method = RequestMethod.GET)public Object allConsumer(HttpServletRequest request){return consumerService.allConsumer();}/*** 更新前端用戶圖片*/@ApiOperation(value = "更新前端用戶圖片")@RequestMapping(value = "/updateConsumerPic",method = RequestMethod.POST)public Object updateConsumerPic(@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;}//文件名=當(dāng)前時(shí)間到毫秒+原來的文件名String fileName = System.currentTimeMillis()+avatorFile.getOriginalFilename();//文件路徑String filePath = PathUtils.getClassLoadRootPath() +"/userImages/";//如果文件路徑不存在,新增該路徑File file1 = new File(filePath);if(!file1.exists()){file1.mkdir();}//實(shí)際的文件地址File dest = new File(filePath + fileName);//存儲(chǔ)到數(shù)據(jù)庫里的相對(duì)文件地址String storeAvatorPath = "/userImages/"+fileName;try {avatorFile.transferTo(dest);Consumer consumer = new Consumer();consumer.setId(id);consumer.setAvator(storeAvatorPath);boolean flag = consumerService.update(consumer);if(flag){jsonObject.put(Consts.CODE,1);jsonObject.put(Consts.MSG,"上傳成功");jsonObject.put("avator",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;}}/*** 前端用戶登錄*/@ApiOperation(value = "前端用戶登錄")@RequestMapping(value = "/login",method = RequestMethod.POST)public Object login(HttpServletRequest request){JSONObject jsonObject = new JSONObject();String username = request.getParameter("username").trim(); //賬號(hào)String password = request.getParameter("password").trim(); //密碼if(username==null||username.equals("")){jsonObject.put(Consts.CODE,0);jsonObject.put(Consts.MSG,"用戶名不能為空");return jsonObject;}if(password==null||password.equals("")){jsonObject.put(Consts.CODE,0);jsonObject.put(Consts.MSG,"密碼不能為空");return jsonObject;}//保存到前端用戶的對(duì)象中Consumer consumer = new Consumer();consumer.setUsername(username);consumer.setPassword(password);boolean flag = consumerService.verifyPassword(username,password);if(flag){ //驗(yàn)證成功jsonObject.put(Consts.CODE,1);jsonObject.put(Consts.MSG,"登錄成功");jsonObject.put("userMsg",consumerService.getByUsername(username));return jsonObject;}jsonObject.put(Consts.CODE,0);jsonObject.put(Consts.MSG,"用戶名或密碼錯(cuò)誤");return jsonObject;}
}
package com.rabbiter.music.controller;import com.alibaba.fastjson.JSONObject;
import com.rabbiter.music.pojo.Song;
import com.rabbiter.music.service.SongService;
import com.rabbiter.music.utils.Consts;
import com.rabbiter.music.utils.PathUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletRequest;
import java.io.File;
import java.io.IOException;/*** 歌曲管理controller*/
@RestController
@RequestMapping("/song")
@Api(tags = "歌曲管理")
public class SongController {@Autowiredprivate SongService songService;/*** 添加歌曲*/@ApiOperation(value = "添加歌曲")@RequestMapping(value = "/add",method = RequestMethod.POST)public Object addSong(HttpServletRequest request, @RequestParam("file")MultipartFile mpFile){JSONObject jsonObject = new JSONObject();//獲取前端傳來的參數(shù)String singerId = request.getParameter("singerId").trim(); //所屬歌手idString name = request.getParameter("name").trim(); //歌名String introduction = request.getParameter("introduction").trim(); //簡(jiǎn)介String pic = "/img/songPic/tubiao.jpg"; //默認(rèn)圖片String lyric = request.getParameter("lyric").trim(); //歌詞//上傳歌曲文件if(mpFile.isEmpty()){jsonObject.put(Consts.CODE,0);jsonObject.put(Consts.MSG,"歌曲上傳失敗");return jsonObject;}//文件名=當(dāng)前時(shí)間到毫秒+原來的文件名String fileName = System.currentTimeMillis()+mpFile.getOriginalFilename();//文件路徑String filePath = PathUtils.getClassLoadRootPath() + "/song/";//如果文件路徑不存在,新增該路徑File file1 = new File(filePath);if(!file1.exists()){file1.mkdir();}//實(shí)際的文件地址File dest = new File(filePath + fileName);//存儲(chǔ)到數(shù)據(jù)庫里的相對(duì)文件地址String storeUrlPath = "/song/"+fileName;try {mpFile.transferTo(dest);Song song = new Song();song.setSingerId(Integer.parseInt(singerId));song.setName(name);song.setIntroduction(introduction);song.setPic(pic);song.setLyric(lyric);song.setUrl(storeUrlPath);boolean flag = songService.insert(song);if(flag){jsonObject.put(Consts.CODE,1);jsonObject.put(Consts.MSG,"保存成功");jsonObject.put("avator",storeUrlPath);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;}}/*** 根據(jù)歌手id查詢歌曲*/@ApiOperation(value = "根據(jù)歌手id查詢歌曲")@RequestMapping(value = "/singer/detail",method = RequestMethod.GET)public Object songOfSingerId(HttpServletRequest request){String singerId = request.getParameter("singerId");return songService.songOfSingerId(Integer.parseInt(singerId));}/*** 修改歌曲*/@ApiOperation(value = "修改歌曲")@RequestMapping(value = "/update",method = RequestMethod.POST)public Object updateSong(HttpServletRequest request){JSONObject jsonObject = new JSONObject();String id = request.getParameter("id").trim(); //主鍵String name = request.getParameter("name").trim(); //歌名String introduction = request.getParameter("introduction").trim();//專輯String lyric = request.getParameter("lyric").trim(); //歌詞//保存到歌手的對(duì)象中Song song = new Song();song.setId(Integer.parseInt(id));song.setName(name);song.setIntroduction(introduction);song.setLyric(lyric);boolean flag = songService.update(song);if(flag){ //保存成功jsonObject.put(Consts.CODE,1);jsonObject.put(Consts.MSG,"修改成功");return jsonObject;}jsonObject.put(Consts.CODE,0);jsonObject.put(Consts.MSG,"修改失敗");return jsonObject;}/*** 刪除歌曲*/@ApiOperation(value = "刪除歌曲")@RequestMapping(value = "/delete",method = RequestMethod.GET)public Object deleteSinger(HttpServletRequest request){//-TODO 先查詢到數(shù)據(jù)庫中對(duì)應(yīng)的文件地址,刪除掉它再進(jìn)行下面的代碼String id = request.getParameter("id").trim(); //主鍵boolean flag = songService.delete(Integer.parseInt(id));return flag;}/*** 更新歌曲圖片*/@ApiOperation(value = "更新歌曲圖片")@RequestMapping(value = "/updateSongPic",method = RequestMethod.POST)public Object updateSongPic(@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;}//文件名=當(dāng)前時(shí)間到毫秒+原來的文件名String fileName = System.currentTimeMillis()+avatorFile.getOriginalFilename();//文件路徑String filePath = PathUtils.getClassLoadRootPath() + "/img/songPic/";//如果文件路徑不存在,新增該路徑File file1 = new File(filePath);if(!file1.exists()){file1.mkdir();}//實(shí)際的文件地址File dest = new File(filePath + fileName);//存儲(chǔ)到數(shù)據(jù)庫里的相對(duì)文件地址String storeAvatorPath = "/img/songPic/"+fileName;try {avatorFile.transferTo(dest);Song song = new Song();song.setId(id);song.setPic(storeAvatorPath);boolean flag = songService.update(song);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;}}/*** 更新歌曲*/@ApiOperation(value = "更新歌曲")@RequestMapping(value = "/updateSongUrl",method = RequestMethod.POST)public Object updateSongUrl(@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;}//文件名=當(dāng)前時(shí)間到毫秒+原來的文件名String fileName = System.currentTimeMillis()+avatorFile.getOriginalFilename();//文件路徑String filePath = PathUtils.getClassLoadRootPath() + "/song/";//如果文件路徑不存在,新增該路徑File file1 = new File(filePath);if(!file1.exists()){file1.mkdir();}//實(shí)際的文件地址File dest = new File(filePath + fileName);//存儲(chǔ)到數(shù)據(jù)庫里的相對(duì)文件地址String storeAvatorPath = "/song/"+fileName;try {avatorFile.transferTo(dest);Song song = new Song();song.setId(id);song.setUrl(storeAvatorPath);boolean flag = songService.update(song);if(flag){jsonObject.put(Consts.CODE,1);jsonObject.put(Consts.MSG,"上傳成功");jsonObject.put("avator",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;}}/*** 根據(jù)歌曲id查詢歌曲對(duì)象*/@ApiOperation(value = "根據(jù)歌曲id查詢歌曲對(duì)象")@RequestMapping(value = "/detail",method = RequestMethod.GET)public Object detail(HttpServletRequest request){String songId = request.getParameter("songId");return songService.selectByPrimaryKey(Integer.parseInt(songId));}/*** 根據(jù)歌手名字精確查詢歌曲*/@ApiOperation(value = "根據(jù)歌手名字精確查詢歌曲")@RequestMapping(value = "/songOfSongName",method = RequestMethod.GET)public Object songOfSongName(HttpServletRequest request){String songName = request.getParameter("songName");return songService.songOfName(songName);}/*** 根據(jù)歌手名字模糊查詢歌曲*/@ApiOperation(value = "根據(jù)歌手名字模糊查詢歌曲")@RequestMapping(value = "/likeSongOfName",method = RequestMethod.GET)public Object likeSongOfName(HttpServletRequest request){String songName = request.getParameter("songName");return songService.likeSongOfName(songName);}/*** 查詢所有歌曲*/@ApiOperation(value = "查詢所有歌曲")@RequestMapping(value = "/allSong",method = RequestMethod.GET)public Object allSong(HttpServletRequest request){return songService.allSong();}}
六、底部獲取項(xiàng)目源碼和萬字論文參考(9.9¥帶走)
有問題,或者需要協(xié)助調(diào)試運(yùn)行項(xiàng)目的也可以