1.技术介绍
java+springboot+mybatis+mysql+jsp
开发工具:eclipse或IDEA
2.主要功能说明:
网站前台
用户注册、登录、首页音乐分类、在线播放、收藏、评分、留言、音乐榜单、视频MV、我的音乐收藏、个人中心、退出登录、光于我们
管理后台
管理员管理、用户管理、标签管理、关于我们管理、音乐管理、MV管理、友情链接管理、留言管理
3.部分代码展示
/**
* 页面请求控制 音乐管理
*/
@Controller
public class ArticleController {
@Autowired
ArticleMapper articleMapper;
@Autowired
SorttypeMapper sorttypeMapper;
/**
* 跳转到列表页面
*
* @return
*/
@RequestMapping("manage/articleList")
public String articleList() {
return "manage/article/articleList";
}
/**
* 跳转到添加页面
*
* @return
*/
@RequestMapping("manage/addArticle")
public String addArticle(Model model) {
List<Sorttype> sorttypeList = sorttypeMapper.selectAll(null);
model.addAttribute("sorttypeList", sorttypeList);
return "manage/article/saveArticle";
}
/**
* 跳转到修改页面
*
* @param id
* @param model
* @return
*/
@RequestMapping("manage/editArticle")
public String editArticle(Integer id, Model model) {
List<Sorttype> sorttypeList = sorttypeMapper.selectAll(null);
model.addAttribute("sorttypeList", sorttypeList);
Article article = articleMapper.selectArticleById(id);
model.addAttribute("article", article);
return "manage/article/saveArticle";
}
/**
* 查看详情页面
*
* @param id
* @param model
* @return
*/
@RequestMapping("manage/articleInfo")
public String articleInfo(Integer id, Model model) {
Article article = articleMapper.selectArticleById(id);
model.addAttribute("article", article);
return "manage/article/articleInfo";
}
/**
* 分页查询
*
* @param page 默认第一页
* @param limit 默认每页显示10条
* @return
*/
@RequestMapping("manage/queryArticleList")
@ResponseBody
public ResultUtil getCarouseList(Integer page, Integer limit, String keyword) {
if (null == page) { //默认第一页
page = 1;
}
if (null == limit) { //默认每页10条
limit = 10;
}
Map map = new HashMap();
if (StringUtils.isNotEmpty(keyword)) {
map.put("keyword", keyword);
}
Page pageHelper = PageHelper.startPage(page, limit, true);
pageHelper.setOrderBy(" id desc ");
List<Article> list = articleMapper.selectAll(map);
PageInfo<Article> pageInfo = new PageInfo<Article>(list); //使用mybatis分页插件
ResultUtil resultUtil = new ResultUtil();
resultUtil.setCode(0); //设置返回状态0为成功
resultUtil.setCount(pageInfo.getTotal()); //获取总记录数目 类似count(*)
resultUtil.setData(pageInfo.getList()); //获取当前查询出来的集合
return resultUtil;
}
/**
* 插入记录
*/
@RequestMapping("manage/saveArticle")
@ResponseBody
public ResultUtil saveArticle(Article article, HttpSession session) {
Date nowTime = new Date();
article.setCreatetime(nowTime);
try {
articleMapper.insertArticle(article);
return ResultUtil.ok("添加音乐成功");
} catch (Exception e) {
return ResultUtil.error("添加音乐出错,稍后再试!");
}
}
/**
* 更新记录
*/
@RequestMapping("manage/updateArticle")
@ResponseBody
public ResultUtil updateArticle(Article article, HttpSession session) {
Date nowTime = new Date();
article.setCreatetime(nowTime);
try {
articleMapper.updateArticle(article);
return ResultUtil.ok("修改音乐成功");
} catch (Exception e) {
return ResultUtil.error("修改音乐出错,稍后再试!");
}
}
/**
* 根据ID删除
*
* @param id
* @return
*/
@RequestMapping("manage/deleteArticle")
@ResponseBody
public ResultUtil deleteArticleById(Integer id) {
try {
articleMapper.deleteArticleById(id);
return ResultUtil.ok("删除音乐成功");
} catch (Exception e) {
return ResultUtil.error("删除音乐出错,稍后再试!");
}
}
/**
* 根据ID批量删除
*
* @param idsStr
* @return
*/
@RequestMapping("manage/deletesArticle")
@ResponseBody
public ResultUtil deletesArticle(String idsStr) {
try {
if (!StringUtils.isBlank(idsStr)) {
String[] ids = idsStr.split(",");
for (String id : ids) {
articleMapper.deleteArticleById(Integer.parseInt(id));
}
}
return ResultUtil.ok("批量删除音乐成功");
} catch (Exception e) {
return ResultUtil.error("删除音乐出错,稍后再试!");
}
}
}```
4.系统演示地址:
链接:https://pan.baidu.com/s/1wBMpGTwzgR3BNSUXAWhbRQ
提取码:ttyq