项目介绍
音乐网站与分享平台的主要使用者分为管理员和用户,实现功能包括管理员:首页、个人中心、用户管理、音乐资讯管理、音乐翻唱管理、在线听歌管理、留言板管理、论坛交流管理、系统管理,用户:首页、个人中心、音乐翻唱管理、我的收藏管理、我的留言管理、论坛交流管理,前台首页;首页、音乐资讯、音乐翻唱、在线听歌、歌曲下载、留言反馈、个人中心、后台管理、在线客服等功能。由于本网站的功能模块设计比较全面,所以使得整个音乐网站与分享平台信息管理的过程得以实现。
开发环境
开发语言:Java
数据库 :MySQL
系统架构:B/S
后端框架:SpringBoot
前端框架:Vue
开发工具:IDEA或者Eclipse,JDK1.8,Maven
系统截图
部分代码
package com.controller;
import com.annotation.IgnoreAuth;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.entity.*;
import com.service.*;
import com.utils.MPUtil;
import com.utils.PageUtils;
import com.utils.R;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import java.util.*;
@RestController
@RequestMapping("/song")
public class SongController {
@Autowired
private SongService songService;
@Autowired
private YonghuService yonghuService;
@Autowired
private FenleiService fenleiService;
/**
* 后端列表
*/
@RequestMapping("/page")
public R page(@RequestParam Map<String, Object> params, SongEntity song,
HttpServletRequest request){
EntityWrapper<SongEntity> ew = new EntityWrapper<SongEntity>();
if(request.getSession().getAttribute("role").toString().equals("会员")) {
Long yonghuid=(Long)request.getSession().getAttribute("userId");
ew.eq("yonghuid",yonghuid);
}
PageUtils page = songService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, song), params), params));
for(int i=0;i<page.getList().size();i++){
SongEntity songEntity = (SongEntity) page.getList().get(i);
FenleiEntity fenleiEntity=fenleiService.selectById(songEntity.getFenleiid());
songEntity.setFenleiEntity(fenleiEntity);
}
return R.ok().put("data", page);
}
/**
* 查询所有
* @param request
* @return
*/
@RequestMapping("/findAll")
public R findAll(HttpServletRequest request) {
EntityWrapper<SongEntity> ew = new EntityWrapper<SongEntity>();
List<SongEntity> songEntityList = songService.selectList(ew);
return R.ok().put("data", songEntityList);
}
/**
* 前端列表
*/
@IgnoreAuth
@RequestMapping("/list")
public R list(@RequestParam Map<String, Object> params, SongEntity song, HttpServletRequest request){
EntityWrapper<SongEntity> ew = new EntityWrapper<SongEntity>();
PageUtils page = songService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, song), params), params));
return R.ok().put("data", page);
}
/**
* 前端智能排序
*/
@IgnoreAuth
@RequestMapping("/autoSort")
public R autoSort(@RequestParam Map<String, Object> params, SongEntity songEntity, HttpServletRequest request, String pre){
EntityWrapper<SongEntity> ew = new EntityWrapper<SongEntity>();
Map<String, Object> newMap = new HashMap<String, Object>();
Map<String, Object> param = new HashMap<String, Object>();
Iterator<Map.Entry<String, Object>> it = param.entrySet().iterator();
while (it.hasNext()) {
Map.Entry<String, Object> entry = it.next();
String key = entry.getKey();
String newKey = entry.getKey();
if (pre.endsWith(".")) {
newMap.put(pre + newKey, entry.getValue());
} else if (StringUtils.isEmpty(pre)) {
newMap.put(newKey, entry.getValue());
} else {
newMap.put(pre + "." + newKey, entry.getValue());
}
}
params.put("order", "desc");
PageUtils page = songService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, songEntity), params), params));
return R.ok().put("data", page);
}
/**
* 后端详情
*/
@RequestMapping("/info/{id}")
public R info(@PathVariable("id") Long id){
SongEntity song = songService.selectById(id);
FenleiEntity fenleiEntity=fenleiService.selectById(song.getFenleiid());
song.setFenleiEntity(fenleiEntity);
return R.ok().put("data", song);
}
/**
* 前端详情
*/
@IgnoreAuth
@RequestMapping("/detail/{id}")
public R detail(@PathVariable("id") Long id){
SongEntity song = songService.selectById(id);
FenleiEntity fenleiEntity=fenleiService.selectById(song.getFenleiid());
song.setFenleiEntity(fenleiEntity);
return R.ok().put("data", song);
}
/**
* 后端保存
*/
@RequestMapping("/save")
public R save(@RequestBody SongEntity song, HttpServletRequest request){
if(request.getSession().getAttribute("role").toString().equals("会员")) {
Long yonghuid=(Long)request.getSession().getAttribute("userId");
YonghuEntity yonghuEntity=yonghuService.selectById(yonghuid);
song.setYonghuid(yonghuid);
song.setYonghuming(yonghuEntity.getYonghuming());
}
songService.insert(song);
return R.ok();
}
/**
* 前端保存
*/
@RequestMapping("/add")
public R add(@RequestBody SongEntity song, HttpServletRequest request){
songService.insert(song);
return R.ok();
}
/**
* 修改
*/
@RequestMapping("/update")
public R update(@RequestBody SongEntity song, HttpServletRequest request){
songService.updateById(song);
return R.ok();
}
/**
* 删除
*/
@RequestMapping("/delete")
public R delete(@RequestBody Long[] ids){
songService.deleteBatchIds(Arrays.asList(ids));
return R.ok();
}
}
package com.controller;
import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Map;
import java.util.Date;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import com.entity.FenleiEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.entity.view.FenleiView;
import com.service.FenleiService;
import com.utils.PageUtils;
import com.utils.R;
import com.utils.MPUtil;
/**
* 分类
* 后端接口
*/
@RestController
@RequestMapping("/fenlei")
public class FenleiController {
@Autowired
private FenleiService fenleiService;
/**
* 后端列表
*/
@RequestMapping("/page")
public R page(@RequestParam Map<String, Object> params, FenleiEntity fenlei,
HttpServletRequest request){
EntityWrapper<FenleiEntity> ew = new EntityWrapper<FenleiEntity>();
PageUtils page = fenleiService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, fenlei), params), params));
return R.ok().put("data", page);
}
/**
* 查询所有
* @param request
* @return
*/
@RequestMapping("/findAll")
public R findAll(HttpServletRequest request) {
EntityWrapper<FenleiEntity> ew = new EntityWrapper<FenleiEntity>();
List<FenleiEntity> fenleiEntityList = fenleiService.selectList(ew);
return R.ok().put("data", fenleiEntityList);
}
/**
* 前端列表
*/
@RequestMapping("/list")
public R list(@RequestParam Map<String, Object> params, FenleiEntity fenlei, HttpServletRequest request){
EntityWrapper<FenleiEntity> ew = new EntityWrapper<FenleiEntity>();
PageUtils page = fenleiService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, fenlei), params), params));
return R.ok().put("data", page);
}
/**
* 列表
*/
@RequestMapping("/lists")
public R list( FenleiEntity fenlei){
EntityWrapper<FenleiEntity> ew = new EntityWrapper<FenleiEntity>();
ew.allEq(MPUtil.allEQMapPre( fenlei, "fenlei"));
return R.ok().put("data", fenleiService.selectListView(ew));
}
/**
* 查询
*/
@RequestMapping("/query")
public R query(FenleiEntity fenlei){
EntityWrapper<FenleiEntity> ew = new EntityWrapper<FenleiEntity>();
ew.allEq(MPUtil.allEQMapPre( fenlei, "fenlei"));
FenleiView fenleiView = fenleiService.selectView(ew);
return R.ok("查询分类成功").put("data", fenleiView);
}
/**
* 后端详情
*/
@RequestMapping("/info/{id}")
public R info(@PathVariable("id") Long id){
FenleiEntity fenlei = fenleiService.selectById(id);
return R.ok().put("data", fenlei);
}
/**
* 前端详情
*/
@RequestMapping("/detail/{id}")
public R detail(@PathVariable("id") Long id){
FenleiEntity fenlei = fenleiService.selectById(id);
return R.ok().put("data", fenlei);
}
/**
* 后端保存
*/
@RequestMapping("/save")
public R save(@RequestBody FenleiEntity fenlei, HttpServletRequest request){
fenlei.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue());
//ValidatorUtils.validateEntity(fenlei);
fenleiService.insert(fenlei);
return R.ok();
}
/**
* 前端保存
*/
@RequestMapping("/add")
public R add(@RequestBody FenleiEntity fenlei, HttpServletRequest request){
fenlei.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue());
//ValidatorUtils.validateEntity(fenlei);
fenleiService.insert(fenlei);
return R.ok();
}
/**
* 修改
*/
@RequestMapping("/update")
public R update(@RequestBody FenleiEntity fenlei, HttpServletRequest request){
//ValidatorUtils.validateEntity(fenlei);
fenleiService.updateById(fenlei);//全部更新
return R.ok();
}
/**
* 删除
*/
@RequestMapping("/delete")
public R delete(@RequestBody Long[] ids){
fenleiService.deleteBatchIds(Arrays.asList(ids));
return R.ok();
}
/**
* 提醒接口
*/
@RequestMapping("/remind/{columnName}/{type}")
public R remindCount(@PathVariable("columnName") String columnName, HttpServletRequest request,
@PathVariable("type") String type,@RequestParam Map<String, Object> map) {
map.put("column", columnName);
map.put("type", type);
if(type.equals("2")) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
Calendar c = Calendar.getInstance();
Date remindStartDate = null;
Date remindEndDate = null;
if(map.get("remindstart")!=null) {
Integer remindStart = Integer.parseInt(map.get("remindstart").toString());
c.setTime(new Date());
c.add(Calendar.DAY_OF_MONTH,remindStart);
remindStartDate = c.getTime();
map.put("remindstart", sdf.format(remindStartDate));
}
if(map.get("remindend")!=null) {
Integer remindEnd = Integer.parseInt(map.get("remindend").toString());
c.setTime(new Date());
c.add(Calendar.DAY_OF_MONTH,remindEnd);
remindEndDate = c.getTime();
map.put("remindend", sdf.format(remindEndDate));
}
}
Wrapper<FenleiEntity> wrapper = new EntityWrapper<FenleiEntity>();
if(map.get("remindstart")!=null) {
wrapper.ge(columnName, map.get("remindstart"));
}
if(map.get("remindend")!=null) {
wrapper.le(columnName, map.get("remindend"));
}
int count = fenleiService.selectCount(wrapper);
return R.ok().put("count", count);
}
}