@RequestMapping(
      value = "/register.action",
      method = RequestMethod.POST,
      produces = "text/plain;charset=UTF-8")
  @ResponseBody
  public String register(
      @RequestParam(value = "userName") String userName,
      @RequestParam(value = "passWord") String passWord,
      @RequestParam(value = "deptId") String deptId,
      HttpSession session) {
    try {
      DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss EE");
      log.info("收到注册请求[" + df.format(new Date()) + "],USERNAME=[" + userName + "]");

      // 根据用户名获取数据库中保存的信息
      UserInfo userInfo = userInfoService.getUserInfo(userName);
      if (userInfo != null) {
        return "REGISTER_ERROR:此用户已注册";
      } else {
        userInfo = new UserInfo();
        userInfo.setUserName(userName);
        userInfo.setPassWord(passWord);
        userInfo.setOrgId(deptId);
        if (userInfoService.addUser(userInfo) == 1) {
          // session.removeAttribute("LOGIN_USER");
          // session.setAttribute("LOGIN_USER", userInfo.getUserName());
          return "REGISTER_SUCC:恭喜您," + userName + " 注册成功!";
        } else {
          return "REGISTER_ERROR:注册用户失败";
        }
      }
    } catch (Exception e) {
      e.printStackTrace();
      log.error(e);
      return "REGISTER_ERROR:系统异常";
    }
  }
  @RequestMapping(
      value = "/login.action",
      method = RequestMethod.POST,
      produces = "text/plain;charset=UTF-8")
  @ResponseBody
  public String login(
      @RequestParam(value = "userName") String userName,
      @RequestParam(value = "passWord") String passWord,
      @RequestParam(value = "validateCode") String validateCode,
      HttpSession session) {
    try {
      DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss EE");
      log.info("收到登录验证请求[" + df.format(new Date()) + "],USERNAME=[" + userName + "]");
      session.removeAttribute("LOGIN_USER");

      String validateC = (String) session.getAttribute("validateCode");
      log.info("validateC:[" + validateC + "];validateCode:[" + validateCode + "]");
      if (!validateC.equalsIgnoreCase(validateCode)) {
        return "LOGIN_ERROR:校验码不正确";
      }

      // 根据用户名获取数据库中保存的信息
      UserInfo userInfo = userInfoService.getUserInfo(userName);
      if (userInfo == null) {
        return "LOGIN_ERROR:用户名不正确";
      } else {
        if (passWord.equals(userInfo.getPassWord())) {
          session.setAttribute("LOGIN_USER", userInfo.getUserName() + ";" + userInfo.getOrgName());
          String loginTime = df.format(new Date());
          log.info("USERNAME:[" + userInfo.getUserName() + "]登录成功时间:[" + loginTime + "]");
          session.removeAttribute("validateCode");
          return "LOGIN_SUCC:" + userName + ";" + userInfo.getOrgName();
        } else {
          return "LOGIN_ERROR:密码不正确";
        }
      }
    } catch (Exception e) {
      e.printStackTrace();
      log.error(e);
      session.removeAttribute("LOGIN_USER");
      return "LOGIN_ERROR:系统异常";
    }
  }