基于javaweb+mysql的springboot电影推荐系统(java+springboot+html+easyui+bootstrap+mysql)
运行环境
Java≥8、MySQL≥5.7
开发工具
eclipse/idea/myeclipse/sts等均可配置运行
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
功能说明
基于javaweb+mysql的SpringBoot电影推荐系统(java+springboot+html+easyui+bootstrap+mysql)
项目介绍
本系统采用企业级开发标准,使用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版本;
技术栈
-
后端:SpringBoot+Spring Data Jpa+shiro
-
前端:html+easyui+bootstrap
使用说明
- 使用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
/**
* 添加或者修改电影
*
* @param film
* @return
* @throws Exception
*/
@ResponseBody
@RequestMapping("/save")
public Map<String, Object> 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<String, Object> 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<String, Object> delete(@RequestParam(value = "ids") String ids, HttpServletRequest request) throws Exception {
String[] idsStr = ids.split(",");
Map<String, Object> resultMap = new HashMap<>();
boolean flag = true;
for (int i = 0; i < idsStr.length; i++) {
Integer filmId = Integer.parseInt(idsStr[i]);
if (webSiteInfoService.getByFilmId(filmId).size() > 0) {
flag = false;
} else {
filmService.delete(filmId);
package com.java1234.controller;
/**
* 电影网站动态控制器
*
*/
@Controller
@RequestMapping(value = "/webSiteInfo")
public class WebSiteInfoController {
@Resource
private WebSiteInfoService webSiteInfoService;
/**
* 分页查询电影网站动态信息
* @param page
* @return
* @throws Exception
*/
@RequestMapping("/list/{id}")
public ModelAndView list(@PathVariable(value="id",required=false) Integer page)throws Exception{
ModelAndView mav=new ModelAndView();
List<WebSiteInfo> webSiteInfoList=webSiteInfoService.list(null, page, 20);
Long total=webSiteInfoService.getCount(null);
mav.addObject("webSiteInfoList", webSiteInfoList);
mav.addObject("pageCode",PageUtil.genPagination("/webSiteInfo/list", total, page, 20));
mav.addObject("title", "电影网站动态信息列表");
mav.addObject("mainPage", "webSiteInfo/list");
mav.addObject("mainPageKey", "#f");
mav.setViewName("index");
return mav;
}
}
package com.java1234.controller;
}
/**
* 删除电影动态信息
* @param ids
* @param response
* @return
* @throws Exception
*/
@ResponseBody
@RequestMapping("/delete")
public Map<String,Object> delete(@RequestParam(value="ids")String ids,HttpServletRequest request)throws Exception{
String []idsStr=ids.split(",");
Map<String, Object> resultMap = new HashMap<>();
for(int i=0;i<idsStr.length;i++){
webSiteInfoService.delete(Integer.parseInt(idsStr[i]));
}
initSystem.loadData(request.getServletContext());
resultMap.put("success", true);
return resultMap;
}
}
package com.java1234.controller.admin;
/**
* 友情链接Controller类
webSite.setUrl(q);
return webSiteService.list(webSite, 1, 30); // 最多查询30条
}
/**
* 添加或者修改电影网站信息
* @param link
* @return
* @throws Exception
*/
@ResponseBody
@RequestMapping("/save")
public Map<String,Object> save(WebSite webSite,HttpServletRequest request)throws Exception{
Map<String, Object> resultMap = new HashMap<>();
webSiteService.save(webSite);
initSystem.loadData(request.getServletContext());
resultMap.put("success", true);
return resultMap;
}
/**
* 删除友情电影网站信息
* @param ids
* @param response
* @return
* @throws Exception
*/
@ResponseBody
@RequestMapping("/delete")
public Map<String,Object> delete(@RequestParam(value="ids")String ids,HttpServletRequest request)throws Exception{
String []idsStr=ids.split(",");
Map<String, Object> resultMap = new HashMap<>();
boolean flag=true;
for(int i=0;i<idsStr.length;i++){
Integer webSiteId=Integer.parseInt(idsStr[i]);
if(webSiteInfoService.getByWebSiteId(webSiteId).size()>0){
flag=false;
}else{
webSiteService.delete(Integer.parseInt(idsStr[i]));
}
}
initSystem.loadData(request.getServletContext());
if(flag){
resultMap.put("success", true);
}else{
resultMap.put("success", false);
/**
* 电影Controller类
*
*/
@RestController
@RequestMapping(value = "/admin/film")
public class FilmAdminController {
@Resource
private FilmService filmService;
@Resource
private WebSiteInfoService webSiteInfoService;
private String imageFilePath = System.getProperty("user.dir") + "/src/main/webapp/static/filmImage/";
@Resource
private InitSystem initSystem;
/**
* 分页查询电影
*
* @param page
* @param rows
* @return
* @throws Exception
*/
@ResponseBody
@RequestMapping("/list")
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));
/**
* 电影Controller类
*
*/
@RestController
@RequestMapping(value = "/admin/film")
public class FilmAdminController {
@Resource
private FilmService filmService;
@Resource
private WebSiteInfoService webSiteInfoService;
private String imageFilePath = System.getProperty("user.dir") + "/src/main/webapp/static/filmImage/";
@Resource
private InitSystem initSystem;
/**
* 分页查询电影
*
* @param page
* @param rows
* @return
* @throws Exception
*/
@ResponseBody
@RequestMapping("/list")
public Map<String, Object> list(Film film, @RequestParam(value = "page", required = false) Integer page, @RequestParam(value = "rows", required = false) Integer rows) throws Exception {
List<Film> filmList = filmService.list(film, page, rows);
Long total = filmService.getCount(film);
Map<String, Object> resultMap = new HashMap<>();
resultMap.put("rows", filmList);
resultMap.put("total", total);
return resultMap;
}
/**
* 分页查询电影网站动态信息
* @param page
* @return
* @throws Exception
*/
@RequestMapping("/list/{id}")
public ModelAndView list(@PathVariable(value="id",required=false) Integer page)throws Exception{
ModelAndView mav=new ModelAndView();
List<WebSiteInfo> webSiteInfoList=webSiteInfoService.list(null, page, 20);
Long total=webSiteInfoService.getCount(null);
mav.addObject("webSiteInfoList", webSiteInfoList);
mav.addObject("pageCode",PageUtil.genPagination("/webSiteInfo/list", total, page, 20));
mav.addObject("title", "电影网站动态信息列表");
mav.addObject("mainPage", "webSiteInfo/list");
mav.addObject("mainPageKey", "#f");
mav.setViewName("index");
return mav;
}
}
package com.java1234.controller;
/**
* 首页或者权限url跳转控制器
*
*/
@Controller
public class IndexController {
/**
* 进入后台管理请求
* @return
*/
@RequestMapping(value = "/admin")
public String toAdmin(){
return "admin/main";
}
/**
* 关于本站
* @return
*/
@RequestMapping("/aboutMe")
public ModelAndView aboutMe(){
ModelAndView mav=new ModelAndView();
mav.addObject("title", "关于本站");
/**
* 电影网站动态控制器
*
*/
@Controller
@RequestMapping(value = "/webSiteInfo")
public class WebSiteInfoController {
@Resource
private WebSiteInfoService webSiteInfoService;
/**
* 分页查询电影网站动态信息
* @param page
* @return
* @throws Exception
*/
@RequestMapping("/list/{id}")
public ModelAndView list(@PathVariable(value="id",required=false) Integer page)throws Exception{
ModelAndView mav=new ModelAndView();
List<WebSiteInfo> webSiteInfoList=webSiteInfoService.list(null, page, 20);
Long total=webSiteInfoService.getCount(null);
mav.addObject("webSiteInfoList", webSiteInfoList);
mav.addObject("pageCode",PageUtil.genPagination("/webSiteInfo/list", total, page, 20));
mav.addObject("title", "电影网站动态信息列表");
mav.addObject("mainPage", "webSiteInfo/list");
mav.addObject("mainPageKey", "#f");
mav.setViewName("index");
return mav;
}
}
package com.java1234.controller;
/**
* 电影网站动态控制器
*
*/
@Controller
@RequestMapping(value = "/webSiteInfo")
public class WebSiteInfoController {
@Resource
private WebSiteInfoService webSiteInfoService;
/**
* 分页查询电影网站动态信息
* @param page
* @return
* @throws Exception
*/
@RequestMapping("/list/{id}")
public ModelAndView list(@PathVariable(value="id",required=false) Integer page)throws Exception{
ModelAndView mav=new ModelAndView();
List<WebSiteInfo> webSiteInfoList=webSiteInfoService.list(null, page, 20);
Long total=webSiteInfoService.getCount(null);
mav.addObject("webSiteInfoList", webSiteInfoList);
mav.addObject("pageCode",PageUtil.genPagination("/webSiteInfo/list", total, page, 20));
mav.addObject("title", "电影网站动态信息列表");
mav.addObject("mainPage", "webSiteInfo/list");
mav.addObject("mainPageKey", "#f");
mav.setViewName("index");
return mav;
}
}
package com.java1234.controller;
/**
* 首页或者权限url跳转控制器
*
*/
@Controller
public class IndexController {
/**
* 分页查询电影信息
* @return
* @throws Exception
*/
@RequestMapping("/list/{id}")
public ModelAndView list(@PathVariable(value="id",required=false) Integer page)throws Exception{
ModelAndView mav=new ModelAndView();
List<Film> 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
Map<String, Object> resultMap = new HashMap<>();
resultMap.put("rows", webSiteList);
resultMap.put("total", total);
return resultMap;
}
/**
* 下拉框模糊查询
* @param name
* @return
* @throws Exception
*/
@ResponseBody
@RequestMapping("/comboList")
public List<WebSite> comboList(String q)throws Exception{
if(StringUtil.isEmpty(q)){
return null;
}
WebSite webSite=new WebSite();
webSite.setUrl(q);
return webSiteService.list(webSite, 1, 30); // 最多查询30条
}
/**
* 添加或者修改电影网站信息
* @param link
* @return
* @throws Exception
*/
@ResponseBody
@RequestMapping("/save")
public Map<String,Object> save(WebSite webSite,HttpServletRequest request)throws Exception{
Map<String, Object> resultMap = new HashMap<>();
webSiteService.save(webSite);
initSystem.loadData(request.getServletContext());
resultMap.put("success", true);
return resultMap;
}
/**
* 删除友情电影网站信息
* @param ids
*/
@ResponseBody
@RequestMapping("/delete")
public Map<String,Object> delete(@RequestParam(value="ids")String ids,HttpServletRequest request)throws Exception{
String []idsStr=ids.split(",");
Map<String, Object> resultMap = new HashMap<>();
for(int i=0;i<idsStr.length;i++){
webSiteInfoService.delete(Integer.parseInt(idsStr[i]));
}
initSystem.loadData(request.getServletContext());
resultMap.put("success", true);
return resultMap;
}
}
package com.java1234.controller.admin;
/**
* 友情链接Controller类
*
*/
@RestController
@RequestMapping(value = "/admin/link")
public class LinkAdminController {
@Resource
private LinkService linkService;
* @param link
* @return
* @throws Exception
*/
@ResponseBody
@RequestMapping("/save")
public Map<String,Object> save(WebSiteInfo webSiteInfo,HttpServletRequest request)throws Exception{
webSiteInfo.setPublishDate(new Date());
Map<String, Object> resultMap = new HashMap<>();
webSiteInfoService.save(webSiteInfo);
initSystem.loadData(request.getServletContext());
resultMap.put("success", true);
return resultMap;
}
/**
* 删除电影动态信息
* @param ids
* @param response
* @return
* @throws Exception
*/
@ResponseBody
@RequestMapping("/delete")
public Map<String,Object> delete(@RequestParam(value="ids")String ids,HttpServletRequest request)throws Exception{
String []idsStr=ids.split(",");
Map<String, Object> resultMap = new HashMap<>();
for(int i=0;i<idsStr.length;i++){
webSiteInfoService.delete(Integer.parseInt(idsStr[i]));
}
initSystem.loadData(request.getServletContext());
resultMap.put("success", true);
return resultMap;
}
}
package com.java1234.controller.admin;
webSite.setUrl(q);
return webSiteService.list(webSite, 1, 30); // 最多查询30条
}
/**
* 添加或者修改电影网站信息
* @param link
* @return
* @throws Exception
*/
@ResponseBody
@RequestMapping("/save")
public Map<String,Object> save(WebSite webSite,HttpServletRequest request)throws Exception{
Map<String, Object> resultMap = new HashMap<>();
webSiteService.save(webSite);
initSystem.loadData(request.getServletContext());
resultMap.put("success", true);
return resultMap;
}
/**
* 删除友情电影网站信息
* @param ids
* @param response
* @return
* @throws Exception
*/
@ResponseBody
@RequestMapping("/delete")
public Map<String,Object> delete(@RequestParam(value="ids")String ids,HttpServletRequest request)throws Exception{
String []idsStr=ids.split(",");
Map<String, Object> resultMap = new HashMap<>();
boolean flag=true;
for(int i=0;i<idsStr.length;i++){
Integer webSiteId=Integer.parseInt(idsStr[i]);
if(webSiteInfoService.getByWebSiteId(webSiteId).size()>0){
flag=false;
}else{
webSiteService.delete(Integer.parseInt(idsStr[i]));
}
}
initSystem.loadData(request.getServletContext());
if(flag){
resultMap.put("success", true);
}else{
resultMap.put("success", false);
resultMap.put("errorInfo", "电影动态信息中存在电影网站信息,不能删除!");
* @return
* @throws Exception
*/
@ResponseBody
@RequestMapping("/list")
public Map<String,Object> list(WebSiteInfo webSiteInfo,@RequestParam(value="page",required=false)Integer page,@RequestParam(value="rows",required=false)Integer rows)throws Exception{
List<WebSiteInfo> webSiteInfoList=webSiteInfoService.list(webSiteInfo,page,rows);
Long total=webSiteInfoService.getCount(webSiteInfo);
Map<String, Object> resultMap = new HashMap<>();
resultMap.put("rows", webSiteInfoList);
resultMap.put("total", total);
return resultMap;
}
/**
* 添加网站动态信息
* @param link
* @return
* @throws Exception
*/
@ResponseBody
@RequestMapping("/save")
public Map<String,Object> save(WebSiteInfo webSiteInfo,HttpServletRequest request)throws Exception{
webSiteInfo.setPublishDate(new Date());
Map<String, Object> resultMap = new HashMap<>();
webSiteInfoService.save(webSiteInfo);
initSystem.loadData(request.getServletContext());
resultMap.put("success", true);
return resultMap;
}
/**
* 删除电影动态信息
* @param ids
* @param response
* @return
* @throws Exception
*/
@ResponseBody
@RequestMapping("/delete")
public Map<String,Object> delete(@RequestParam(value="ids")String ids,HttpServletRequest request)throws Exception{
String []idsStr=ids.split(",");
Map<String, Object> resultMap = new HashMap<>();
for(int i=0;i<idsStr.length;i++){
webSiteInfoService.delete(Integer.parseInt(idsStr[i]));
}
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<Film> 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<Film> 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;
}
/**
Map<String, Object> resultMap = new HashMap<>();
boolean flag=true;
for(int i=0;i<idsStr.length;i++){
Integer webSiteId=Integer.parseInt(idsStr[i]);
if(webSiteInfoService.getByWebSiteId(webSiteId).size()>0){
flag=false;
}else{
webSiteService.delete(Integer.parseInt(idsStr[i]));
}
}
initSystem.loadData(request.getServletContext());
if(flag){
resultMap.put("success", true);
}else{
resultMap.put("success", false);
resultMap.put("errorInfo", "电影动态信息中存在电影网站信息,不能删除!");
}
return resultMap;
}
}
package com.java1234.controller.admin;
/**