Advertisement

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

阅读量:

一、项目运行

软件环境配置:Java JDK版本号1.8配合Tomcat8.5运行MySQL数据库,并基于Eclipse平台支持以下开发工具使用:IntelliJ IDEA、Eclipses、MyEclipses以及Sts等开发环境

项目技术:
JSP + Servlert + html+ css + JavaScript + JQuery + Ajax 等等;

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

适用

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

复制代码
        return "user/list";
    }
    }
    个人中心Controller:
    /** * 个人中心Controller
     */
    @Controller
    public class UserInforController {
    	
    @Autowired
    private UserInforServiceImpl userInforService = null;
    /** * 修改密码操作
    
    
      
      
      
      
      
      
      
      
      
      
      
      
      
      
    
    AI写代码
复制代码
        Employee employee = loginService.findEmployeeById(id);
        HashMap<String, String> map = new HashMap<String, String>();
        map.put("account",employee.geteAccount());
        map.put("name",employee.geteName());
        return map;
    }
    @RequestMapping(value = "/logout.do")
    public String logout(HttpSession httpSession){
        httpSession.removeAttribute("employeeId");
        return "redirect:/";
    }
    @RequestMapping(value = "/logoutAdmin.do")
    public String logoutAdmin(HttpSession httpSession){
       httpSession.removeAttribute("admin");
    
    
      
      
      
      
      
      
      
      
      
      
      
      
      
      
    
    AI写代码
复制代码
     * @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)){
            SystemManager admin = (SystemManager) httpSession.getAttribute("admin");
            String encodeByMD5 = MD5Utils.encodeByMD5(oldPassword);
            if (encodeByMD5.equals(admin.getSmPassword())){
    
    
      
      
      
      
      
      
      
      
      
      
      
      
      
      
    
    AI写代码
复制代码
    /** * 用户添加操作
     * @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();
        }
        int result = userService.create(user);
        if (result <= 0) {
            return MapControl.getInstance().error().getMap();
        }
    
    
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
    
    AI写代码
复制代码
        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;
            }
        }else{
            map.put("type","error");
            map.put("msg","两次密码不一致");
            return map;
        }
    }
    
    /**
    
    
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
    
    AI写代码
复制代码
    @RequestMapping(value = "/logout.do")
    public String logout(HttpSession httpSession){
        httpSession.removeAttribute("employeeId");
        return "redirect:/";
    }
    @RequestMapping(value = "/logoutAdmin.do")
    public String logoutAdmin(HttpSession httpSession){
       httpSession.removeAttribute("admin");
       return "redirect:/admin.do";
    }
    }
    用户管理操作: 
    /** * 用户管理操作
     */
    @Controller
    @RequestMapping("/user")
    public class UserController {
    @Autowired
    private UserService userService;
    /** * 用户添加页面
     * @return
     */
    @GetMapping("/add")
    public String create() {
    
    
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
    
    AI写代码
复制代码
     */
    @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(StringUtils.isEmpty(user.getUserPwd())){
            return MapControl.getInstance().error("请填写密码").getMap();
        }
        int result = userService.update(user);
        if (result <= 0) {
            return MapControl.getInstance().error().getMap();
        }
        return MapControl.getInstance().success().getMap();
    }
    /** * 根据id查询,跳转修改页面
     * @param id
     * @param modelMap
     * @return
     */
    @GetMapping("/edit/{id}")
    
    
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
    
    AI写代码
复制代码
    private UserService userService;
    /** * 用户添加页面
     * @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();
    
    
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
    
    AI写代码
复制代码
     * @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,
            @RequestParam(value="year", defaultValue="1") String year,
            HttpSession httpSession) throws Exception {
        Integer eId = (Integer) httpSession.getAttribute("employeeId");
        //pageNum:起始页面  pageSize:每页的大小
        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;
    
    
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
    
    AI写代码
复制代码
    @RequestMapping(value = "/getEmployeeAccount.do")
    @ResponseBody
    public Map<String,String> getEmployeeAccount(HttpSession httpSession){
        Integer id = (Integer) httpSession.getAttribute("employeeId");
        Employee employee = loginService.findEmployeeById(id);
        HashMap<String, String> map = new HashMap<String, String>();
        map.put("account",employee.geteAccount());
        map.put("name",employee.geteName());
        return map;
    }
    @RequestMapping(value = "/logout.do")
    public String logout(HttpSession httpSession){
        httpSession.removeAttribute("employeeId");
    
    
      
      
      
      
      
      
      
      
      
      
      
      
      
    
    AI写代码
复制代码
            return MapControl.getInstance().error().getMap();
        }
        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();
    }
    /** * 编辑用户信息操作
     * @param user
     * @return
    
    
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
    
    AI写代码

全部评论 (0)

还没有任何评论哟~