@RequestMapping( value = "/deluser.jsn", method = {RequestMethod.POST, RequestMethod.GET}) @ResponseBody public Object delUser( HttpServletRequest request, @RequestParam(value = "userId", required = true) String userId) { HttpSession session = request.getSession(true); User user = (User) session.getAttribute("currestUser"); LogWirterUtil.saveLogsToFile(user.getFullName() + "于" + new Date() + "执行删除用户操作用户id" + userId); return userService.moveUserById(Long.parseLong(userId)); }
@RequestMapping( value = "/modifypwd.jsn", method = {RequestMethod.POST, RequestMethod.GET}) @ResponseBody public Object modifyPwd( @RequestParam(value = "newpasswd", required = true) String newpasswd, HttpServletRequest request, HttpServletResponse response) { if (newpasswd == null || "".equals(newpasswd)) { return 0; } HttpSession session = request.getSession(true); User user = (User) session.getAttribute("currestUser"); if (user != null) { return userService.modifyUserPassWd(user.getUserId(), newpasswd); } else { return 0; } }
@RequestMapping( value = "/updateUser.jsn", method = {RequestMethod.POST, RequestMethod.GET}) @ResponseBody public Object updateUser(HttpServletRequest request, @ModelAttribute User user) { if (user.getFullName() == null || "".equals(user.getFullName())) { logger.error("用户名为空"); return 0; } if (user.getEmail() == null || "".equals(user.getEmail())) { logger.error("email为空"); return 0; } HttpSession session = request.getSession(true); User currestUser = (User) session.getAttribute("currestUser"); LogWirterUtil.saveLogsToFile( currestUser.getFullName() + "于" + new Date() + "执行修改用户操作用户id" + user.getUserId()); return userService.modifyUser(user); }
@RequestMapping( value = "/addUser.jsn", method = {RequestMethod.POST, RequestMethod.GET}) @ResponseBody public Object addUser( HttpServletRequest request, HttpServletResponse response, @ModelAttribute User user) { if (user.getUserName() == null || "".equals(user.getUserName())) { logger.error("登录名称为空"); return null; } if (user.getFullName() == null || "".equals(user.getFullName())) { logger.error("姓名为空"); return null; } if (user.getEmail() == null || "".equals(user.getEmail())) { logger.error("邮箱为空"); return null; } if (user.getPassWd() == null || "".equals(user.getPassWd())) { logger.error("密码为空"); return null; } HttpSession session = request.getSession(true); User currestUser = (User) session.getAttribute("currestUser"); if (currestUser != null) { user.setCreator(currestUser.getFullName()); } return userService.addUser(user); }