基于javaweb+jsp的火车票预订系统(java+JDBC+JSP+Servlet+html+mysql)

基于javaweb+jsp的火车票预订系统(java+JDBC+JSP+Servlet+html+mysql)
一、项目运行

环境配置:
Jdk1.8 + Tomcat8.5 + mysql + Eclispe(IntelliJ IDEA,Eclispe,MyEclispe,Sts都支持)

项目技术:
JSP + Servlert + html+ css + JavaScript + JQuery + Ajax 等等;
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述

适用

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

     * @return
     */
    @RequestMapping("changePassword.do")
    @ResponseBody
    public Map<String, String> changePassword(String oldPassword, String newPassword,
                                              String rePassword, HttpSession httpSession){
        HashMap<String, String> map = new HashMap<String, String>();
        if (newPassword.equals(rePassword)){
            SystemManager admin = (SystemManager) httpSession.getAttribute("admin");
            String encodeByMD5 = MD5Utils.encodeByMD5(oldPassword);
            if (encodeByMD5.equals(admin.getSmPassword())){
                String newPasswords = MD5Utils.encodeByMD5(newPassword);
                admin.setSmPassword(newPasswords);
                userInforService.updateSystemManagePassword(admin.getSmId(),admin);
                map.put("type","success");
                map.put("msg","密码修改成功");
                return map;
            }else{
                map.put("type","error");
                map.put("msg","原密码错误");
                return map;
        //查找条件,一定要紧跟在startPage后
        List<Salary> salaryList = userInforService.getEmployeeSalaryList(eId, year);
        PageInfo pageResult = new PageInfo(salaryList);
        //设置前台需要的数据
        EmployeeSalaryVO employeeSalaryVO = new EmployeeSalaryVO();
        employeeSalaryVO.setCode(0);
        employeeSalaryVO.setMsg("");
        employeeSalaryVO.setCount((int) pageResult.getTotal());
        employeeSalaryVO.setData(pageResult.getList());
        return employeeSalaryVO;
     * @param httpSession
     * @param username
     * @param password
     * @param identifyingcode
     * @return
     */
    @RequestMapping(value = "/adminLogin.do")
    @ResponseBody
    public Message adminLogin(HttpSession httpSession, String username,
                                            String password, String identifyingcode)
    {
        
    	if(StringUtils.isEmpty(username)) {
    		return Message.error("请填写账号");
    	}
    @PostMapping("/query")
    @ResponseBody
    public Map<String, Object> query(@RequestBody User user) {
        List<User> list = userService.query(user);
        Integer count = userService.count(user);
        return MapControl.getInstance().success().page(list, count).getMap();
    }
    //跳转列表页面
    @GetMapping("/list")
    public String list() {
        return "user/list";
    }
}
个人中心Controller/**
 * 个人中心Controller
 */
@Controller
public class UserInforController {
	
    @Autowired
        modelMap.addAttribute("user", user);
        return "user/edit";
    }
    //查询所有
    @PostMapping("/query")
    @ResponseBody
    public Map<String, Object> query(@RequestBody User user) {
        List<User> list = userService.query(user);
        Integer count = userService.count(user);
        return MapControl.getInstance().success().page(list, count).getMap();
    }
    //跳转列表页面
    @GetMapping("/list")
    public String list() {
    public Map<String, Object> delete(String ids) {
        int result = userService.delete(ids);
        if (result <= 0) {
            return MapControl.getInstance().error().getMap();
        }
        return MapControl.getInstance().success().getMap();
    }
    /**
     * 编辑用户信息操作
     * @param user
     * @return
     */
    @PostMapping("/edit")
    @ResponseBody
    public Map<String, Object> edit(@RequestBody User user) {
        if(StringUtils.isEmpty(user.getUserName())){
            return MapControl.getInstance().error("请填写用户名").getMap();
        }
        if(StringUtils.isEmpty(user.getName())){
            return MapControl.getInstance().error("请填写名称").getMap();
        }
        if(userInforService.updateEmploueeById(id,employee)<=0) {
        	return Message.error("修改信息失败");
        }
       return Message.success();
    }
    /**
     * 个人工资信息
     * @param pageNum
     * @param limit
     * @param year
     * @param httpSession
     * @return
     * @throws Exception
     */
    @RequestMapping("employeeSalaryList.do")
    @ResponseBody
    public EmployeeSalaryVO findSelective(
            @RequestParam(value="page", defaultValue="1")int pageNum,
            @RequestParam(value="limit", defaultValue="10") int limit,
    @PostMapping("/delete")
    @ResponseBody
    public Map<String, Object> delete(String ids) {
        int result = userService.delete(ids);
        if (result <= 0) {
            return MapControl.getInstance().error().getMap();
        }
        return MapControl.getInstance().success().getMap();
    }
    /**
     * 编辑用户信息操作
     * @param user
                map.put("msg","原密码错误");
                return map;
            }
        }else{
            map.put("type","error");
            map.put("msg","两次密码不一致");
            return map;
        }
    }
    
    /**
     * 员工修改个人密码
     * @param oldPassword
     * @param newPassword
     * @param rePassword
     * @param httpSession
     * @return
     */
    @RequestMapping("changeEmployeePassword.do")
    @ResponseBody
}
个人中心Controller/**
 * 个人中心Controller
 */
@Controller
public class UserInforController {
	
    @Autowired
    private UserInforServiceImpl userInforService = null;
    /**
     * 修改密码操作
     * @param oldPassword
     * @param newPassword
     * @param rePassword
     * @param httpSession
     * @return
     */
    @RequestMapping("changePassword.do")
    @ResponseBody
    public Map<String, String> changePassword(String oldPassword, String newPassword,
                                              String rePassword, HttpSession httpSession){
        HashMap<String, String> map = new HashMap<String, String>();
        if (newPassword.equals(rePassword)){
    @PostMapping("/delete/{id}")
    @ResponseBody
    public Map<String, Object> delete(@PathVariable("id") Integer id) {
        int result = userService.delete(id);
        if (result <= 0) {
            return MapControl.getInstance().error().getMap();
        }
        return MapControl.getInstance().success().getMap();
    }
    //批量删除
    @PostMapping("/delete")
    @ResponseBody
    public Map<String, Object> delete(String ids) {
        PageHelper.startPage(pageNum,limit);
        //查找条件,一定要紧跟在startPage后
        List<Salary> salaryList = userInforService.getEmployeeSalaryList(eId, year);
        PageInfo pageResult = new PageInfo(salaryList);
        //设置前台需要的数据
        EmployeeSalaryVO employeeSalaryVO = new EmployeeSalaryVO();
        employeeSalaryVO.setCode(0);
        employeeSalaryVO.setMsg("");
        employeeSalaryVO.setCount((int) pageResult.getTotal());
        employeeSalaryVO.setData(pageResult.getList());
        return employeeSalaryVO;
    }
}
管理员和员工登陆控制:
/**
 * @Author: admin
 * @Description: 管理员和员工登陆控制
 **/
@Controller
        return MapControl.getInstance().success().getMap();
    }
    //批量删除
    @PostMapping("/delete")
    @ResponseBody
    public Map<String, Object> delete(String ids) {
        int result = userService.delete(ids);
        if (result <= 0) {
            return MapControl.getInstance().error().getMap();
        }
        return MapControl.getInstance().success().getMap();
}
用户管理操作: 
/**
 * 用户管理操作
 */
@Controller
@RequestMapping("/user")
public class UserController {
    @Autowired
    private UserService userService;
    /**
     * 用户添加页面
     * @return
     */
    @GetMapping("/add")
    public String create() {
        return "user/add";
    }
    /**
     * 用户添加操作
     * @param user
     * @return
    	String realPath = request.getServletContext().getRealPath("/");
    	request.getSession().setAttribute("realPath", realPath);
        return "admin/adminLogin.html";
    }
    
    
    /**
     * 员工登录操作
     * @param model
     * @param httpSession
     * @param username
     * @param password
     * @param identifyingcode
     * @return
     */
    @RequestMapping(value = "/employeeLogin.do")
    @ResponseBody
    public Message employeeLogin(HttpSession httpSession, String username,
            }
        }else{
            map.put("type","error");
            map.put("msg","两次密码不一致");
            return map;
        }
    }
    /**
     * 查看个人信息
     * @param httpSession
     * @return
     */
    @RequestMapping("inforEmployee.do")
    public @ResponseBody EmployeeCustomVo getInforEmployee(HttpSession httpSession){
        Integer id = (Integer) httpSession.getAttribute("employeeId");
        EmployeeCustomVo employeeCustomVo = userInforService.getInforEmployee(id);
        return employeeCustomVo;
    @RequestMapping("/")
    public String getLoginPage(){
        return "employee/login.html";
    }
    // 获取管理员登陆界面
    @RequestMapping("/admin.do")
    public String getAdminLoginPage(HttpServletRequest request){
    	String realPath = request.getServletContext().getRealPath("/");
    	request.getSession().setAttribute("realPath", realPath);
        return "admin/adminLogin.html";
    }
    
    
    /**
     * 员工登录操作
     * @param model
     * @param httpSession
     * @param username
     * @param password
     * @param identifyingcode
     * @return
     */
    @RequestMapping(value = "/employeeLogin.do")
    @ResponseBody
     * @return
     */
    @GetMapping("/add")
    public String create() {
        return "user/add";
    }
    /**
     * 用户添加操作
     * @param user
     * @return
     */
    @PostMapping("/add")
    @ResponseBody
    public Map<String, Object> add(@RequestBody User user) {
        if(StringUtils.isEmpty(user.getUserName())){
            return MapControl.getInstance().error("请填写用户名").getMap();
        }
        if(StringUtils.isEmpty(user.getName())){
            return MapControl.getInstance().error("请填写名称").getMap();
        }
        if(StringUtils.isEmpty(user.getUserPwd())){
            return MapControl.getInstance().error("请填写密码").getMap();
        }
    @RequestMapping(value = "/changeCode.do")
    @ResponseBody
    public void getIdentifyingCode(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException
    {
        // 验证码存储在session的identifyingCode,属性中
        CaptchaUtil.outputCaptcha(request, response);
    }
    // 获取员工登陆界面
    @RequestMapping("/")
    public String getLoginPage(){
        return "employee/login.html";
    }
    // 获取管理员登陆界面
    @RequestMapping("/admin.do")
    public String getAdminLoginPage(HttpServletRequest request){
    	String realPath = request.getServletContext().getRealPath("/");
    	request.getSession().setAttribute("realPath", realPath);
管理员和员工登陆控制:
/**
 * @Author: admin
 * @Description: 管理员和员工登陆控制
 **/
@Controller
public class LoginController {
    @Autowired
    private LoginServiceImpl loginService = null;
    /**
     * @Author: admin
     * @Description: 验证码变更
     * @Date: 14:33 2021/10/5
     * @Param: [request, response]
     * @Return: void
     **/
    @RequestMapping(value = "/changeCode.do")
    @ResponseBody
        }
    }
    
    /**
     * 员工修改个人密码
     * @param oldPassword
     * @param newPassword
     * @param rePassword
     * @param httpSession
     * @return
     * @param username
     * @param password
     * @param identifyingcode
     * @return
     */
    @RequestMapping(value = "/adminLogin.do")
    @ResponseBody
    public Message adminLogin(HttpSession httpSession, String username,
                                            String password, String identifyingcode)
    {
        
    	if(StringUtils.isEmpty(username)) {
    		return Message.error("请填写账号");
    	}
    	if(StringUtils.isEmpty(password)) {
    		return Message.error("请填写密码");
    	}
    	if(StringUtils.isEmpty(identifyingcode)) {
    		return Message.error("请填写验证码");
        PageInfo pageResult = new PageInfo(salaryList);
        //设置前台需要的数据
        EmployeeSalaryVO employeeSalaryVO = new EmployeeSalaryVO();
        employeeSalaryVO.setCode(0);
        employeeSalaryVO.setMsg("");
        employeeSalaryVO.setCount((int) pageResult.getTotal());
        employeeSalaryVO.setData(pageResult.getList());
        return employeeSalaryVO;
    }
}
管理员和员工登陆控制:
/**
 * @Author: admin
 * @Description: 管理员和员工登陆控制
 **/
@Controller
public class LoginController {
    @Autowired
    private LoginServiceImpl loginService = null;
    /**
     * @Author: admin
     * @Description: 验证码变更
     * @Date: 14:33 2021/10/5
     * @return
     */
    @ResponseBody
    @RequestMapping("updateInforEmployee.do")
    public Message updateInforEmployee(HttpSession httpSession, Employee employee){
        Integer id = (Integer) httpSession.getAttribute("employeeId");
        employee.seteId(id);
        if(userInforService.updateEmploueeById(id,employee)<=0) {
        	return Message.error("修改信息失败");
        }
       return Message.success();
    }
    /**
     * 个人工资信息
     * @param pageNum
     * @param limit
     * @param year
     * @param httpSession
    @ResponseBody
    public void getIdentifyingCode(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException
    {
        // 验证码存储在session的identifyingCode,属性中
        CaptchaUtil.outputCaptcha(request, response);
    }
    // 获取员工登陆界面
    @RequestMapping("/")
    public String getLoginPage(){
        int result = userService.create(user);
        if (result <= 0) {
            return MapControl.getInstance().error().getMap();
        }
        return MapControl.getInstance().success().getMap();
    }
    /**
     * 根据id删除
     * @param id
     * @return
     */
    @PostMapping("/delete/{id}")
    @ResponseBody
    public Map<String, Object> delete(@PathVariable("id") Integer id) {
        int result = userService.delete(id);
        if (result <= 0) {
            return MapControl.getInstance().error().getMap();

适用

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

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值