@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); }
@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); }