开发工具:eclipse,数据库mysql5.7 jdk1.8

技术:springboot+mybatis

/**
*
*
*
*/package com.bjpowernode.music.ss.service.impl;import javax.annotation.Resource;import com.bjpowernode.music.common.AbstractService;
import com.bjpowernode.music.common.IOperations;
import com.bjpowernode.music.ss.domain.User;
import com.bjpowernode.music.ss.mapper.IUserMapper;
import com.bjpowernode.music.ss.service.IUserService;
import org.springframework.stereotype.Service;@Service("userService")
public class UserService extends AbstractService<User, User> implements IUserService {public UserService() {this.setTableName("user");}@Resourceprivate IUserMapper userMapper;@Overrideprotected IOperations<User, User> getMapper() {return userMapper;}@Overridepublic void setTableName(String tableName) {this.tableName = tableName;;}//    public User getUserByName(String user_name) {
//        User user = userMapper.getUserByName(user_name);
//        return user;
//    }public String login(String user_name, String user_password) {return userMapper.login(user_name, user_password);}public String getUserById(String user_name, String user_password) {return userMapper.getUserById(user_name, user_password);}public String registJudge(String user_name) {return userMapper.registJudge(user_name);}// 更改密码public Integer resetPassword(String user_name, String newUser_password) {return userMapper.resetPassword(user_name, newUser_password);}// 判断用户名是否重复@Overridepublic String rearchUserName(String user_name) {return userMapper.rearchUserName(user_name);}
}

package com.bjpowernode.music.ss.controller.base;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import com.bjpowernode.music.common.WebResponse;
import com.bjpowernode.music.ss.domain.MusicLink;
import com.bjpowernode.music.ss.domain.User;
import com.bjpowernode.music.ss.service.impl.MusicLinkService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
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.ResponseBody;
import com.bjpowernode.music.ss.service.IMusicLinkService;
/**
*
*
*
*/
@Controller
@RequestMapping("/musicLink")
public class MusicLinkController {
@Autowired
protected WebResponse webResponse;
@Resource
protected IMusicLinkService musicLinkService;
@Resource
protected MusicLinkService musicLinkService2;
/**
* //常用注解快速解释:
* @Controller :用于标记在一个类上,使用它标记的类就是一个SpringMVC Controller 对象。
* 分发处理器将会扫描使用了该注解的类的方法,并检测该方法是否使用了@RequestMapping 注解。@Controller
* 只是定义了一个控制器类,而使用@RequestMapping 注解的方法才是真正处理请求的处理器。
*
* @RequestMapping :是一个用来处理请求地址映射的注解,可用于类或方法上。
* 用于类上,表示类中的所有响应请求的方法都是以该地址作为父路径;
* 用于方法上,表示在类的父路径下追加方法上注解中的地址将会访问到该方法
*
* @Autowired:@Autowired 注释,它可以对类成员变量、方法及构造函数进行标注,完成自动装配的工作。 通过 @Autowired的使用来消除 set ,get方法。
*
*
* @Resource:@Autowired与@Resource都可以用来装配bean. 都可以写在字段上,或写在setter方法上。
*
*
* @Responsebody 注解表示该方法的返回的结果直接写入 HTTP 响应正文(ResponseBody)中,
* 一般在异步获取数据时使用,通常是在使用 @RequestMapping 后,返回值通常解析为跳转路径,
* 加上 @Responsebody 后返回结果不会被解析为跳转路径,而是直接写入HTTP 响应正文中。
* 作用: 该注解用于将Controller的方法返回的对象,通过适当的HttpMessageConverter转换为指定格式后,写入到Response对象的body数据区。
*
*
*
*
* @RequestParam(value="aa" required=false)
* 1.可以对传入参数指定参数名
*
* // 下面的对传入参数指定为aa,如果前端不传aa参数名,会报错
* @RequestParam(value="aa") String inputStr
*
* 2、可以通过required=false或者true来要求@RequestParam配置的前端参数是否一定要传
*
* 3、如果@requestParam注解的参数是int类型,并且required=false,此时如果不传参数的话,会报错。原因是,required=false时,不传参数的话,
* 会给参数赋值null,这样就会把null赋值给了int,因此会报错。
*
*
*
*/
// 从数据库中获取歌曲数据,在榜单中显示
@RequestMapping(value = "/getMusicLinkList", method = RequestMethod.POST, produces = "application/json;charset=UTF-8")
@ResponseBody
public WebResponse getMusicLinkList(HttpServletRequest request, HttpServletResponse response, HttpSession session,
@RequestParam(defaultValue = "1", required = false) Integer pageNo,
@RequestParam(defaultValue = "30", required = false) Integer pageSize,
@RequestParam(defaultValue = "正常", required = false) String tbStatus,
@RequestParam(required = false) String keyword,
@RequestParam(defaultValue = "ml_id", required = false) String order,
@RequestParam(defaultValue = "desc", required = false) String desc) {
Object data = null;
String statusMsg = "";
int statusCode = 200;
LinkedHashMap<String, String> condition = new LinkedHashMap<String, String>();
/*
* if (tbStatus != null && tbStatus.length() > 0) { condition.put("tb_status='"
* + tbStatus + "'", "and"); }
*/
if (keyword != null && keyword.length() > 0) {
StringBuffer buf = new StringBuffer();
buf.append("(");
buf.append("test_name like '%").append(keyword).append("%'");
buf.append(" or ");
buf.append("info like '%").append(keyword).append("%'");
buf.append(" or ");
buf.append("other like '%").append(keyword).append("%'");
buf.append(")");
condition.put(buf.toString(), "and");
}
String field = null;
if (condition.size() > 0) {
condition.put(condition.entrySet().iterator().next().getKey(), "");
}
int count = this.musicLinkService.getCount(condition, field);
if (order != null && order.length() > 0 & "desc".equals(desc)) {
order = order + " desc";
}
// 从数据库中获取数据,并把对象的结果集存到list列表中
List<MusicLink> list = this.musicLinkService.getList(condition, pageNo, pageSize, order, field);
Map<Object, Object> map = new HashMap<Object, Object>();
map.put("total", count);
// 如果数据库有15条音乐,则list中有15个对象,则size的大小为15
int size = list.size();
if (size > 0) {
List<MusicLink> listFont = new ArrayList<MusicLink>();
MusicLink vo;
MusicLink voFont = new MusicLink();
// 循环将获取到的对象及结构属性克隆到一个新的voFont对象中,并保存到动态数组中
for (int i = 0; i < size; i++) {
vo = list.get(i);
// 通过java反射将类中当前属性字段对应的内容复制到另外一个类中
BeanUtils.copyProperties(vo, voFont);
listFont.add(voFont);
voFont = new MusicLink();
}
map.put("list", listFont);
// data是一个map对象
data = map;
statusMsg = "根据条件获取分页数据成功!!!";
} else {
map.put("list", list);
data = map;
statusCode = 202;
statusMsg = "no record!!!";
return webResponse.getWebResponse(statusCode, statusMsg, data);
}
return webResponse.getWebResponse(statusCode, statusMsg, data);
}
// 歌曲搜索功能
@RequestMapping(value = "/getSongRearch", method = RequestMethod.POST, produces = "application/json;charset=UTF-8")
@ResponseBody
public WebResponse getSongRearch(HttpServletRequest request, HttpServletResponse response, HttpSession session,
@RequestParam(required = false) String songName) {
Object data = null;
String statusMsg = "";
int statusCode = 200;
// 调用Mapper层的songRearch方法,进行数据库的操作
List<MusicLink> list = this.musicLinkService2.songRearch(songName);
int count = list.size();
System.out.println();
System.out.println("搜索到的歌曲数:" + count);
System.out.println("结束");
Map<Object, Object> map = new HashMap<Object, Object>();
map.put("total", count);
int size = list.size();
if (size > 0) {
List<MusicLink> listFont = new ArrayList<MusicLink>();
MusicLink vo;
MusicLink voFont = new MusicLink();
for (int i = 0; i < size; i++) {
vo = list.get(i);
BeanUtils.copyProperties(vo, voFont);
listFont.add(voFont);
voFont = new MusicLink();
}
map.put("list", listFont);
data = map;
//for (int i = 0; i < map.size(); i++) {
//System.out.println(map.get(listFont).toString());
//}
//
statusMsg = "根据条件获取分页数据成功!!!";
} else {
map.put("list", list);
data = map;
statusCode = 202;
statusMsg = "no record!!!";
return webResponse.getWebResponse(statusCode, statusMsg, data);
}
return webResponse.getWebResponse(statusCode, statusMsg, data);
}
// 歌曲收藏
@RequestMapping(value = "/addMusicCollect", method = RequestMethod.POST, produces = "application/json;charset=UTF-8")
@ResponseBody
public WebResponse addMusicCollect(HttpServletRequest request, HttpServletResponse response, HttpSession session,
@RequestParam(required = false) int song_id, @RequestParam(required = false) String user_name,
@RequestParam(required = false) String user_password, @RequestParam(required = false) String songName) {
WebResponse webResponse = new WebResponse();
MusicLink musicLink = new MusicLink();
User user = new User();
System.out.println("歌曲id:" + song_id + " 用户名:" + user_name + " 户用密码:" + user_password);
Object data = null;
String statusMsg = "";
int statusCode = 200;
String user_Id = null;
try {
user_Id = musicLinkService2.getUserId(user_name, user_password);
} catch (Exception e) {
}
int userId = 0;
try {
// 判断字符串是否是数字,并且抛出异常
boolean NotisNum = (user_Id.equals("null"));
// System.out.println(NotisNum);
if (!NotisNum) {
userId = Integer.parseInt(user_Id);
}
} catch (Exception e) {
}
System.out.println("歌曲名:" + songName);
String jSong = this.musicLinkService.judgeSong(songName, userId);
int my_Id = 0;
try {
// 判断字符串是否是数字,并且抛出异常
// boolean NotisNum
// =(user_Id.equals(null)||user_Id.equals("")||user_Id.equals("null"));
boolean NotisNum = (jSong.equals("null"));
if (!NotisNum) {
my_Id = Integer.parseInt(jSong);
}
} catch (Exception e) {
}
if (my_Id > 0) {
statusCode = 201;
statusMsg = "已收藏,请不要重复收藏!";
} else {
this.musicLinkService.insertSongRearch(song_id, userId);
}
System.out.println("收藏歌曲的用户id:" + userId);
return webResponse.getWebResponse(statusCode, statusMsg, data);
}
}

免费领取下载链接-关注底部gongzhonghao:029

(免费分享)springboot音乐网站相关推荐

  1. 一款基于SpringBoot 音乐网站项目

    本音乐网站的客户端和管理端使用 VUE 框架来实现,服务端使用 Spring Boot + MyBatis 来实现,数据库使用了 MySQL. 项目功能 音乐播放 用户登录注册 用户信息编辑.头像修改 ...

  2. 基于springboot音乐网站与分享平台

    开发语言:Java 框架:springboot JDK版本:JDK1.8 服务器:tomcat7 数据库:mysql 数据库工具:Navicat11 开发软件:eclipse/myeclipse/id ...

  3. 【项目精选】springboot音乐网站与分享平台(论文+源码)

  4. (免费分享)springboot论坛bbs系统

    源码获取:关注文末gongzhonghao,输入010领取下载链接 开发工具:IDEA 数据库mysql5.7 技术:springboot+jpa+shiro+redis+layui 前台截图: 后台 ...

  5. Java+SpringBoot音乐网站(含源码+论文+答辩PPT等)

    项目功能简介: 该项目含有源码.论文等资料.配套开发软件.软件安装教程.项目发布教程等 Java--涉及技术: 后端使用技术:SpringBoot(SSM)等 数据库:MySQL数据库 主要功能: 前 ...

  6. 免费分享设计素材网站

    视频素材:https://mixkit.co 音效类:https://www.ear0.com 文字转语音:https://www.6pian.cn 字幕类:https://jianwai.youda ...

  7. 开源案例:Spring Boot + Vue 的音乐网站

    不知不觉这居家隔离也快一个月了,上海发布这每天增长的数字,也让人不知道什么时候是个头,不少居家许久的邻居,甚至拿出了低音炮享受起了音乐. 所以今天和大家分享一个音乐网站吧. music-website ...

  8. Springboot+vue项目音乐网站与分享平台

    文末获取源码 开发语言:Java 开发工具:IDEA /Eclipse 数据库:MYSQL5.7 应用服务:Tomcat7/Tomcat8 使用框架:springboot+vue JDK版本:jdk1 ...

  9. java基于Springboot+vue的在线听歌音乐网站与分享平台 elementui

    音乐网站与分享平台的主要使用者分为管理员和用户,实现功能包括管理员:首页.个人中心.用户管理.音乐资讯管理.音乐翻唱管理.在线听歌管理.留言板管理.系统管理,用户:首页.个人中心.音乐翻唱管理.我的收 ...

最新文章

  1. fancybox关闭弹出窗体parent.$.fancybox.close();
  2. Boost:bind绑定和或||的测试程序
  3. 重磅 | 20+技术大咖齐聚 阿里云数据库创新上云峰会进入一周倒计时
  4. Nginx静态资源优化配置之sendfile
  5. ubuntu 编译mysql_Ubuntu编译MySQL5
  6. 关于python2到python3更新的一些书写规则的更改
  7. Linux Server 安装 raid 1
  8. feign post 传递空值_http中post和get的区别和联系
  9. 求生之路显示服务器指令,求生之路2控制台指令..doc
  10. Style后台动态定义[转]
  11. 开万人 AI 大会什么感受?陆奇任大会主席 | AI ProCon 2020
  12. windows 运行banana
  13. unix--Tripwire 应用
  14. Java开发 音视频会议
  15. SetWindowsHookEx 全局钩子
  16. 由于系统缓冲区空间不足或队列已满,不能执行套接字上的操作
  17. linux shell变量的,linux shell变量解析
  18. 给孩子炖鳄鱼?时代变了,就比谁会玩儿...
  19. 创建vue项目的时候报错:Skipped git commit due to missing username and email in git config.
  20. 客户端与服务器端的区别

热门文章

  1. 对学校的希望和寄语_对学校寄语怎么写
  2. win10+Ubuntu双系统 Easybcd安装
  3. 微信小程序实现两个页面之间的跳转
  4. Ubuntu 一键美化
  5. 【Python】Python中的迭代器和生成器
  6. 被程序员鄙视的“开发者5个等级”划分
  7. java 二维数组排序 sort_js sort 二维数组排序的用法小结
  8. oppoa5系统服务器是什么,oppoa52是什么处理器
  9. 谷歌浏览器完整显示URL网址
  10. vue3.0 配置@根路径