这篇文章主要介绍Java 语言(一种计算机语言,尤用于创建网站)语言(一种计算机语言,尤用于创建网站)如何实现精美网上音乐平台,文中介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们一定要看完!
一、项目简述
本系统功能包括:音乐播放用户登录注册用户信息编辑、头像修改歌曲、歌单搜索歌单打分歌单、歌曲评论歌单列表、歌手列表分页显示歌词同步显不音乐收藏、下载、拖动控制、音粉制后台对用户、歌曲、歌手、歌单信息的管理
二、项目运行
环境配置:Jdk1.8 Tomcat8.5 Mysql HBuilderX(网络风暴也行)Eclispe (IntelliJ IDEA,Eclispe,MyEclispe,Sts都支持)。
项目技术:跳羚马文米巴蒂斯武埃雷迪斯模式专家等等
歌手信息操作代码:
@RestController
@控制器
publicclassSingerController{
@自动连线
privatesignerserviceimplsingerservice;
@配置
public class mypicconfigimplementwebmvcconconfigurer {
@覆盖
public void addresourcehandlers(资源handlerregistryregistry){ 0
//注册表。addresource Chandler('/img/singer pic/* *).添加资源位置('文件:/用户/尹宏伟/Documents/github-工作区/音乐-网站/music-server/img/singer pic/');
}
}
//添加歌手
@ResponseBody
@RequestMapping(值='/singer/add ',方法=RequestMethod .开机自检)
publicObjectaddSinger(HttpServletrequestSeq){ 0
nbsp;JSONObject jsonObject = new JSONObject();
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.setName(name);
singer.setSex(new Byte(sex));
singer.setPic(pic);
singer.setBirth(myBirth);
singer.setLocation(location);
singer.setIntroduction(introduction);
boolean res = singerService.addSinger(singer);
if (res){
jsonObject.put("code", 1);
jsonObject.put("msg", "添加成功");
return jsonObject;
}else {
jsonObject.put("code", 0);
jsonObject.put("msg", "添加失败");
return jsonObject;
}
}
// 返回所有歌手
@RequestMapping(value = "/singer", method = RequestMethod.GET)
public Object allSinger(){
return singerService.allSinger();
}
// 根据歌手名查找歌手
@RequestMapping(value = "/singer/name/detail", method = RequestMethod.GET)
public Object singerOfName(HttpServletRequest req){
String name = req.getParameter("name").trim();
return singerService.singerOfName(name);
}
// 根据歌手性别查找歌手
@RequestMapping(value = "/singer/sex/detail", method = RequestMethod.GET)
public Object singerOfSex(HttpServletRequest req){
String sex = req.getParameter("sex").trim();
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)
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 = 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 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;
}
}
}
以上是“Java如何实现精美网上音乐平台”这篇文章的所有内容,感谢各位的阅读!希望分享的内容对大家有帮助,更多相关知识,欢迎关注行业资讯频道!
内容来源网络,如有侵权,联系删除,本文地址:https://www.230890.com/zhan/86568.html