Java project: Cinema member management system (java + springboot + Vue + element UI + Maven + MySQL)

Source code acquisition: download from "resources" on the blog home page!

Project introduction

This project has simple code architecture design, complete comments and clear structure, which is suitable for java beginners.
The project is a set of cinema member management system, which is developed using the front-end and back-end separation architecture, and the front-end is based on Vue JS + element UI technology, the back-end is realized by springboot+mybatis, including administrator, member management, membership card management, movie tickets, consumption records, data statistics and other modules

Environmental needs

1. Running environment: java jdk 1.8 is preferred. We run it on this platform. Other versions are theoretically OK.

2.IDE environment: IDEA, eclipse and MyEclipse are OK. Recommend IDEA;
3.tomcat environment: Tomcat 7 x,8. x,9. X version
4. Hardware environment: Windows 7 / 8 / 10 with more than 1G memory; Or Mac OS;
5. Maven project: Yes; Check whether the source directory contains POM xml; If yes, it is a maven project; otherwise, it is a non Maven project
6. Database: MySQL version 5.7;

Technology stack

1. Back end: springboot+mybatis

Front end: Vue 2 js+element-ui

instructions

*Database file cinema SQL has been integrated into the project, and the database can be generated by importing mysql

*The front-end and back-end of the project have been integrated. After the front-end files are built by webpack, the static folder and index. XML are generated Html is put under webapp.
*To modify the front-end page, the generated file will also be placed under the webapp of the project after modification.

*Program design documents can refer to the directory: Cinema member management system description documents docx

Run project

*Method 1: Cinema project has integrated the static resources packaged by vue, directly start the project and input it on the browser http://localhost:8081/cinema Can run.
1. Use IDEA/Eclipse/MyEclipse to import the project. When importing Eclipse/MyEclipse, if it is a maven project, please select Maven; If it is a maven project, please execute Maven clean after successful import; 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. DB. In the project Change the database configuration in the properties configuration file to your own configuration
4. Configure tomcat, then run the project and enter http://localhost:8081/cinema Login
5. Account: admin Password: 123123

*Method 2: Cinema web project is a vue single page front-end project of cinema project, which can be entered on the command line under the folder Directory:
`npm run install`
`npm run dev`

After, modify utils / request JS "baseURL =" / api ", start the node reverse proxy server to solve the cross domain problem, then start the cinema back-end project and enter it in the browser http://localhost:8080 That is, it can be run in front and back-end separation mode (or put the dist folder under nginx after npm run build)

 

 

 

 

 

 

Background user management controller:

/**
 * 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;
	/**
	 * User list page
	 * @param model
	 * @param user
	 * @param pageBean
	 * @return
	 */
	@RequestMapping(value="/list")
	public String list(Model model, User user, PageBean<User> pageBean){
		model.addAttribute("title", "User list");
		model.addAttribute("username", user.getUsername());
		model.addAttribute("pageBean", userService.findList(user, pageBean));
		return "admin/user/list";
	}
	
	/**
	 * New user page
	 * @param model
	 * @return
	 */
	@RequestMapping(value="/add",method=RequestMethod.GET)
	public String add(Model model){
		model.addAttribute("roles", roleService.findAll());
		return "admin/user/add";
	}
	
	/**
	 * User added form submission processing
	 * @param user
	 * @return
	 */
	@RequestMapping(value="/add",method=RequestMethod.POST)
	@ResponseBody
	public Result<Boolean> add(User user){
		//Use the unified entity verification method to verify whether it is legal
		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);
		}
		//Determine whether the user name exists
		if(userService.isExistUsername(user.getUsername(), 0l)){
			return Result.error(CodeMsg.ADMIN_USERNAME_EXIST);
		}
		//This shows that everything meets the conditions and the database is added
		if(userService.save(user) == null){
			return Result.error(CodeMsg.ADMIN_USE_ADD_ERROR);
		}
		operaterLogService.add("Add user, user name:" + user.getUsername());
		return Result.success(true);
	}
	
	/**
	 * User edit page
	 * @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";
	}
	
	/**
	 * Edit user information form submission processing
	 * @param user
	 * @return
	 */
	@RequestMapping(value="/edit",method=RequestMethod.POST)
	@ResponseBody
	public Result<Boolean> edit(User user){
		//Use the unified entity verification method to verify whether it is legal
		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);
		}
		//This means that everything meets the conditions and the database is saved
		User findById = userService.find(user.getId());
		//The specified field of the submitted user information is copied to the existing user object, and this method will overwrite the content of the new field
		BeanUtils.copyProperties(user, findById, "id","createTime","updateTime");
		if(userService.save(findById) == null){
			return Result.error(CodeMsg.ADMIN_USE_EDIT_ERROR);
		}
		operaterLogService.add("Edit user name:" + user.getUsername());
		return Result.success(true);
	}
	
	/**
	 * delete user
	 * @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("Add user ID: " + id);
		return Result.success(true);
	}
}

Background role management controller:

/**
 * 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;
	
	/**
	 * Paging search role list
	 * @param model
	 * @param role
	 * @param pageBean
	 * @return
	 */
	@RequestMapping(value="/list")
	public String list(Model model, Role role, PageBean<Role> pageBean){
		model.addAttribute("title", "Role list");
		model.addAttribute("name", role.getName());
		model.addAttribute("pageBean", roleService.findByName(role, pageBean));
		return "admin/role/list";
	}
	
	/**
	 * Role add page
	 * @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";
	}
	
	/**
	 * Role addition form submission processing
	 * @param role
	 * @return
	 */
	@RequestMapping(value="/add",method=RequestMethod.POST)
	@ResponseBody
	public Result<Boolean> add(Role role){
		//Use the unified entity verification method to verify whether it is legal
		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("Add role["+role+"]");
		operaterLogService.add("Add role["+role.getName()+"]");
		return Result.success(true);
	}
	
	/**
	 * Role edit page
	 * @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";
	}
	
	/**
	 * Role modification form submission processing
	 * @param request
	 * @param role
	 * @return
	 */
	@RequestMapping(value="/edit",method=RequestMethod.POST)
	@ResponseBody
	public Result<Boolean> edit(Role role){
		//Use the unified entity verification method to verify whether it is legal
		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("Edit role["+role+"]");
		operaterLogService.add("Edit role["+role.getName()+"]");
		return Result.success(true);
	}
	
	/**
	 * Delete role
	 * @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("Edit role ID["+id+"]");
		operaterLogService.add("Delete role ID["+id+"]");
		return Result.success(true);
	}
}

Movie management controller:

/**
 * Movie management controller
 * @author yy
 *
 */
@RequestMapping("/admin/movie")
@Controller
public class MovieController {

	@Autowired
	private MovieService movieService;
	@Autowired
	private MovieCommentService movieCommentService;
	
	/**
	 * Movie list page
	 * @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";
	}
	
	/**
	 * Movie add page
	 * @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";
	}
	
	/**
	 * Movie editing page
	 * @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";
	}
	
	/**
	 * Add movie form submission
	 * @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);
		}
		//Determine whether to edit
		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());
		}
		//Indicates that the data is legal and can be saved to the database
		if(movieService.save(movie) == null){
			return Result.error(CodeMsg.ADMIN_AREA_SAVE_ERROR);
		}
		return Result.success(true);
	}
	
	/**
	 * delete
	 * @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);
	}
	
	
	/**
	 * ----------Film evaluation management-------------
	 */
	/**
	 * Film review list
	 * @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";
	}
	
	/**
	 * Delete evaluation
	 * @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:

/**
 * Order management controller
 * @author yy
 *
 */
@RequestMapping("/admin/order")
@Controller
public class OrderController {

	@Autowired
	private OrderService orderService;
	@Autowired
	private OrderItemService orderItemService;
	
	/**
	 * Order list
	 * @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";
	}
	
	/**
	 * View order details
	 * @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));
	}
}

Layout field management controller:

/**
 * Film arrangement field 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;
	
	/**
	 * Film arrangement session list page
	 * @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";
	}
	
	/**
	 * Film arrangement session addition page
	 * @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";
	}
	
	/**
	 * Film arrangement editing page
	 * @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";
	}
	
	/**
	 * Add film layout session form submission
	 * @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);
		}
		//Determine whether to edit
		if(cinemaHallSession.getId() != null && cinemaHallSession.getId() > 0){
			CinemaHallSession findById = cinemaHallSessionService.findById(cinemaHallSession.getId());
			cinemaHallSession.setCreateTime(findById.getCreateTime());
		}
		//Generation and dispersion time
		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);
		}
		//Indicates that the data is legal and can be saved to the database
		if(cinemaHallSessionService.save(cinemaHallSession) == null){
			return Result.error(CodeMsg.ADMIN_CINEMA_HALL_SESSION_SAVE_ERROR);
		}
		return Result.success(true);
	}
	
	/**
	 * delete
	 * @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);
	}
	
	
}

Source code acquisition: download from "resources" on the blog home page!  

Tags: Java MySQL Vue Maven Spring Boot

Posted by shakazulu on Sat, 16 Apr 2022 19:46:35 +0930