——————————DescriptionStart——————————
运行环境
Java≥8、MySQL≥5.7
开发工具
eclipse/idea/myeclipse/sts等均可配置运行
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
功能说明






基于javaweb的SpringBoot协同过滤算法新闻推荐管理系统(java+ssm+javascript+html+thymeleaf+ajax+mysql+maven)
项目介绍
本项目新闻推荐管理系统;
前台:
登录、首页、全部新闻、系统特色、猜你喜欢、分类、评论
后台: (1)文件管理:文件列表。 (2)用户管理:用户管理。 (3)新闻管理:新闻管理。 (4)三联管理:联动管理。 (5)新闻审核:新闻的审核和管理。
技术栈
SSM+mysql+layui+CSS+JavaScript
使用说明
- 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件; 2. 使用IDEA/Eclipse/MyEclipse导入项目,导入成功后请执行maven clean;maven install命令,然后运行; 3. 将项目中application.properties配置文件中的数据库配置改为自己的配置; 4. 运行项目,在浏览器中输入http://localhost:8080 访问
——————————CodeStart——————————
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
| return response; }
@ApiOperation(value = "根据ID文件下载/回显",notes = "path里面传文件ID") @RequestMapping(value = "/fileDown/{id}",method = {RequestMethod.POST,RequestMethod.GET}) public ResponseEntity<byte[]> fileDown(@PathVariable Long id, String fileName){ SysFile sysFile = fileService.getById(id); byte [] body = null; String fileUrl=sysFile.getFileUrl(); try { InputStream in = new FileSystemResource(fileUrl).getInputStream(); body = new byte[in.available()]; in.read(body); } catch (IOException e1) { logger.debug("文件读入出错,文件路径为:"+fileUrl); e1.printStackTrace(); } HttpHeaders headers = new HttpHeaders(); headers.add("Content-Disposition", "attachment;filename="+fileName); headers.setContentType(MediaType.APPLICATION_OCTET_STREAM); HttpStatus statusCode = HttpStatus.OK; ResponseEntity<byte[]> response = new ResponseEntity<byte[]>(body, headers, statusCode); return response; }
@RequestMapping(value = "/export") public ResponseEntity<byte[]> fileExport(String fileName){ byte [] body = null; InputStream in=null; try { in = FileController.class.getClassLoader().getResourceAsStream(fileName); if(in.available()<1){ in=new FileInputStream(new File(configJsonPath+File.separator+fileName)); } logger.debug("需要导出的模板:{},获取的流为:{}",fileName,in); body = new byte[in.available()]; logger.debug("导出模板大小:{},读入body大小:{}",in.available(),body.length); in.read(body); HttpHeaders headers = new HttpHeaders(); headers.add("Content-Disposition", "attachment;filename="+ URLEncoder.encode(fileName,"UTF-8")); headers.setContentType(MediaType.APPLICATION_OCTET_STREAM); HttpStatus statusCode = HttpStatus.OK; ResponseEntity<byte[]> response = new ResponseEntity<byte[]>(body, headers, statusCode); return response;
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
|
@Controller @RequestMapping("grap") public class GrapNewsController {
@Autowired SysNewsService newsService;
@Autowired SysUserService userService;
@Autowired NewsCategoryService categoryService;
private static final Logger logger= LoggerFactory.getLogger(GrapNewsController.class);
private static String baseUrlStar="https://ent.ifeng.com/star/"; private static String baseUrlMovie="https://ent.ifeng.com/movie/"; private static String baseUrlMusic="https://ent.ifeng.com/music/";
@Value("${com.cgx.file.baseFilePath}") private String baseFilePath;
private static String yuleyiyueUrl="https://shankapi.ifeng.com/shanklist/_/getColumnInfo/_/default/{id}/{idTimeMills}/20/4-20077-/getColumnInfoCallback?callback=getColumnInfoCallback&_={currTimeMills}"; private static String yulestarUrl="https://shankapi.ifeng.com/shanklist/_/getColumnInfo/_/default/{id}/{idTimeMills}/20/4-20074-/getColumnInfoCallback?callback=getColumnInfoCallback&_={currTimeMills}"; private static String yulefilmUrl="https://shankapi.ifeng.com/shanklist/_/getColumnInfo/_/default/{id}/{idTimeMills}/20/4-20075-/getColumnInfoCallback?callback=getColumnInfoCallback&_={currTimeMills}";
private String defaultYuLeId="6760584714211311643"; private String defaultYuLeTimeMills="1611846336000";
private String defaultYuLeStarId="6776520715089744701"; private String defaultYuLeStarTimeMills="1615739836000";
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
| /** * <p> * 新闻分类表 前端控制器 * </p> * */ @Controller @RequestMapping({"/category","/home/category"}) public class NewsCategoryController {
private static final Logger logger= LoggerFactory.getLogger(NewsCategoryController.class);
private static final String page_prefix="news/category/";
@Autowired SysNewsService newsService;
@Autowired NewsCategoryService categoryService;
/** * 跳到添加页面 * @param model * @return */ @RequestMapping("addPage") public String addPage(Model model){ return page_prefix+"add"; }
//新闻分类添加 @RequestMapping("add") @ResponseBody public ResponseBean addNews(NewsCategory category, HttpSession session){ logger.debug("addNewsCategory:"+category); String name = category.getName(); String code = category.getCode(); QueryWrapper<NewsCategory> queryWrapper=new QueryWrapper<>(); queryWrapper.like("code",code).like("name",name); List<NewsCategory> list = categoryService.list(queryWrapper); if(!ToolsUtils.isEmpty(list)){ return ResultUtil.error("名称或编码已经存在!"); } boolean i = categoryService.save(category); logger.debug("保存后的NewsCategory:"+category);
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
| QueryWrapper<NewsFavor> queryWrapper=new QueryWrapper<>(); String newsTitle = queryParam.getNewsTitle(); String userName = queryParam.getUserName(); queryWrapper.like(!StringUtils.isEmpty(newsTitle),"news_title",newsTitle) .like(!StringUtils.isEmpty(userName),"user_name",userName); IPage<NewsFavor> indexPage = new Page<>(pageNum, pageSize); IPage<NewsFavor> listPage = favorService.page(indexPage, queryWrapper); logger.debug("获取的新闻点赞列表:"+listPage); Map resultMap = ToolsUtils.wrapperResult(listPage, "favorList"); return ResultUtil.successData(resultMap); }
@RequestMapping("deleteBatchByIds") @ResponseBody public ResponseBean deleteBatchByIds(@RequestParam List<Long> idList){ logger.debug("deleteBatchByIds:"+idList); if(idList==null||idList.isEmpty()){ return ResultUtil.error(CommonEnum.BAD_PARAM); } boolean delete = favorService.removeByIds(idList); logger.debug("批量删除结果:"+delete); return ResultUtil.success() ; }
@RequestMapping("deleteById") @ResponseBody public ResponseBean deleteById(@RequestParam Long id){ if(id==null||id<0){ return ResultUtil.error(CommonEnum.BAD_PARAM); } boolean delete = favorService.removeById(id); return ResultUtil.success() ; }
} package com.news.common.file;
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
| NewsFavorService favorService;
@Autowired SysUserService userService;
@Autowired NewsForwardService forwardService;
@Autowired NewsCommentService commentService;
@Value("${com.cgx.file.baseFilePath}") private String baseFilePath;
@ModelAttribute public void addModelAttribute(Model model){ List<NewsCategory> categoryList = newsCategoryService.list(); model.addAttribute("categoryList",categoryList); }
public String saveFileByUrl(String imgUrl) throws IOException { FileOutputStream out = null; BufferedInputStream in = null; HttpURLConnection connection = null; byte[] buf = new byte[1024]; int len = 0; String saveFileName= UUID.randomUUID().toString().replaceAll("-","")+".jpg"; try { URL url = new URL(imgUrl); connection = (HttpURLConnection)url.openConnection(); connection.connect(); in = new BufferedInputStream(connection.getInputStream());
|
——————————PayStart——————————
项目链接:
https://javayms.github.io?id=421023491103200yr
https://javayms.pages.dev?id=421023491103200yr