基于javaweb+mysql的ssm+maven教室预约管理系统(java+jsp+ssm+bootstrap+javascript+mysql)

基于javaweb+mysql的ssm+maven教室预约管理系统(java+jsp+ssm+bootstrap+javascript+mysql)

私信源码获取及调试交流

运行环境

Java≥8、MySQL≥5.7、Tomcat≥8

开发工具

eclipse/idea/myeclipse/sts等均可配置运行

适用

课程设计,大作业,毕业设计,项目练习,学习演示等

功能说明

基于javaweb的SSM+Maven教室预约管理系统(java+jsp+ssm+bootstrap+javascript+mysql)

项目介绍

本项目包含管理员与用户两种角色;

管理员角色包含以下功能: 管理员登陆,教室信息管理,预约审核,预约记录查询,注册用户等功能。

用户角色包含以下功能: 用户登录,教室信息查询,预约记录查询,预约教室,个人信息修改等功能。

环境需要

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.数据库:MySql 5.7版本; 6.是否Maven项目:是;

技术栈

  1. 后端:Spring+SpringMVC+Mybatis 2. 前端:JSP+CSS+JavaScript+jQuery+bootstrap

使用说明

  1. 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件; 2. 使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven; 若为maven项目,导入成功后请执行maven clean;maven install命令,然后运行; 3. 将项目中db.properties配置文件中的数据库配置改为自己的配置; 4. 运行项目,输入localhost:8080/ 登录
		//页码对象
		PagingVO pagingVO = new PagingVO();
		//设置总页数
		pagingVO.setTotalCount(reservationService.reservationCount());
		if (page == null || page == 0) {
			pagingVO.setToPageNo(1);
			list = reservationService.findByPaging(1);
		} else {
			pagingVO.setToPageNo(page);
			list = reservationService.findByPaging(page);
		}

		model.addAttribute("reservationList", list);
		model.addAttribute("pagingVO", pagingVO);

		return "/admin/showReservation";
	}

	//搜索预约人
	@RequestMapping(value = "queryUser", method = {RequestMethod.POST})
	private String queryUser(String findByName, Model model) throws Exception {

		List<Reservation> list = reservationService.findByName(findByName);

		model.addAttribute("reservationList", list);
		return "/admin/showReservation";
	}

	//同意教室申请
	@RequestMapping("/reviewReservation")
	public String reviewReservation(Integer id) throws Exception{
		reservationService.reviewReservation(id);
		return "redirect:/admin/showReservation";
	}

	//同意教室申请
	@RequestMapping("/rejectReservation")
	public String rejectReservation(Integer id) throws Exception{
		reservationService.rejectReservation(id);
		return "redirect:/admin/showReservation";
	}

		return "/ordinary/showUser";
	}

	//查询接下来的15天内所有已被预约的教室记录
	@RequestMapping("/showRecord")
	public String findAllReservation(Model model, Integer page) throws Exception {
		List<ReservationVo> list = null;

		//页码对象
		PagingVO pagingVO = new PagingVO();
		//设置总页数
		pagingVO.setTotalCount(reservationService.reserveCount());
		if (page == null || page == 0) {
			pagingVO.setToPageNo(1);
			list = reservationService.findAllByPaging(1);
		} else {
			pagingVO.setToPageNo(page);
			list = reservationService.findAllByPaging(page);
		}

		model.addAttribute("recordList", list);
		model.addAttribute("pagingVo", pagingVO);

		return "/ordinary/showRecord";
	}

	//搜索借用人
	@RequestMapping(value = "/queryByUser", method = {RequestMethod.POST})
	private String queryUser(String findByName, Model model) throws Exception {

		List<ReservationVo> list = reservationService.queryByUser(findByName);

		model.addAttribute("recordList", list);

		return "/ordinary/showRecord";
	}

	//预约教室页面跳转
	@RequestMapping(value = "/reserveRoom", method = RequestMethod.GET)
	public String reserveRoomUI(Model model,HttpServletRequest request) throws Exception {
		//从数据库查询出所有教室信息回显到页面
		List<Room> list = roomService.nameList();
		model.addAttribute("nameList", list);
		User user = (User) request.getSession().getAttribute("usersession");
		model.addAttribute("object", user);
		return "/ordinary/reserveRoom";
	}

	//预约教室功能实现
	@RequestMapping(value = "/reserveRoom", method = RequestMethod.POST)
	public String reserveRoom(ReservationCustom reservationCustom) throws Exception {
		return "/ordinary/showRoom";
	}

	//搜索教室
	@RequestMapping(value = "/queryRoom", method = {RequestMethod.POST})
	private String queryRoom(String findByName, Model model) throws Exception {

		List<Room> list = roomService.findByName(findByName);

		model.addAttribute("roomList", list);
		return "/ordinary/showRoom";
	}

	//个人信息修改
	@RequestMapping(value = "/showUser", method = {RequestMethod.GET})
	private String showUser(Model model,HttpServletRequest request) throws Exception {
		String id = String.valueOf(request.getSession().getAttribute("user"));
		User user = userService.findUserById(id);
		model.addAttribute("object", user);
		return "/ordinary/showUser";
	}

	//个人信息修改
	@RequestMapping(value = "/changeUser", method = {RequestMethod.POST})
	private String changeUser(String password, String username, Model model,HttpServletRequest request) throws Exception {
		String id = String.valueOf(request.getSession().getAttribute("user"));
		User user = userService.findUserById(id);
		user.setUsername(username);
		user.setPassword(password);
		userService.updateUser(user);
		model.addAttribute("object", user);
		return "/ordinary/showUser";
	}

	//查询接下来的15天内所有已被预约的教室记录
	@RequestMapping("/showRecord")
	public String findAllReservation(Model model, Integer page) throws Exception {
		List<ReservationVo> list = null;

		//页码对象
		PagingVO pagingVO = new PagingVO();
		//设置总页数
		pagingVO.setTotalCount(reservationService.reserveCount());
	@RequestMapping("/reviewReservation")
	public String reviewReservation(Integer id) throws Exception{
		reservationService.reviewReservation(id);
		return "redirect:/admin/showReservation";
	}

	//同意教室申请
	@RequestMapping("/rejectReservation")
	public String rejectReservation(Integer id) throws Exception{
		reservationService.rejectReservation(id);
		return "redirect:/admin/showReservation";
	}

	//查询所有审核通过预约记录
	@RequestMapping("/showRecord")
	public String findRecord(Model model,Integer page) throws Exception{
		List<ReservationVo> list = null;

		//页码对象
		PagingVO pagingVO = new PagingVO();
		//设置总页数
		pagingVO.setTotalCount(reservationService.reservationPassCount());
		if (page == null || page == 0) {
			pagingVO.setToPageNo(1);
			list = reservationService.findRecord(1);
		} else {
			pagingVO.setToPageNo(page);
			list = reservationService.findRecord(page);
		}

		model.addAttribute("recordList", list);
		model.addAttribute("pagingVo", pagingVO);

		return "/admin/showRecord";
	}

	//查询所有审核未通过预约记录
	@RequestMapping("/showRecordReject")
	public String showRecordReject(Model model,Integer page) throws Exception{
		List<ReservationVo> list = null;

		//页码对象
        //如果获取不到用户名就是登录失败,但登录失败的话,会直接抛出异常
        try {
			subject.login(token);
		} catch (Exception e) {
//			return "/login";
            model.addAttribute("message","用户名或密码错误");
            return "/error";
		}

        if (subject.hasRole("admin")) {
        	request.getSession().setAttribute("admin", user.getId());
        	request.getSession().setAttribute("usersession", userService.findUserById(user.getId()));
            return "redirect:/admin/showRoom";
        } else if (subject.hasRole("ordinary")) {
        	request.getSession().setAttribute("user", user.getId());
        	request.getSession().setAttribute("usersession", userService.findUserById(user.getId()));
            return "redirect:/ordinary/showRoom";
        }

        model.addAttribute("message","登录异常,请联系管理员");
        return "/error";
    }

    // 注册跳转
    @RequestMapping(value = "/register",method = {RequestMethod.GET})
    public String registerUI() throws Exception{
        return "/register";
    }

    //注册表单处理
    @RequestMapping(value = "/register", method = {RequestMethod.POST})
    public String register(Model model,User user, HttpServletRequest request) throws Exception {

        // 获取用户输入的验证码
        String checkCode = request.getParameter("checkCode");

        // 比对验证码,若不对,则返回
        String checkCodeGen = request.getSession().getAttribute("checkCodeGen").toString();

        if (!checkCodeGen.equalsIgnoreCase(checkCode)){  
            model.addAttribute("message","验证码输入有误");
            return "redirect:/register";
        }

        if(user.getUsername()!=null && user.getUsername()!="" && user.getPassword()!=null && user.getPassword()!=""){
            user.setId(user.getUsername());

            // 查看用户id是否存在
            User userById = userService.findUserById(user.getId());
            if (userById !=null){
                model.addAttribute("message","用户名已存在");

/**
 */
@Controller
@RequestMapping("/ordinary")
public class OrdinaryController {

	@Resource(name = "roomServiceImpl")
	private RoomService roomService;

	@Resource(name = "reservationServiceImpl")
	private ReservationService reservationService;

	@Resource(name = "userServiceImpl")
	private UserService userService;

	/*<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<教室信息管理>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/
	// 教室信息显示
	@RequestMapping("/showRoom")
	public String showRoom(Model model, Integer page) throws Exception {

		List<Room> list = null;
		//页码对象
		PagingVO pagingVO = new PagingVO();
		//设置总页数
	@RequestMapping(value = "/queryRoom", method = {RequestMethod.POST})
	private String queryRoom(String findByName, Model model) throws Exception {

		List<Room> list = roomService.findByName(findByName);

		model.addAttribute("roomList", list);
		return "/admin/showRoom";
	}

	//添加教室页面跳转
	@RequestMapping(value = "/addRoom", method = {RequestMethod.GET})
	public String addRoom(Model model) throws Exception {

		return "/admin/addRoom";
	}

	//添加教室业务实现
	@RequestMapping(value = "/addRoom", method = {RequestMethod.POST})
	public String addRoom(Room room, Model model) throws Exception {

		roomService.add(room);

		return "redirect:/admin/showRoom";
	}

	// 修改教室信息页面显示
	@RequestMapping(value = "/editRoom", method = {RequestMethod.GET})
	public String editRoomUI(Integer id, Model model) throws Exception {
		if (id == null) {
			return "redirect:/admin/showRoom";
		}
		Room room = roomService.findById(id);
		model.addAttribute("roomList", room);

		return "/admin/editRoom";
	}

	// 修改教室信息页面处理
	@RequestMapping(value = "/editRoom", method = {RequestMethod.POST})
	public String editRoom(Room room) throws Exception {
		roomService.updateById(room);

		//重定向
		return "redirect:/admin/showRoom";
	}

		List<ReservationVo> list = reservationService.queryByUser(findByName);

		model.addAttribute("recordList", list);

		return "/ordinary/showRecord";
	}

	//预约教室页面跳转
	@RequestMapping(value = "/reserveRoom", method = RequestMethod.GET)
	public String reserveRoomUI(Model model,HttpServletRequest request) throws Exception {
		//从数据库查询出所有教室信息回显到页面
		List<Room> list = roomService.nameList();
		model.addAttribute("nameList", list);
		User user = (User) request.getSession().getAttribute("usersession");
		model.addAttribute("object", user);
		return "/ordinary/reserveRoom";
	}

	//预约教室功能实现
	@RequestMapping(value = "/reserveRoom", method = RequestMethod.POST)
	public String reserveRoom(ReservationCustom reservationCustom) throws Exception {

		reservationService.addReservation(reservationCustom);

		return "redirect:/ordinary/showRecord";
	}

	//取消预约申请页面跳转
	@RequestMapping(value = "/cancelApplication",method = RequestMethod.GET)
	public String cancelApplicationUI(String user,Model model) throws Exception{
		List<ReservationCustom> list=reservationService.findByUser(user);
		model.addAttribute("reserveList",list);

		return "/ordinary/cancelApplication";
	}

	//取消预约申请业务实现
	@RequestMapping("/cancelApply")
	public String cancelApplication(Integer id) throws Exception{
		reservationService.cancelApplication(id);

		return "redirect:/ordinary/showRecord";
	}

}
		//页码对象
		PagingVO pagingVO = new PagingVO();
		//设置总页数
		pagingVO.setTotalCount(reservationService.reservationNoPassCount());
		if (page == null || page == 0) {
			pagingVO.setToPageNo(1);
			list = reservationService.findRejectRecord(pagingVO);
		} else {
			pagingVO.setToPageNo(page);
			list = reservationService.findRejectRecord(pagingVO);
		}

		model.addAttribute("recordList", list);
		model.addAttribute("pagingVo", pagingVO);

		return "/admin/showRecordReject";
	}

	/*<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<用户信息管理>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/
	//添加新用户
	@RequestMapping(value = "/userRegister", method = {RequestMethod.GET})
	public String userRegister(Model model) throws Exception {
		return "/admin/userRegister";
	}

	@RequestMapping(value = "/userRegister",method = RequestMethod.POST)
	public String userRegister(User user) throws Exception{
		if(user.getId()!=null && user.getId()!="" && user.getPassword()!=null && user.getPassword()!=""){
			user.setUsername(user.getId());
			userService.addNewUser(user);
		}
		return "redirect:/admin/userRegister";
	}
}

	@RequestMapping(value = "/addRoom", method = {RequestMethod.POST})
	public String addRoom(Room room, Model model) throws Exception {

		roomService.add(room);

		return "redirect:/admin/showRoom";
	}

	// 修改教室信息页面显示
	@RequestMapping(value = "/editRoom", method = {RequestMethod.GET})
	public String editRoomUI(Integer id, Model model) throws Exception {
		if (id == null) {
			return "redirect:/admin/showRoom";
		}
		Room room = roomService.findById(id);
		model.addAttribute("roomList", room);

		return "/admin/editRoom";
	}

	// 修改教室信息页面处理
	@RequestMapping(value = "/editRoom", method = {RequestMethod.POST})
	public String editRoom(Room room) throws Exception {
		roomService.updateById(room);

		//重定向
		return "redirect:/admin/showRoom";
	}

	//个人信息修改
	@RequestMapping(value = "/showUser", method = {RequestMethod.GET})
	private String showUser(Model model,HttpServletRequest request) throws Exception {
		String id = String.valueOf(request.getSession().getAttribute("admin"));
		User user = userService.findUserById(id);
		model.addAttribute("object", user);
		return "/admin/showUser";
	}

	//个人信息修改
	@RequestMapping(value = "/changeUser", method = {RequestMethod.POST})
	private String changeUser(String password, String username, Model model,HttpServletRequest request) throws Exception {
		String id = String.valueOf(request.getSession().getAttribute("admin"));
		User user = userService.findUserById(id);
		user.setUsername(username);
		user.setPassword(password);
		userService.updateUser(user);
		model.addAttribute("object", user);
		return "/admin/showUser";
	}
		Room room = roomService.findById(id);
		model.addAttribute("roomList", room);

		return "/admin/editRoom";
	}

	// 修改教室信息页面处理
	@RequestMapping(value = "/editRoom", method = {RequestMethod.POST})
	public String editRoom(Room room) throws Exception {
		roomService.updateById(room);

		//重定向
		return "redirect:/admin/showRoom";
	}

	//个人信息修改
	@RequestMapping(value = "/showUser", method = {RequestMethod.GET})
	private String showUser(Model model,HttpServletRequest request) throws Exception {
		String id = String.valueOf(request.getSession().getAttribute("admin"));
		User user = userService.findUserById(id);
		model.addAttribute("object", user);
		return "/admin/showUser";
	}

	//个人信息修改
	@RequestMapping(value = "/changeUser", method = {RequestMethod.POST})
	private String changeUser(String password, String username, Model model,HttpServletRequest request) throws Exception {
		String id = String.valueOf(request.getSession().getAttribute("admin"));
		User user = userService.findUserById(id);
		user.setUsername(username);
		user.setPassword(password);
		userService.updateUser(user);
		model.addAttribute("object", user);
		return "/admin/showUser";
	}

	// 删除教室信息
	@RequestMapping("/removeRoom")
	public String removeRoom(Integer id) throws Exception {
		if (id == null) {
			//加入没有带教师id就进来的话就返回教师显示页面
			return "/admin/showRoom";
		}
		roomService.removeById(id);

		return "redirect:/admin/showRoom";
	}

	/*<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<教室预约管理>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/
	//查询所有待审核预约记录
	public String reserveRoomUI(Model model,HttpServletRequest request) throws Exception {
		//从数据库查询出所有教室信息回显到页面
		List<Room> list = roomService.nameList();
		model.addAttribute("nameList", list);
		User user = (User) request.getSession().getAttribute("usersession");
		model.addAttribute("object", user);
		return "/ordinary/reserveRoom";
	}

	//预约教室功能实现
	@RequestMapping(value = "/reserveRoom", method = RequestMethod.POST)
	public String reserveRoom(ReservationCustom reservationCustom) throws Exception {

		reservationService.addReservation(reservationCustom);

		return "redirect:/ordinary/showRecord";
	}

	//取消预约申请页面跳转
	@RequestMapping(value = "/cancelApplication",method = RequestMethod.GET)
	public String cancelApplicationUI(String user,Model model) throws Exception{
		List<ReservationCustom> list=reservationService.findByUser(user);
		model.addAttribute("reserveList",list);

		return "/ordinary/cancelApplication";
	}

	//取消预约申请业务实现
	@RequestMapping("/cancelApply")
	public String cancelApplication(Integer id) throws Exception{
		reservationService.cancelApplication(id);

		return "redirect:/ordinary/showRecord";
	}

}

			//加入没有带教师id就进来的话就返回教师显示页面
			return "/admin/showRoom";
		}
		roomService.removeById(id);

		return "redirect:/admin/showRoom";
	}

	/*<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<教室预约管理>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/
	//查询所有待审核预约记录
	@RequestMapping("/showReservation")
	public String findAllReservation(Model model,Integer page) throws Exception {
		List<ReservationVo> list = null;

		//页码对象
		PagingVO pagingVO = new PagingVO();
		//设置总页数
		pagingVO.setTotalCount(reservationService.reservationCount());
		if (page == null || page == 0) {
			pagingVO.setToPageNo(1);
			list = reservationService.findByPaging(1);
		} else {
			pagingVO.setToPageNo(page);
			list = reservationService.findByPaging(page);
		}

		model.addAttribute("reservationList", list);
		model.addAttribute("pagingVO", pagingVO);

		return "/admin/showReservation";
	}

	//搜索预约人
	@RequestMapping(value = "queryUser", method = {RequestMethod.POST})
	private String queryUser(String findByName, Model model) throws Exception {

		List<Reservation> list = reservationService.findByName(findByName);

		model.addAttribute("reservationList", list);
		return "/admin/showReservation";
	}

			list = reservationService.findByPaging(page);
		}

		model.addAttribute("reservationList", list);
		model.addAttribute("pagingVO", pagingVO);

		return "/admin/showReservation";
	}

	//搜索预约人
	@RequestMapping(value = "queryUser", method = {RequestMethod.POST})
	private String queryUser(String findByName, Model model) throws Exception {

		List<Reservation> list = reservationService.findByName(findByName);

		model.addAttribute("reservationList", list);
		return "/admin/showReservation";
	}

	//同意教室申请
	@RequestMapping("/reviewReservation")
	public String reviewReservation(Integer id) throws Exception{
		reservationService.reviewReservation(id);
		return "redirect:/admin/showReservation";
	}

	//同意教室申请
	@RequestMapping("/rejectReservation")
	public String rejectReservation(Integer id) throws Exception{
		reservationService.rejectReservation(id);
		return "redirect:/admin/showReservation";
	}

	//查询所有审核通过预约记录
	@RequestMapping("/showRecord")
	public String findRecord(Model model,Integer page) throws Exception{
		List<ReservationVo> list = null;

		//页码对象
		PagingVO pagingVO = new PagingVO();
		//设置总页数
		pagingVO.setTotalCount(reservationService.reservationPassCount());
		if (page == null || page == 0) {
			pagingVO.setToPageNo(1);
			list = reservationService.findRecord(1);
		} else {
			pagingVO.setToPageNo(page);
			list = reservationService.findRecord(page);
	/*<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<教室信息管理>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/
	// 教室信息显示
	@RequestMapping("/showRoom")
	public String showRoom(Model model, Integer page) throws Exception {

		List<Room> list = null;
		//页码对象
		PagingVO pagingVO = new PagingVO();
		//设置总页数
		pagingVO.setTotalCount(roomService.roomCount());
		if (page == null || page == 0) {
			pagingVO.setToPageNo(1);
			list = roomService.findByPaging(1);
		} else {
			pagingVO.setToPageNo(page);
			list = roomService.findByPaging(page);
		}

		model.addAttribute("roomList", list);
		model.addAttribute("pagingVO", pagingVO);

		return "/ordinary/showRoom";
	}

	//搜索教室
	@RequestMapping(value = "/queryRoom", method = {RequestMethod.POST})
	private String queryRoom(String findByName, Model model) throws Exception {

		List<Room> list = roomService.findByName(findByName);

		model.addAttribute("roomList", list);
		return "/ordinary/showRoom";
	}

	//个人信息修改
	@RequestMapping(value = "/showUser", method = {RequestMethod.GET})
	private String showUser(Model model,HttpServletRequest request) throws Exception {
		String id = String.valueOf(request.getSession().getAttribute("user"));
		User user = userService.findUserById(id);
		model.addAttribute("object", user);
		return "/ordinary/showUser";
	}

	//个人信息修改
	@RequestMapping(value = "/changeUser", method = {RequestMethod.POST})
	private String changeUser(String password, String username, Model model,HttpServletRequest request) throws Exception {
		String id = String.valueOf(request.getSession().getAttribute("user"));
		User user = userService.findUserById(id);
		user.setUsername(username);
		user.setPassword(password);
		userService.updateUser(user);
		model.addAttribute("object", user);
    public String loginUI() throws Exception {
        return "../../login";
    }

    //登录表单处理
    @RequestMapping(value = "/login", method = {RequestMethod.POST})
    public String login(Model model,User user, HttpServletRequest request) throws Exception {

        //Shiro实现登录
        UsernamePasswordToken token = new UsernamePasswordToken(user.getId(),user.getPassword());
        Subject subject = SecurityUtils.getSubject();

        //如果获取不到用户名就是登录失败,但登录失败的话,会直接抛出异常
        try {
			subject.login(token);
		} catch (Exception e) {
//			return "/login";
            model.addAttribute("message","用户名或密码错误");
            return "/error";
		}

        if (subject.hasRole("admin")) {
        	request.getSession().setAttribute("admin", user.getId());
        	request.getSession().setAttribute("usersession", userService.findUserById(user.getId()));
            return "redirect:/admin/showRoom";
        } else if (subject.hasRole("ordinary")) {
        	request.getSession().setAttribute("user", user.getId());
        	request.getSession().setAttribute("usersession", userService.findUserById(user.getId()));
            return "redirect:/ordinary/showRoom";
        }

        model.addAttribute("message","登录异常,请联系管理员");
        return "/error";
    }

    // 注册跳转
    @RequestMapping(value = "/register",method = {RequestMethod.GET})
    public String registerUI() throws Exception{
        return "/register";
    }

    //注册表单处理
    @RequestMapping(value = "/register", method = {RequestMethod.POST})
    public String register(Model model,User user, HttpServletRequest request) throws Exception {

	//预约教室功能实现
	@RequestMapping(value = "/reserveRoom", method = RequestMethod.POST)
	public String reserveRoom(ReservationCustom reservationCustom) throws Exception {

		reservationService.addReservation(reservationCustom);

		return "redirect:/ordinary/showRecord";
	}

	//取消预约申请页面跳转
	@RequestMapping(value = "/cancelApplication",method = RequestMethod.GET)
	public String cancelApplicationUI(String user,Model model) throws Exception{
		List<ReservationCustom> list=reservationService.findByUser(user);
		model.addAttribute("reserveList",list);

		return "/ordinary/cancelApplication";
	}

	//取消预约申请业务实现
	@RequestMapping("/cancelApply")
	public String cancelApplication(Integer id) throws Exception{
		reservationService.cancelApplication(id);

		return "redirect:/ordinary/showRecord";
	}

}


        //Shiro实现登录
        UsernamePasswordToken token = new UsernamePasswordToken(user.getId(),user.getPassword());
        Subject subject = SecurityUtils.getSubject();

        //如果获取不到用户名就是登录失败,但登录失败的话,会直接抛出异常
        try {
			subject.login(token);
		} catch (Exception e) {
//			return "/login";
            model.addAttribute("message","用户名或密码错误");
            return "/error";
		}

        if (subject.hasRole("admin")) {
        	request.getSession().setAttribute("admin", user.getId());
        	request.getSession().setAttribute("usersession", userService.findUserById(user.getId()));
            return "redirect:/admin/showRoom";
        } else if (subject.hasRole("ordinary")) {
        	request.getSession().setAttribute("user", user.getId());
        	request.getSession().setAttribute("usersession", userService.findUserById(user.getId()));
            return "redirect:/ordinary/showRoom";
        }

        model.addAttribute("message","登录异常,请联系管理员");
        return "/error";
    }

    // 注册跳转
    @RequestMapping(value = "/register",method = {RequestMethod.GET})
    public String registerUI() throws Exception{
        return "/register";
    }

    //注册表单处理
    @RequestMapping(value = "/register", method = {RequestMethod.POST})
    public String register(Model model,User user, HttpServletRequest request) throws Exception {

        // 获取用户输入的验证码
        String checkCode = request.getParameter("checkCode");

        // 比对验证码,若不对,则返回
        String checkCodeGen = request.getSession().getAttribute("checkCodeGen").toString();

请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述

  • 5
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值