// 修改密码 @RequestMapping("/submitretpwd") public String submitretpwd(String newpsd1) { Users user = usersService.selectByPrimaryKey(this.id); user.setLogpwd(newpsd1); user.setFirstornot("0"); usersService.updateByPrimaryKey(user); return "ok"; }
@RequestMapping("/deleteUser") public String deleteUser(ModelMap modelmap, String userid) { Users user = userService.selectByPrimaryKey(userid); int resault = 0; if (!user.getUserid().equals("") && userid.equals(user.getUserid())) { resault = userService.deleteByPrimaryKey(userid); } if (resault > 0) return "forward:/listUser"; else return "error/404"; }
@RequestMapping("/listUser") public String listUser(ModelMap modelmap, String page, Users user) { String username = user.getUsername(); String usertype = user.getUsertype(); String userstate = user.getUserstate(); StringBuffer url = new StringBuffer(); // 把action跳转的地址存在url中 url.append(request.getContextPath() + "/listUser?method=listUser"); int current = 1; if (page != null && !page.trim().equals("")) { current = Integer.parseInt(page); } try { int first = 0; int pageSize = Integer.parseInt(String.valueOf(PageBean.pagecount)); if (current != 0) { first = (current - 1) * pageSize; } int startNum = first; Map<String, Object> params = new HashMap<String, Object>(); params.put("sortName", "userid"); params.put("pageSize", pageSize); params.put("startNum", startNum); if (username != null && !"".equals(username)) { params.put("username", "%" + username + "%"); url.append("&username="******"".equals(usertype)) { params.put("usertype", "%" + usertype + "%"); url.append("&usertype=" + usertype); } if (userstate != null && !"".equals(userstate)) { params.put("userstate", "%" + userstate + "%"); url.append("&userstate=" + userstate); } int num = userService.findByParamsCount(params); List<Users> listRoles = userService.findByParams(params); PageBean PageBean = new PageBean(current, pageSize, num, listRoles); PageBean.setUrl(url.toString()); modelmap.put("pageBean", PageBean); modelmap.put("PageList", PageBean.getList()); return "WebRoot/users/listUser"; } catch (Exception e) { e.printStackTrace(); return "error/404"; } }
@RequestMapping("/saveUser") public String saveUser(Users users) { users.setUserid(Identities.uuid2()); users.setWorkstate("1"); System.out.println(users.toString()); usersService.insert(users); return "WebRoot/users/addUser"; }
@RequestMapping("/editUser") public String editUser(ModelMap modelmap, String userid) { Users user = userService.selectByPrimaryKey(userid); modelmap.put("users", user); return "WebRoot/users/editUser"; }
@RequestMapping("/listUserDetail") public String listUserDetail(ModelMap modelmap, String userid) { Users user = userService.selectByPrimaryKey(userid); modelmap.put("userlogin", user); return "WebRoot/users/listUserDetail"; }
@RequestMapping(value = "/login", method = RequestMethod.POST) public String login(ModelMap modelmap, Users users, String validate) { request.getSession().setAttribute("user", users); request.getSession().setAttribute("username", users.getLogname()); String logname = users.getLogname(); modelmap.put("users", users); if (users.getLogname() == null || users.getLogname() == "") { modelmap.put("sysMessge", "请登陆!"); return "WebRoot/login"; } /*//太复杂先注释 if (!this.code.equalsIgnoreCase(validate)) { modelmap.put("sysMessge", "验证码错误!"); return "WebRoot/login"; }*/ // 验证是用户名是否正确 List<Users> usersList = usersService.selectByLogname(logname); if (usersList == null || usersList.size() == 0) { modelmap.put("sysMessge", "用户名不存在,请重新输入!"); return "WebRoot/login"; } Users user = usersList.get(0); String userid = user.getUserid(); request.getSession().setAttribute("user", user); request.getSession().setAttribute("username", user.getLogname()); if (!users.getLogpwd().equals(user.getLogpwd())) { modelmap.put("sysMessge", "密码错误,请重新输入!"); return "WebRoot/login"; } if (user.getUserstate().contains("0")) { modelmap.put("sysMessge", "此用户已被禁用!"); return "WebRoot/login"; } // 判断是否首次登陆 if (user.getFirstornot().contains("0")) { this.password = user.getLogpwd(); this.id = user.getUserid(); return "WebRoot/firstlogin"; // 提示用户修改密码,跳转到修改密码的页面 } // 获取一级权限 List<UserRole> crs = userroleservice.selectByUserId(userid); String roleid = ""; if (crs != null && crs.size() > 0) { roleid = crs.get(0).getRoleid(); } Roles role = rolesService.selectByPrimaryKey(roleid); List<Popedem> popedemList = popedemService.selectByRoleId(roleid); ArrayList<Popedem> splist1 = new ArrayList<Popedem>(); ArrayList<Popedem> splist2 = new ArrayList<Popedem>(); ArrayList<Popedem> splist3 = new ArrayList<Popedem>(); if (popedemList != null && popedemList.size() > 0) { for (int i = 0; i < popedemList.size(); i++) { Popedem popedem = popedemList.get(i); String grade = popedem.getGrade().toString(); if ("1".equals(grade)) { splist1.add(popedem); } else if ("2".equals(grade)) { splist2.add(popedem); } else if ("3".equals(grade)) { splist3.add(popedem); } } } modelmap.put("role", role); modelmap.put("splist1", splist1); modelmap.put("splist2", splist2); modelmap.put("splist3", splist3); this.modelmap = modelmap; return "forward:home"; }