@RequestMapping(
      value = "/search/{name}/{value}.jsn",
      method = {RequestMethod.POST, RequestMethod.GET})
  @ResponseBody
  public Object search(
      @RequestParam(value = "page", required = true, defaultValue = "1") int page,
      @RequestParam(value = "rows", required = true, defaultValue = "30") int rows,
      @PathVariable String name,
      @PathVariable String value) {

    if (value == null || value.trim().isEmpty()) {
      return null;
    }

    if ("userName".equals(name)) {
      PageBean<User> pageBean = userService.getUserByName(value);
      if (pageBean.getTotal() == 0) {
        Map<String, Integer> map = new HashMap<String, Integer>();
        map.put("rows", 0);
        map.put("total", 0);
        map.put("page", 1);
        return map;
      } else {
        return pageBean;
      }
    }

    return "[]";
  }
  @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 = "/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 = "/edit.html")
  public ModelAndView goEdit(@RequestParam(value = "userId", required = false) String userId) {

    Map<String, Object> map = new HashMap<String, Object>();
    map.put("timp", System.currentTimeMillis());

    if (userId != null && !userId.trim().isEmpty()) {
      User user = userService.getUserById(Long.parseLong(userId));
      map.put("user", user);
    }

    return new ModelAndView("vrs/user/edit.html", map);
  }
 @RequestMapping(
     value = "/addUserRepeatValid",
     method = {RequestMethod.POST, RequestMethod.GET})
 @ResponseBody
 public Object addUserRepeatValid(
     @RequestParam(value = "userName", required = true) String userName) {
   if (userName == null || "".equals(userName)) {
     return false;
   }
   User user = userService.getReUserByName(userName);
   if (user != null) {
     return false;
   }
   return true;
 }
 @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 = "/userlist.jsn",
      method = {RequestMethod.POST, RequestMethod.GET})
  @ResponseBody
  public Object getUserList(
      HttpServletRequest request,
      HttpServletResponse response,
      @RequestParam(value = "page", required = true, defaultValue = "1") int page,
      @RequestParam(value = "rows", required = true, defaultValue = "30") int rows) {

    PageBean<User> pageBean = userService.getUsersList(page, rows);
    if (pageBean.getTotal() == 0) {
      Map<String, Integer> map = new HashMap<String, Integer>();
      map.put("rows", 0);
      map.put("total", 0);
      map.put("page", 1);
      return map;
    } else {
      return pageBean;
    }
  }