基于javaweb+mysql的springboot新闻视频发布推荐评论系统(java+springboot+maven+vue+mysql+html)
私信源码获取及调试交流
运行环境
Java≥8、MySQL≥5.7、Node.js≥10
开发工具
后端:eclipse/idea/myeclipse/sts等均可配置运行
前端:WebStorm/VSCode/HBuilderX等均可
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
功能说明
基于javaweb的SpringBoot新闻视频发布推荐评论系统(java+springboot+maven+vue+mysql+html)
管理员
admin 123456
用户:
用户1 123456
用户2 123456
用户3 123456
用户4 123456
用户5 123456
用户6 123456
front-end-admin前端如果要单独运行,启动命令为:npm run serve
/** * 上传文件映射表 */ @RestController @RequestMapping("file") @SuppressWarnings({"unchecked","rawtypes"}) public class FileController{ @Autowired private ConfigService configService; /** * 上传文件 */ @RequestMapping("/upload") public R upload(@RequestParam("file") MultipartFile file,String type) throws Exception { if (file.isEmpty()) { throw new EIException("上传文件不能为空"); } String fileExt = file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf(".")+1); File path = new File(ResourceUtils.getURL("classpath:static").getPath()); if(!path.exists()) { path = new File(""); } File upload = new File(path.getAbsolutePath(),"/upload/"); if(!upload.exists()) { upload.mkdirs(); } String fileName = new Date().getTime()+"."+fileExt; File dest = new File(upload.getAbsolutePath()+"/"+fileName); file.transferTo(dest); if(StringUtils.isNotBlank(type) && type.equals("1")) { ConfigEntity configEntity = configService.selectOne(new EntityWrapper<ConfigEntity>().eq("name", "faceFile")); if(configEntity==null) { configEntity = new ConfigEntity(); configEntity.setName("faceFile"); configEntity.setValue(fileName); } else { configEntity.setValue(fileName); } configService.insertOrUpdate(configEntity); } return R.ok().put("file", fileName); } /** * 下载文件 */ @IgnoreAuth @RequestMapping("/download") public ResponseEntity<byte[]> download(@RequestParam String fileName) { try {
@IgnoreAuth @RequestMapping("/detail/{id}") public R detail(@PathVariable("id") Long id){ XinwenEntity xinwen = xinwenService.selectById(id); xinwen.setClicknum(xinwen.getClicknum()+1); xinwen.setClicktime(new Date()); xinwenService.updateById(xinwen); return R.ok().put("data", xinwen); } /** * 赞或踩 */ @RequestMapping("/thumbsup/{id}") public R vote(@PathVariable("id") String id,String type){ XinwenEntity xinwen = xinwenService.selectById(id); if(type.equals("1")) { xinwen.setThumbsupnum(xinwen.getThumbsupnum()+1); } else { xinwen.setCrazilynum(xinwen.getCrazilynum()+1); } xinwenService.updateById(xinwen); return R.ok("投票成功"); } /** * 后端保存 */ @RequestMapping("/save") public R save(@RequestBody XinwenEntity xinwen, HttpServletRequest request){ xinwen.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue()); //ValidatorUtils.validateEntity(xinwen); xinwenService.insert(xinwen); return R.ok(); } /** * 前端保存 */ @RequestMapping("/add") public R add(@RequestBody XinwenEntity xinwen, HttpServletRequest request){ xinwen.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue()); //ValidatorUtils.validateEntity(xinwen); xinwenService.insert(xinwen); return R.ok(); } /** * 修改 */ @RequestMapping("/update")
} /** * 列表 */ @RequestMapping("/lists") public R list( StoreupEntity storeup){ EntityWrapper<StoreupEntity> ew = new EntityWrapper<StoreupEntity>(); ew.allEq(MPUtil.allEQMapPre( storeup, "storeup")); return R.ok().put("data", storeupService.selectListView(ew)); } /** * 查询 */ @RequestMapping("/query") public R query(StoreupEntity storeup){ EntityWrapper< StoreupEntity> ew = new EntityWrapper< StoreupEntity>(); ew.allEq(MPUtil.allEQMapPre( storeup, "storeup")); StoreupView storeupView = storeupService.selectView(ew); return R.ok("查询收藏表成功").put("data", storeupView); } /** * 后端详情 */ @RequestMapping("/info/{id}") public R info(@PathVariable("id") Long id){ StoreupEntity storeup = storeupService.selectById(id); return R.ok().put("data", storeup); } /** * 前端详情 */ @RequestMapping("/detail/{id}") public R detail(@PathVariable("id") Long id){ StoreupEntity storeup = storeupService.selectById(id); return R.ok().put("data", storeup); } /** * 后端保存 */ @RequestMapping("/save") public R save(@RequestBody StoreupEntity storeup, HttpServletRequest request){ storeup.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue());
public R page(@RequestParam Map<String, Object> params,ConfigEntity config){ EntityWrapper<ConfigEntity> ew = new EntityWrapper<ConfigEntity>(); PageUtils page = configService.queryPage(params); return R.ok().put("data", page); } /** * 列表 */ @IgnoreAuth @RequestMapping("/list") public R list(@RequestParam Map<String, Object> params,ConfigEntity config){ EntityWrapper<ConfigEntity> ew = new EntityWrapper<ConfigEntity>(); PageUtils page = configService.queryPage(params); return R.ok().put("data", page); } /** * 信息 */ @RequestMapping("/info/{id}") public R info(@PathVariable("id") String id){ ConfigEntity config = configService.selectById(id); return R.ok().put("data", config); } /** * 详情 */ @IgnoreAuth @RequestMapping("/detail/{id}") public R detail(@PathVariable("id") String id){ ConfigEntity config = configService.selectById(id); return R.ok().put("data", config); } /** * 根据name获取信息 */ @RequestMapping("/info") public R infoByName(@RequestParam String name){ ConfigEntity config = configService.selectOne(new EntityWrapper<ConfigEntity>().eq("name", "faceFile")); return R.ok().put("data", config); } /** * 保存 */ @PostMapping("/save") public R save(@RequestBody ConfigEntity config){ // ValidatorUtils.validateEntity(config); configService.insert(config); return R.ok(); }
/** * 前端详情 */ @RequestMapping("/detail/{id}") public R detail(@PathVariable("id") Long id){ YonghuEntity yonghu = yonghuService.selectById(id); return R.ok().put("data", yonghu); } /** * 后端保存 */ @RequestMapping("/save") public R save(@RequestBody YonghuEntity yonghu, HttpServletRequest request){ yonghu.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue()); //ValidatorUtils.validateEntity(yonghu); YonghuEntity user = yonghuService.selectOne(new EntityWrapper<YonghuEntity>().eq("zhanghao", yonghu.getZhanghao())); if(user!=null) { return R.error("用户已存在"); } yonghu.setId(new Date().getTime()); yonghuService.insert(yonghu); return R.ok(); } /** * 前端保存 */ @RequestMapping("/add") public R add(@RequestBody YonghuEntity yonghu, HttpServletRequest request){ yonghu.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue()); //ValidatorUtils.validateEntity(yonghu); YonghuEntity user = yonghuService.selectOne(new EntityWrapper<YonghuEntity>().eq("zhanghao", yonghu.getZhanghao())); if(user!=null) { return R.error("用户已存在"); } yonghu.setId(new Date().getTime());
/** * 后端列表 */ @RequestMapping("/page") public R page(@RequestParam Map<String, Object> params,DiscussxinwenEntity discussxinwen, HttpServletRequest request){ EntityWrapper<DiscussxinwenEntity> ew = new EntityWrapper<DiscussxinwenEntity>(); PageUtils page = discussxinwenService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, discussxinwen), params), params)); return R.ok().put("data", page); } /** * 前端列表 */ @IgnoreAuth @RequestMapping("/list") public R list(@RequestParam Map<String, Object> params,DiscussxinwenEntity discussxinwen, HttpServletRequest request){ EntityWrapper<DiscussxinwenEntity> ew = new EntityWrapper<DiscussxinwenEntity>(); PageUtils page = discussxinwenService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, discussxinwen), params), params)); return R.ok().put("data", page); } /** * 列表 */ @RequestMapping("/lists") public R list( DiscussxinwenEntity discussxinwen){ EntityWrapper<DiscussxinwenEntity> ew = new EntityWrapper<DiscussxinwenEntity>(); ew.allEq(MPUtil.allEQMapPre( discussxinwen, "discussxinwen")); return R.ok().put("data", discussxinwenService.selectListView(ew)); } /** * 查询 */ @RequestMapping("/query") public R query(DiscussxinwenEntity discussxinwen){ EntityWrapper< DiscussxinwenEntity> ew = new EntityWrapper< DiscussxinwenEntity>(); ew.allEq(MPUtil.allEQMapPre( discussxinwen, "discussxinwen")); DiscussxinwenView discussxinwenView = discussxinwenService.selectView(ew); return R.ok("查询新闻评论表成功").put("data", discussxinwenView); }
* 前端保存 */ @RequestMapping("/add") public R add(@RequestBody StoreupEntity storeup, HttpServletRequest request){ storeup.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue()); //ValidatorUtils.validateEntity(storeup); storeup.setUserid((Long)request.getSession().getAttribute("userId")); storeupService.insert(storeup); return R.ok(); } /** * 修改 */ @RequestMapping("/update") public R update(@RequestBody StoreupEntity storeup, HttpServletRequest request){ //ValidatorUtils.validateEntity(storeup); storeupService.updateById(storeup);//全部更新 return R.ok(); } /** * 删除 */ @RequestMapping("/delete") public R delete(@RequestBody Long[] ids){ storeupService.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));
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<StoreupEntity> wrapper = new EntityWrapper<StoreupEntity>(); if(map.get("remindstart")!=null) { wrapper.ge(columnName, map.get("remindstart")); } if(map.get("remindend")!=null) { wrapper.le(columnName, map.get("remindend")); } if(!request.getSession().getAttribute("role").toString().equals("管理员")) { wrapper.eq("userid", (Long)request.getSession().getAttribute("userId")); } int count = storeupService.selectCount(wrapper); return R.ok().put("count", count); } }
} /** * 后端详情 */ @RequestMapping("/info/{id}") public R info(@PathVariable("id") Long id){ DiscussxinwenEntity discussxinwen = discussxinwenService.selectById(id); return R.ok().put("data", discussxinwen); } /** * 前端详情 */ @RequestMapping("/detail/{id}") public R detail(@PathVariable("id") Long id){ DiscussxinwenEntity discussxinwen = discussxinwenService.selectById(id); return R.ok().put("data", discussxinwen); } /** * 后端保存 */ @RequestMapping("/save") public R save(@RequestBody DiscussxinwenEntity discussxinwen, HttpServletRequest request){ discussxinwen.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue()); //ValidatorUtils.validateEntity(discussxinwen); discussxinwenService.insert(discussxinwen); return R.ok(); } /** * 前端保存 */ @RequestMapping("/add") public R add(@RequestBody DiscussxinwenEntity discussxinwen, HttpServletRequest request){ discussxinwen.setId(new Date().getTime()+new Double(Math.floor(Math.random()*1000)).longValue()); //ValidatorUtils.validateEntity(discussxinwen); discussxinwenService.insert(discussxinwen); return R.ok(); } /** * 修改 */ @RequestMapping("/update") public R update(@RequestBody DiscussxinwenEntity discussxinwen, HttpServletRequest request){
* @param column * @return */ @IgnoreAuth @RequestMapping("/follow/{tableName}/{columnName}") public R getFollowByOption(@PathVariable("tableName") String tableName, @PathVariable("columnName") String columnName, @RequestParam String columnValue) { Map<String, Object> params = new HashMap<String, Object>(); params.put("table", tableName); params.put("column", columnName); params.put("columnValue", columnValue); Map<String, Object> result = commonService.getFollowByOption(params); return R.ok().put("data", result); } /** * 修改table表的sfsh状态 * @param table * @param map * @return */ @RequestMapping("/sh/{tableName}") public R sh(@PathVariable("tableName") String tableName, @RequestBody Map<String, Object> map) { map.put("table", tableName); commonService.sh(map); return R.ok(); } /** * 获取需要提醒的记录数 * @param tableName * @param columnName * @param type 1:数字 2:日期 * @param map * @return */ @IgnoreAuth @RequestMapping("/remind/{tableName}/{columnName}/{type}") public R remindCount(@PathVariable("tableName") String tableName, @PathVariable("columnName") String columnName, @PathVariable("type") String type,@RequestParam Map<String, Object> map) { map.put("table", tableName); 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));
public R delete(@RequestBody Long[] ids){ xinwenService.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<XinwenEntity> wrapper = new EntityWrapper<XinwenEntity>(); if(map.get("remindstart")!=null) { wrapper.ge(columnName, map.get("remindstart")); } if(map.get("remindend")!=null) { wrapper.le(columnName, map.get("remindend")); } int count = xinwenService.selectCount(wrapper); return R.ok().put("count", count); } /** * 前端智能排序 */ @IgnoreAuth @RequestMapping("/autoSort")
/** * 上传文件映射表 */ @RestController @RequestMapping("file") @SuppressWarnings({"unchecked","rawtypes"}) public class FileController{ @Autowired private ConfigService configService; /** * 上传文件 */ @RequestMapping("/upload") public R upload(@RequestParam("file") MultipartFile file,String type) throws Exception { if (file.isEmpty()) { throw new EIException("上传文件不能为空"); } String fileExt = file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf(".")+1); File path = new File(ResourceUtils.getURL("classpath:static").getPath()); if(!path.exists()) { path = new File(""); } File upload = new File(path.getAbsolutePath(),"/upload/"); if(!upload.exists()) { upload.mkdirs(); } String fileName = new Date().getTime()+"."+fileExt; File dest = new File(upload.getAbsolutePath()+"/"+fileName); file.transferTo(dest); if(StringUtils.isNotBlank(type) && type.equals("1")) { ConfigEntity configEntity = configService.selectOne(new EntityWrapper<ConfigEntity>().eq("name", "faceFile")); if(configEntity==null) { configEntity = new ConfigEntity(); configEntity.setName("faceFile"); configEntity.setValue(fileName); } else { configEntity.setValue(fileName); } configService.insertOrUpdate(configEntity); } return R.ok().put("file", fileName); } /** * 下载文件 */
*/ @RestController @RequestMapping("/storeup") public class StoreupController { @Autowired private StoreupService storeupService; /** * 后端列表 */ @RequestMapping("/page") public R page(@RequestParam Map<String, Object> params,StoreupEntity storeup, HttpServletRequest request){ if(!request.getSession().getAttribute("role").toString().equals("管理员")) { storeup.setUserid((Long)request.getSession().getAttribute("userId")); } EntityWrapper<StoreupEntity> ew = new EntityWrapper<StoreupEntity>(); PageUtils page = storeupService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, storeup), params), params)); return R.ok().put("data", page); } /** * 前端列表 */ @RequestMapping("/list") public R list(@RequestParam Map<String, Object> params,StoreupEntity storeup, HttpServletRequest request){ if(!request.getSession().getAttribute("role").toString().equals("管理员")) { storeup.setUserid((Long)request.getSession().getAttribute("userId")); } EntityWrapper<StoreupEntity> ew = new EntityWrapper<StoreupEntity>(); PageUtils page = storeupService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, storeup), params), params)); return R.ok().put("data", page); } /** * 列表 */ @RequestMapping("/lists") public R list( StoreupEntity storeup){ EntityWrapper<StoreupEntity> ew = new EntityWrapper<StoreupEntity>(); ew.allEq(MPUtil.allEQMapPre( storeup, "storeup")); return R.ok().put("data", storeupService.selectListView(ew)); } /** * 查询 */
tokenEntity = tokenService.getTokenEntity(token); } if(tokenEntity != null) { request.getSession().setAttribute("userId", tokenEntity.getUserid()); request.getSession().setAttribute("role", tokenEntity.getRole()); request.getSession().setAttribute("tableName", tokenEntity.getTablename()); request.getSession().setAttribute("username", tokenEntity.getUsername()); return true; } PrintWriter writer = null; response.setCharacterEncoding("UTF-8"); response.setContentType("application/json; charset=utf-8"); try { writer = response.getWriter(); writer.print(JSONObject.toJSONString(R.error(401, "请先登录"))); } finally { if(writer != null){ writer.close(); } } // throw new EIException("请先登录", 401); return false; } }
@RequestMapping("/xinwen") public class XinwenController { @Autowired private XinwenService xinwenService; /** * 后端列表 */ @RequestMapping("/page") public R page(@RequestParam Map<String, Object> params,XinwenEntity xinwen, HttpServletRequest request){ EntityWrapper<XinwenEntity> ew = new EntityWrapper<XinwenEntity>(); PageUtils page = xinwenService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, xinwen), params), params)); return R.ok().put("data", page); } /** * 前端列表 */ @IgnoreAuth @RequestMapping("/list") public R list(@RequestParam Map<String, Object> params,XinwenEntity xinwen, HttpServletRequest request){ EntityWrapper<XinwenEntity> ew = new EntityWrapper<XinwenEntity>(); PageUtils page = xinwenService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, xinwen), params), params)); return R.ok().put("data", page); } /** * 列表 */ @RequestMapping("/lists") public R list( XinwenEntity xinwen){ EntityWrapper<XinwenEntity> ew = new EntityWrapper<XinwenEntity>(); ew.allEq(MPUtil.allEQMapPre( xinwen, "xinwen")); return R.ok().put("data", xinwenService.selectListView(ew)); } /** * 查询 */ @RequestMapping("/query") public R query(XinwenEntity xinwen){ EntityWrapper< XinwenEntity> ew = new EntityWrapper< XinwenEntity>(); ew.allEq(MPUtil.allEQMapPre( xinwen, "xinwen")); XinwenView xinwenView = xinwenService.selectView(ew); return R.ok("查询新闻成功").put("data", xinwenView); }
/** * 登录相关 */ @RequestMapping("config") @RestController public class ConfigController{ @Autowired private ConfigService configService; /** * 列表 */ @RequestMapping("/page") public R page(@RequestParam Map<String, Object> params,ConfigEntity config){ EntityWrapper<ConfigEntity> ew = new EntityWrapper<ConfigEntity>(); PageUtils page = configService.queryPage(params); return R.ok().put("data", page); } /** * 列表 */ @IgnoreAuth @RequestMapping("/list") public R list(@RequestParam Map<String, Object> params,ConfigEntity config){ EntityWrapper<ConfigEntity> ew = new EntityWrapper<ConfigEntity>(); PageUtils page = configService.queryPage(params); return R.ok().put("data", page); } /** * 信息 */ @RequestMapping("/info/{id}") public R info(@PathVariable("id") String id){ ConfigEntity config = configService.selectById(id); return R.ok().put("data", config); } /** * 详情 */ @IgnoreAuth @RequestMapping("/detail/{id}") public R detail(@PathVariable("id") String id){ ConfigEntity config = configService.selectById(id); return R.ok().put("data", config); }