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

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

一、项目运行

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

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





适用

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

        return "user/list";
    }
}
个人中心Controller/**
 * 个人中心Controller
 */
@Controller
public class UserInforController {
	
    @Autowired
    private UserInforServiceImpl userInforService = null;
    /**
     * 修改密码 *** 作
        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");
     * @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())){
    /**
     * 用户添加 *** 作
     * @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();
        }
        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;
        }
    }
    
    /**
    @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() {
     */
    @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}")
    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();
     * @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;
    @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");
            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

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1320165.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-06-11
下一篇 2022-06-11

发表评论

登录后才能评论

评论列表(0条)

保存