Java Project: Cinema Membership Management System (java+SpringBoot+Vue+element-ui+maven+mysql)

Get the source code: Download it from "Resources" on the homepage of the blog!

Project Introduction

The code structure design of this project is simple, the annotations are complete, and the structure is clear, which is suitable for the reference of Java beginners.
The project is a cinema membership management system, developed using a front-end and back-end separation architecture, the front-end is based on Vue.js+Element UI technology, and the back-end is implemented using springboot+mybatis, including administrators, membership management, membership card management, movie tickets, consumption records , data statistics and other modules

environmental needs

1. Operating environment: preferably java jdk 1.8, we are running on this platform. Other versions are also theoretically possible.

2. IDE environment: IDEA, Eclipse, Myeclipse can be used. IDEA is recommended;
3. Tomcat environment: Tomcat 7.x, 8.x, 9.x versions are available
4. Hardware environment: Windows 7/8/10 with more than 1G memory; or Mac OS;
5. Maven project: Yes; Check whether the source code directory contains pom.xml; if so, it is a maven project, otherwise it is a non-maven project
6. Database: MySql 5.7 version;

technology stack

1. Backend: springboot+mybatis

2. Front end: vue.js+element-ui

Instructions for use

* The database file cinema.sql has been integrated into the project, and the database can be generated using mysql import

* This project has integrated the front and back ends. After the front-end files are built by webpack, a static folder and index.html are generated and placed under the webapp.
* To modify the front-end page, after the modification is completed, the generated files are also placed under the webapp of this project.

* Program design documents can refer to the following directory: Cinema membership management system documentation.docx

run the project

* Method 1: The static resources packaged by vue have been integrated in the cinema project, start the project directly, and enter http://localhost:8081/cinema on the browser to run.
1. Use IDEA/Eclipse/MyEclipse to import the project. When importing from Eclipse/MyEclipse, if it is a maven project, please select maven; if it is a maven project, after the import is successful, please execute the maven clean;maven install command to download the required jar package;
2. Use Navicat or other tools to create a database with the corresponding name in mysql, and import the sql file of
the project; 3. Change the database configuration in the db.properties configuration file in the project to your own configuration
4. Configure tomcat, and then run the project, Enter http://localhost:8081/cinema to log
in 5. Account: admin Password: 123123

* Method 2: The cinema-web project is the Vue single-page front-end project of the cinema project. You can enter the command line in the folder directory:
`npm run install`
`npm run dev`

After that, modify the baseURL=”/api” under utils/request.js, open the node reverse proxy server, solve the cross-domain problem, then start the cinema back-end project, and enter http://localhost:8080 on the browser to go back and forth. Run in a separated mode (you can also run the dist folder under nginx after npm run build)

 

 

 

 

 

 

 

 

Background user management controller:

/**
 * 后台用户管理控制器
 * @author yy
 *
 */
@RequestMapping("/admin/user")
@Controller
public class UserController {

	@Autowired
	private UserService userService;
	@Autowired
	private RoleService roleService;
	@Autowired
	private OperaterLogService operaterLogService;
	/**
	 * 用户列表页面
	 * @param model
	 * @param user
	 * @param pageBean
	 * @return
	 */
	@RequestMapping(value="/list")
	public String list(Model model, User user, PageBean<User> pageBean){
		model.addAttribute("title", "用户列表");
		model.addAttribute("username", user.getUsername());
		model.addAttribute("pageBean", userService.findList(user, pageBean));
		return "admin/user/list";
	}
	
	/**
	 * 新增用户页面
	 * @param model
	 * @return
	 */
	@RequestMapping(value="/add",method=RequestMethod.GET)
	public String add(Model model){
		model.addAttribute("roles", roleService.findAll());
		return "admin/user/add";
	}
	
	/**
	 * 用户添加表单提交处理
	 * @param user
	 * @return
	 */
	@RequestMapping(value="/add",method=RequestMethod.POST)
	@ResponseBody
	public Result<Boolean> add(User user){
		//用统一验证实体方法验证是否合法
		CodeMsg validate = ValidateEntityUtil.validate(user);
		if(validate.getCode() != CodeMsg.SUCCESS.getCode()){
			return Result.error(validate);
		}
		if(user.getRole() == null || user.getRole().getId() == null){
			return Result.error(CodeMsg.ADMIN_USER_ROLE_EMPTY);
		}
		//判断用户名是否存在
		if(userService.isExistUsername(user.getUsername(), 0l)){
			return Result.error(CodeMsg.ADMIN_USERNAME_EXIST);
		}
		//到这说明一切符合条件,进行数据库新增
		if(userService.save(user) == null){
			return Result.error(CodeMsg.ADMIN_USE_ADD_ERROR);
		}
		operaterLogService.add("添加用户,用户名:" + user.getUsername());
		return Result.success(true);
	}
	
	/**
	 * 用户编辑页面
	 * @param model
	 * @return
	 */
	@RequestMapping(value="/edit",method=RequestMethod.GET)
	public String edit(Model model,@RequestParam(name="id",required=true)Long id){
		model.addAttribute("roles", roleService.findAll());
		model.addAttribute("user", userService.find(id));
		return "admin/user/edit";
	}
	
	/**
	 * 编辑用户信息表单提交处理
	 * @param user
	 * @return
	 */
	@RequestMapping(value="/edit",method=RequestMethod.POST)
	@ResponseBody
	public Result<Boolean> edit(User user){
		//用统一验证实体方法验证是否合法
		CodeMsg validate = ValidateEntityUtil.validate(user);
		if(validate.getCode() != CodeMsg.SUCCESS.getCode()){
			return Result.error(validate);
		}
		if(user.getRole() == null || user.getRole().getId() == null){
			return Result.error(CodeMsg.ADMIN_USER_ROLE_EMPTY);
		}
		if(user.getId() == null || user.getId().longValue() <= 0){
			return Result.error(CodeMsg.ADMIN_USE_NO_EXIST);
		}
		if(userService.isExistUsername(user.getUsername(), user.getId())){
			return Result.error(CodeMsg.ADMIN_USERNAME_EXIST);
		}
		//到这说明一切符合条件,进行数据库保存
		User findById = userService.find(user.getId());
		//讲提交的用户信息指定字段复制到已存在的user对象中,该方法会覆盖新字段内容
		BeanUtils.copyProperties(user, findById, "id","createTime","updateTime");
		if(userService.save(findById) == null){
			return Result.error(CodeMsg.ADMIN_USE_EDIT_ERROR);
		}
		operaterLogService.add("编辑用户,用户名:" + user.getUsername());
		return Result.success(true);
	}
	
	/**
	 * 删除用户
	 * @param id
	 * @return
	 */
	@RequestMapping(value="/delete",method=RequestMethod.POST)
	@ResponseBody
	public Result<Boolean> delete(@RequestParam(name="id",required=true)Long id){
		try {
			userService.delete(id);
		} catch (Exception e) {
			return Result.error(CodeMsg.ADMIN_USE_DELETE_ERROR);
		}
		operaterLogService.add("添加用户,用户ID:" + id);
		return Result.success(true);
	}
}

Background role management controller:

/**
 * 后台角色管理控制器
 * @author yy
 *
 */
@RequestMapping("/admin/role")
@Controller
public class RoleController {

	
	private Logger log = LoggerFactory.getLogger(RoleController.class);
	
	@Autowired
	private MenuService menuService;
	
	@Autowired
	private OperaterLogService operaterLogService;
	
	@Autowired
	private RoleService roleService;
	
	/**
	 * 分页搜索角色列表
	 * @param model
	 * @param role
	 * @param pageBean
	 * @return
	 */
	@RequestMapping(value="/list")
	public String list(Model model, Role role, PageBean<Role> pageBean){
		model.addAttribute("title", "角色列表");
		model.addAttribute("name", role.getName());
		model.addAttribute("pageBean", roleService.findByName(role, pageBean));
		return "admin/role/list";
	}
	
	/**
	 * 角色添加页面
	 * @param model
	 * @return
	 */
	@RequestMapping(value="/add",method=RequestMethod.GET)
	public String add(Model model){
		List<Menu> findAll = menuService.findAll();
		model.addAttribute("topMenus", MenuUtil.getTopMenus(findAll));
		model.addAttribute("secondMenus",MenuUtil.getSecondMenus(findAll));
		model.addAttribute("thirdMenus",MenuUtil.getThirdMenus(findAll));
		return "admin/role/add";
	}
	
	/**
	 * 角色添加表单提交处理
	 * @param role
	 * @return
	 */
	@RequestMapping(value="/add",method=RequestMethod.POST)
	@ResponseBody
	public Result<Boolean> add(Role role){
		//用统一验证实体方法验证是否合法
		CodeMsg validate = ValidateEntityUtil.validate(role);
		if(validate.getCode() != CodeMsg.SUCCESS.getCode()){
			return Result.error(validate);
		}
		if(roleService.save(role) == null){
			return Result.error(CodeMsg.ADMIN_ROLE_ADD_ERROR);
		}
		log.info("添加角色【"+role+"】");
		operaterLogService.add("添加角色【"+role.getName()+"】");
		return Result.success(true);
	}
	
	/**
	 * 角色编辑页面
	 * @param id
	 * @param model
	 * @return
	 */
	@RequestMapping(value="/edit",method=RequestMethod.GET)
	public String edit(@RequestParam(name="id",required=true)Long id,Model model){
		List<Menu> findAll = menuService.findAll();
		model.addAttribute("topMenus",MenuUtil.getTopMenus(findAll));
		model.addAttribute("secondMenus",MenuUtil.getSecondMenus(findAll));
		model.addAttribute("thirdMenus",MenuUtil.getThirdMenus(findAll));
		Role role = roleService.find(id);
		model.addAttribute("role", role);
		model.addAttribute("authorities",JSONArray.toJSON(role.getAuthorities()).toString());
		return "admin/role/edit";
	}
	
	/**
	 * 角色修改表单提交处理
	 * @param request
	 * @param role
	 * @return
	 */
	@RequestMapping(value="/edit",method=RequestMethod.POST)
	@ResponseBody
	public Result<Boolean> edit(Role role){
		//用统一验证实体方法验证是否合法
		CodeMsg validate = ValidateEntityUtil.validate(role);
		if(validate.getCode() != CodeMsg.SUCCESS.getCode()){
			return Result.error(validate);
		}
		Role existRole = roleService.find(role.getId());
		if(existRole == null){
			return Result.error(CodeMsg.ADMIN_ROLE_NO_EXIST);
		}
		existRole.setName(role.getName());
		existRole.setRemark(role.getRemark());
		existRole.setStatus(role.getStatus());
		existRole.setAuthorities(role.getAuthorities());
		if(roleService.save(existRole) == null){
			return Result.error(CodeMsg.ADMIN_ROLE_EDIT_ERROR);
		}
		log.info("编辑角色【"+role+"】");
		operaterLogService.add("编辑角色【"+role.getName()+"】");
		return Result.success(true);
	}
	
	/**
	 * 删除角色
	 * @param request
	 * @param id
	 * @return
	 */
	@RequestMapping(value="delete",method=RequestMethod.POST)
	@ResponseBody
	public Result<Boolean> delete(@RequestParam(name="id",required=true)Long id){
		try {
			roleService.delete(id);
		} catch (Exception e) {
			// TODO: handle exception
			return Result.error(CodeMsg.ADMIN_ROLE_DELETE_ERROR);
		}
		log.info("编辑角色ID【"+id+"】");
		operaterLogService.add("删除角色ID【"+id+"】");
		return Result.success(true);
	}
}

Movie Management Controller:

/**
 * 电影管理控制器
 * @author yy
 *
 */
@RequestMapping("/admin/movie")
@Controller
public class MovieController {

	@Autowired
	private MovieService movieService;
	@Autowired
	private MovieCommentService movieCommentService;
	
	/**
	 * 电影列表页面
	 * @param model
	 * @return
	 */
	@RequestMapping(value="/list")
	public String list(Model model, Movie movie, PageBean<Movie> pageBean){
		model.addAttribute("pageBean", movieService.findPage(movie, pageBean));
		model.addAttribute("name",movie.getName());
		return "admin/movie/list";
	}
	
	/**
	 * 电影添加页面
	 * @param model
	 * @return
	 */
	@RequestMapping(value="/add",method=RequestMethod.GET)
	public String add(Model model){
		model.addAttribute("movieAreaList", MovieArea.values());
		model.addAttribute("movieTypeList", MovieType.values());
		model.addAttribute("movieLangList", MovieLang.values());
		return "admin/movie/add";
	}
	
	/**
	 * 电影编辑页面
	 * @param model
	 * @param id
	 * @return
	 */
	@RequestMapping(value="/edit",method=RequestMethod.GET)
	public String edit(Model model,@RequestParam(name="id",required=true)Long id){
		model.addAttribute("movie", movieService.findById(id));
		model.addAttribute("movieAreaList", MovieArea.values());
		model.addAttribute("movieTypeList", MovieType.values());
		model.addAttribute("movieLangList", MovieLang.values());
		return "admin/movie/edit";
	}
	
	/**
	 * 添加电影表单提交
	 * @param movie
	 * @return
	 */
	@RequestMapping(value="/add",method=RequestMethod.POST)
	@ResponseBody
	public Result<Boolean> add(Movie movie){
		if(movie == null){
			return Result.error(CodeMsg.DATA_ERROR);
		}
		CodeMsg validate = ValidateEntityUtil.validate(movie);
		if(validate.getCode() != CodeMsg.SUCCESS.getCode()){
			return Result.error(validate);
		}
		//判断是否是编辑
		if(movie.getId() != null && movie.getId() > 0){
			Movie findById = movieService.findById(movie.getId());
			movie.setCreateTime(findById.getCreateTime());
			movie.setRate(findById.getRate());
			movie.setRateCount(findById.getRateCount());
			movie.setTotalMoney(findById.getTotalMoney());
		}
		//表示数据合法,可以保存到数据库
		if(movieService.save(movie) == null){
			return Result.error(CodeMsg.ADMIN_AREA_SAVE_ERROR);
		}
		return Result.success(true);
	}
	
	/**
	 * 删除
	 * @param id
	 * @return
	 */
	@RequestMapping(value="/delete",method=RequestMethod.POST)
	@ResponseBody
	public Result<Boolean> delete(@RequestParam(name="id",required=true)Long id){
		try {
			movieService.delete(id);
		} catch (Exception e) {
			return Result.error(CodeMsg.ADMIN_MOVIE_DELETE_ERROR);
		}
		return Result.success(true);
	}
	
	
	/**
	 * ----------电影评价管理-------------
	 */
	/**
	 * 电影评价列表
	 * @param model
	 * @param movieComment
	 * @param pageBean
	 * @return
	 */
	@RequestMapping(value="/comment_list")
	public String list(Model model,MovieComment movieComment,PageBean<MovieComment> pageBean){
		model.addAttribute("pageBean", movieCommentService.findPage(movieComment, pageBean));
		model.addAttribute("content",movieComment.getContent());
		return "admin/movie/comment_list";
	}
	
	/**
	 * 删除评价
	 * @param id
	 * @return
	 */
	@RequestMapping(value="/delete_comment",method=RequestMethod.POST)
	@ResponseBody
	public Result<Boolean> deleteComment(@RequestParam(name="id",required=true)Long id){
		movieCommentService.delete(id);
		return Result.success(true);
	}
}

Order Management Controller:

/**
 * 订单管理控制器
 * @author yy
 *
 */
@RequestMapping("/admin/order")
@Controller
public class OrderController {

	@Autowired
	private OrderService orderService;
	@Autowired
	private OrderItemService orderItemService;
	
	/**
	 * 订单列表
	 * @param model
	 * @param order
	 * @param pageBean
	 * @return
	 */
	@RequestMapping(value="/list")
	public String list(Model model, Order order, PageBean<Order> pageBean){
		model.addAttribute("pageBean", orderService.findPage(order, pageBean));
		model.addAttribute("sn",order.getSn());
		return "admin/order/list";
	}
	
	/**
	 * 查看订单详情
	 * @param orderId
	 * @return
	 */
	@RequestMapping(value="/view_detail",method=RequestMethod.POST)
	@ResponseBody
	public Result<List<OrderItem>> viewDetail(@RequestParam(name="orderId",required=true)Long orderId){
		return Result.success(orderItemService.find(orderId));
	}
}

Sequence management controller:

/**
 * 排片场次管理控制器
 * @author yy
 *
 */
@RequestMapping("/admin/cinema_hall_session")
@Controller
public class CinemaHallSessionController {

	@Autowired
	private CinemaService cinemaService;
	@Autowired
	private CinemaHallService cinemaHallService;
	@Autowired
	private MovieService movieService;
	@Autowired
	private CinemaHallSessionService cinemaHallSessionService;
	
	/**
	 * 排片场次列表页面
	 * @param model
	 * @return
	 */
	@RequestMapping(value="/list")
	public String list(Model model, CinemaHallSession cinemaHallSession, PageBean<CinemaHallSession> pageBean){
		model.addAttribute("pageBean", cinemaHallSessionService.findPage(cinemaHallSession, pageBean));
		model.addAttribute("showDate",cinemaHallSession.getShowDate());
		return "admin/cinema_hall_session/list";
	}
	
	/**
	 * 排片场次添加页面
	 * @param model
	 * @return
	 */
	@RequestMapping(value="/add",method=RequestMethod.GET)
	public String add(Model model){
		model.addAttribute("cinemaList", cinemaService.findAll());
		model.addAttribute("movieList", movieService.findAll());
		model.addAttribute("cinemaSessionTypeList", CinemaSessionType.values());
		return "admin/cinema_hall_session/add";
	}
	
	/**
	 * 排片场次编辑页面
	 * @param model
	 * @param id
	 * @return
	 */
	@RequestMapping(value="/edit",method=RequestMethod.GET)
	public String edit(Model model,@RequestParam(name="id",required=true)Long id){
		model.addAttribute("cinemaHallSession", cinemaHallSessionService.findById(id));
		model.addAttribute("movieList", movieService.findAll());
		model.addAttribute("cinemaList", cinemaService.findAll());
		model.addAttribute("cinemaSessionTypeList", CinemaSessionType.values());
		return "admin/cinema_hall_session/edit";
	}
	
	/**
	 * 添加排片场次表单提交
	 * @param cinemaHallSession
	 * @return
	 */
	@RequestMapping(value="/add",method=RequestMethod.POST)
	@ResponseBody
	public Result<Boolean> add(CinemaHallSession cinemaHallSession){
		if(cinemaHallSession == null){
			return Result.error(CodeMsg.DATA_ERROR);
		}
		CodeMsg validate = ValidateEntityUtil.validate(cinemaHallSession);
		if(validate.getCode() != CodeMsg.SUCCESS.getCode()){
			return Result.error(validate);
		}
		//判断是否是编辑
		if(cinemaHallSession.getId() != null && cinemaHallSession.getId() > 0){
			CinemaHallSession findById = cinemaHallSessionService.findById(cinemaHallSession.getId());
			cinemaHallSession.setCreateTime(findById.getCreateTime());
		}
		//生成散场时间
		String startTime = cinemaHallSession.getShowDate() + " " + cinemaHallSession.getShowTime();
		cinemaHallSession.setStartTime(startTime);
		cinemaHallSession.setEndTime(StringUtil.getFormatterDate(startTime, "yyyy-MM-dd HH:mm", Integer.valueOf(cinemaHallSession.getMovie().getTime())));
		if(cinemaHallSessionService.isExistHall(cinemaHallSession.getId(),cinemaHallSession.getCinemaHall().getId(), cinemaHallSession.getShowDate(), startTime,cinemaHallSession.getEndTime())){
			return Result.error(CodeMsg.ADMIN_CINEMA_HALL_SESSION_SAVE_EXIST);
		}
		//表示数据合法,可以保存到数据库
		if(cinemaHallSessionService.save(cinemaHallSession) == null){
			return Result.error(CodeMsg.ADMIN_CINEMA_HALL_SESSION_SAVE_ERROR);
		}
		return Result.success(true);
	}
	
	/**
	 * 删除
	 * @param id
	 * @return
	 */
	@RequestMapping(value="/delete",method=RequestMethod.POST)
	@ResponseBody
	public Result<Boolean> delete(@RequestParam(name="id",required=true)Long id){
		try {
			cinemaHallSessionService.delete(id);
		} catch (Exception e) {
			return Result.error(CodeMsg.ADMIN_CINEMA_HALL_SESSION_DELETE_ERROR);
		}
		return Result.success(true);
	}
	
	
}

Get the source code: Download it from "Resources" on the homepage of the blog! 

Guess you like

Origin blog.csdn.net/yuyecsdn/article/details/124218423