作者主页:夜未央5788
简介:Java领域优质创作者、Java项目、学习资料、技术互助
文末获取源码
springboot电影推荐网站。本系统采用企业级开发标准,使用SpringBoot架构,数据访问层采用Spring Data Jpa,业务控制层采用SpringMvc,安全框架采用Shiro,实现了完整权限系统,Controller方法采用shiro注解,来实现有效的权限控制;界面采用了Easyui技术;在该项目中可以收录电影,收录电影网站,电影网站动态信息以及通过关键字查询你想要看的电影。在后台可以添加电影信息,对电影信动态的管理,电影信息管理,网站信息的管理等。
1.运行环境:最好是java jdk 1.8,我们在这个平台上运行的。其他版本理论上也可以。
2.IDE环境:IDEA,Eclipse,Myeclipse都可以。推荐IDEA;
3.tomcat环境:Tomcat 7.x,8.x,9.x版本均可
4.硬件环境:windows 7/8/10 1G内存以上;或者 Mac OS;
5.是否Maven项目: 是;查看源码目录中是否包含pom.xml;若包含,则为maven项目,否则为非maven项目
6.数据库:MySql 5.7版本;
1. 后端:SpringBoot+Spring Data Jpa+shiro
2. 前端:html+easyui+bootstrap
1. 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件;
2. 将项目中application.yml配置文件中的数据库配置改为自己的配置
3. 使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven;
若为maven项目,导入成功后请执行maven clean;maven install命令,配置tomcat,然后运行;
4. 前台运行地址:http://localhost:8085
后台运行地址:http://localhost:8085/login
管理员账户:admin 密码:123456
- /**
- * 电影控制器
- * @author Administrator
- *
- */
- @Controller
- @RequestMapping(value = "/film")
- public class FilmController {
-
- @Resource
- private FilmService filmService;
-
-
- @Resource
- private WebSiteInfoService webSiteInfoService;
-
- /**
- * 搜索电影 简单模糊查询
- * @param q
- * @return
- * @throws Exception
- */
- @RequestMapping("/search")
- public ModelAndView search(@Valid Film film,BindingResult bindingResult)throws Exception{
- ModelAndView mav=new ModelAndView();
- if(bindingResult.hasErrors()){
- mav.addObject("error", bindingResult.getFieldError().getDefaultMessage());
- mav.addObject("title", "首页");
- mav.addObject("mainPage", "film/indexFilm");
- mav.addObject("mainPageKey", "#f");
- mav.addObject("film", film);
- mav.setViewName("index");
- }else{
- List
filmList=filmService.list(film, 1, 32); - mav.addObject("filmList", filmList); // 最多查询32条数据
- mav.addObject("title", film.getName());
- mav.addObject("mainPage", "film/result");
- mav.addObject("mainPageKey", "#f");
- mav.addObject("film", film);
- mav.addObject("total", filmList.size());
- mav.setViewName("index");
- }
- return mav;
- }
-
- /**
- * 分页查询电影信息
- * @return
- * @throws Exception
- */
- @RequestMapping("/list/{id}")
- public ModelAndView list(@PathVariable(value="id",required=false) Integer page)throws Exception{
- ModelAndView mav=new ModelAndView();
- List
filmList=filmService.list(null, page, 20); - Long total=filmService.getCount(null);
- mav.addObject("filmList", filmList);
- mav.addObject("pageCode",PageUtil.genPagination("/film/list", total, page, 20));
- mav.addObject("title", "电影列表");
- mav.addObject("mainPage", "film/list");
- mav.addObject("mainPageKey", "#f");
- mav.setViewName("index");
- return mav;
- }
-
- /**
- * 根据id查询电影详细信息
- * @return
- * @throws Exception
- */
- @RequestMapping("/{id}")
- public ModelAndView view(@PathVariable("id") Integer id)throws Exception{
- ModelAndView mav=new ModelAndView();
- Film film=filmService.findById(id);
- mav.addObject("film", film);
- mav.addObject("title", film.getTitle());
- mav.addObject("pageCode", this.genUpAndDownPageCode(filmService.getLast(id),filmService.getNext(id)));
- mav.addObject("randomFilmList", filmService.randomList(8));
- mav.addObject("webSiteInfoList", webSiteInfoService.getByFilmId(id));
- mav.addObject("mainPage", "film/view");
- mav.addObject("mainPageKey", "#f");
- mav.addObject("film", film);
- mav.setViewName("index");
- return mav;
- }
-
- /**
- * 获取下一篇博客和下一篇博客代码
- * @param lastBlog
- * @param nextBlog
- * @return
- */
- private String genUpAndDownPageCode(Film lastFilm,Film nextFilm){
- StringBuffer pageCode=new StringBuffer();
- if(lastFilm==null || lastFilm.getId()==null){
- pageCode.append("
上一篇:没有了
"); - }else{
- pageCode.append("
上一篇:"
+lastFilm.getTitle()+""); - }
- if(nextFilm==null || nextFilm.getId()==null){
- pageCode.append("
下一篇:没有了
"); - }else{
- pageCode.append("
下一篇:"
+nextFilm.getTitle()+""); - }
- return pageCode.toString();
- }
-
-
-
- }
- /**
- * 电影Controller类
- * @author Administrator
- *
- */
- @RestController
- @RequestMapping(value = "/admin/film")
- public class FilmAdminController {
-
- @Resource
- private FilmService filmService;
-
- @Resource
- private WebSiteInfoService webSiteInfoService;
-
- @Value("${imageFilePath}")
- private String imageFilePath;
-
- @Resource
- private InitSystem initSystem;
-
- /**
- * 分页查询电影
- * @param page
- * @param rows
- * @return
- * @throws Exception
- */
- @ResponseBody
- @RequestMapping("/list")
- public Map
list(Film film,@RequestParam(value="page",required=false)Integer page,@RequestParam(value="rows",required=false)Integer rows)throws Exception{ - List
filmList=filmService.list(film,page,rows); - Long total=filmService.getCount(film);
- Map
resultMap = new HashMap<>(); - resultMap.put("rows", filmList);
- resultMap.put("total", total);
- return resultMap;
- }
-
- /**
- * 下拉框模糊查询
- * @param name
- * @return
- * @throws Exception
- */
- @ResponseBody
- @RequestMapping("/comboList")
- public List
comboList(String q)throws Exception{ - if(StringUtil.isEmpty(q)){
- return null;
- }
- Film film=new Film();
- film.setName(q);
- return filmService.list(film, 1, 30); // 最多查询30条记录
- }
-
- /**
- * 添加或者修改电影
- * @param film
- * @return
- * @throws Exception
- */
- @ResponseBody
- @RequestMapping("/save")
- public Map
save(Film film,@RequestParam("imageFile")MultipartFile file,HttpServletRequest request)throws Exception{ - if(!file.isEmpty()){
- // 获取文件名
- String fileName = file.getOriginalFilename();
- // 获取文件的后缀名
- String suffixName = fileName.substring(fileName.lastIndexOf("."));
- String newFileName=DateUtil.getCurrentDateStr()+suffixName;
- FileUtils.copyInputStreamToFile(file.getInputStream(), new File(imageFilePath+newFileName));
- film.setImageName(newFileName);
- }
- film.setPublishDate(new Date());
- Map
resultMap = new HashMap<>(); - filmService.save(film);
- initSystem.loadData(request.getServletContext());
- resultMap.put("success", true);
- return resultMap;
- }
-
- /**
- * 删除电影信息
- * @param ids
- * @param response
- * @return
- * @throws Exception
- */
- @ResponseBody
- @RequestMapping("/delete")
- public Map
delete(@RequestParam(value="ids")String ids,HttpServletRequest request)throws Exception{ - String []idsStr=ids.split(",");
- Map
resultMap = new HashMap<>(); - boolean flag=true;
- for(int i=0;i
- Integer filmId=Integer.parseInt(idsStr[i]);
- if(webSiteInfoService.getByFilmId(filmId).size()>0){
- flag=false;
- }else{
- filmService.delete(filmId);
- }
- }
- initSystem.loadData(request.getServletContext());
- if(flag){
- resultMap.put("success", true);
- }else{
- resultMap.put("success", false);
- resultMap.put("errorInfo", "电影动态信息中存在电影信息,不能删除!");
- }
- return resultMap;
- }
-
- /**
- * 根据id查询实体
- * @param id
- * @return
- * @throws Exception
- */
- @ResponseBody
- @RequestMapping("/findById")
- public Film findById(@RequestParam(value="id")Integer id)throws Exception{
- Film film=filmService.findById(id);
- return film;
- }
-
- /**
- * 上传图片
- * @param file
- * @return
- */
- @ResponseBody
- @RequestMapping("/ckeditorUpload")
- public String ckeditorUpload(@RequestParam("upload")MultipartFile file,String CKEditorFuncNum)throws Exception{
- // 获取文件名
- String fileName = file.getOriginalFilename();
- // 获取文件的后缀名
- String suffixName = fileName.substring(fileName.lastIndexOf("."));
- String newFileName=DateUtil.getCurrentDateStr()+suffixName;
- FileUtils.copyInputStreamToFile(file.getInputStream(), new File(imageFilePath+newFileName));
-
- StringBuffer sb=new StringBuffer();
- sb.append("");
-
- return sb.toString();
- }
-
-
-
- }
如果也想学习本系统,下面领取。回复:040springboot