Пример #1
0
 @Override
 public User getUserByUserName(String userName) throws Exception {
   User user = this.userDao.getUserByUserName(userName);
   if (user != null) {
     Department department = this.departmentDao.getDepartmentById(user.getDepartmentId());
     if (department != null) {
       user.setDeptName(department.getName());
     }
   }
   return user;
 }
Пример #2
0
 /**
  * @param User
  * @return @Description:检测用户名的唯一性
  */
 @ResponseBody
 @RequestMapping("/checkUserNameExsits")
 public String checkUserNameExsits(User User) {
   try {
     User param = new User();
     param.setUsername(User.getUsername());
     List<User> list = this.userService.getAll(param);
     if (StringUtils.isNotBlank(User.getId())) {
       User u = this.userService.getUserById(User.getId());
       if (u != null && u.getUsername().equals(User.getUsername())) {
         return "0";
       } else {
         if (list != null && list.size() > 0) {
           return "1";
         }
       }
     } else {
       if (list != null && list.size() > 0) {
         return "1";
       }
     }
   } catch (Exception e) {
     e.printStackTrace();
     logger.debug("UserController-checkUserNameExsits:" + e.getMessage());
   }
   return "0";
 }
Пример #3
0
  // 对外提供的登录接口 这个方法暂时不用
  public LoginVo login(
      String username, String password, String companyId, String ip, String systemSn)
      throws Exception {
    LoginVo vo = new LoginVo();
    SessionMap sessionMap = new SessionMap();
    // 1:查询到用户对象
    User user = login(username, password);
    if (user != null) {
      vo.setLoginUser(user);
      vo.setSid(user.getId());
      sessionMap.put(PrivilegeConstant.LOGIN_USER, JsonUtils.toJson(user));
      Set<ACL> acls = (Set<ACL>) aclService.getAclsByUserId(user.getId());
      sessionMap.put(PrivilegeConstant.LOGIN_USER_ACLS, JsonUtils.toJson(acls));
      ICSystem icSystem = icSystemDao.getICSystemBySn(systemSn);
      if (icSystem != null) {
        List<Module> modules = moduleService.getTreeModuleBySystemIdAndAcls(acls, icSystem.getId());
        vo.setModules(modules);
      } else {
        throw new PrivilegeException("系统标示找不到");
      }
      // 插入登录日志
      LoginLog loginLog =
          new LoginLog(ip, user.getId(), user.getUsername(), user.getRealName(), "登录");
      loginLogService.insertLoginLog(loginLog);

      CacheEntity ce =
          new CacheEntity(user.getId(), sessionMap, PrivilegeConstant.SESSION_OUT_TIME);
      CacheListHandler.addCache(user.getId(), ce);
      // redisClientTemplate.setex(user.getId(),
      // PrivilegeConstant.SESSION_OUT_TIME,
      // JsonUtils.toJson(sessionMap));
    }
    return vo;
  }
Пример #4
0
 @Override
 public void updateUser(User user) throws Exception {
   userDao.updateUser(user);
   this.userSystemDao.delByUserId(user.getId());
   String systemIds = user.getSystemIds();
   if (StringUtils.isNotBlank(systemIds)) {
     String[] syses = systemIds.split(",");
     for (String sys : syses) {
       UserSystem userSystem = new UserSystem();
       userSystem.setSystemId(sys);
       userSystem.setId(UUIDGenerator.generate());
       userSystem.setUserId(user.getId());
       this.userSystemDao.insertUserSystem(userSystem);
     }
   }
 }
Пример #5
0
 /**
  * @param request
  * @return @Description:修改密码
  */
 @ResponseBody
 @RequestMapping("/updatePassowrd")
 public String updatePassowrd(User user) {
   SimpleReturnVo vo;
   String password =
       MD5Util.getMD5String(PrivilegeConstant.USER_PASSWORD_FRONT + user.getPassword());
   try {
     user.setPassword(password);
     this.userService.singleUpdateUser(user);
     vo = new SimpleReturnVo(this.SUCCESS, "成功");
   } catch (Exception e) {
     e.printStackTrace();
     logger.debug("UserController-updatePassowrd:" + e.getMessage());
     vo = new SimpleReturnVo(this.FAIL, "异常错误!");
   }
   return JsonUtils.toJson(vo);
 }
Пример #6
0
 @Override
 public PagerModel<User> getPagerModel(User user, Query query) throws Exception {
   PagerModel<User> pm = userDao.getPagerModel(user, query);
   for (User ur : pm.getDatas()) {
     List<Role> list = this.userRoleDao.getRolesByUserId(ur.getId());
     if (list != null && list.size() > 0) {
       StringBuffer s = new StringBuffer();
       for (int i = 0, len = list.size(); i < len; i++) {
         if (i != 0) {
           s.append(",");
         }
         s.append(list.get(i).getName());
       }
       ur.setRoles(s.toString());
     }
   }
   return pm;
 }
Пример #7
0
 /**
  * @param user
  * @param query
  * @return @Description:用户分页数据
  */
 @ResponseBody
 @RequestMapping("ajaxlist")
 @Permission(systemSn = "privilege", moduleSn = "user", value = PermissionConatant.R)
 public String ajaxlist(User user, Query query) {
   PagerModel<User> Users = null;
   try {
     if ("0".equals(user.getDepartmentId())) {
       user.setDepartmentId(null);
     } else {
       String deptIds = departmentService.getChildrenIdsByPid(user.getDepartmentId());
       user.setDepartmentId(deptIds);
     }
     Users = this.userService.getPagerModel(user, query);
   } catch (Exception e) {
     e.printStackTrace();
     logger.debug("UserController-ajaxlist:" + e.getMessage());
   }
   return JsonUtils.getPmJson(Users);
 }
Пример #8
0
  /**
   * @param oldpwd
   * @param newpwd
   * @param request
   * @return @Description:重置密码
   */
  @ResponseBody
  @RequestMapping("/rePassword")
  public String rePassword(String oldpwd, String newpwd, HttpServletRequest request) {
    SimpleReturnVo vo;
    User user = WebUtils.getLoginUser(request);
    String password = MD5Util.getMD5String(PrivilegeConstant.USER_PASSWORD_FRONT + oldpwd);
    if (!password.equals(user.getPassword())) {
      vo = new SimpleReturnVo(this.FAIL, "原密码不正确!");
      return JsonUtils.toJson(vo);
    }
    try {
      User newUser = new User();
      newUser.setId(user.getId());
      password = MD5Util.getMD5String(PrivilegeConstant.USER_PASSWORD_FRONT + newpwd);
      newUser.setPassword(password);
      this.userService.singleUpdateUser(newUser);
      vo = new SimpleReturnVo(this.SUCCESS, "成功");
    } catch (Exception e) {
      e.printStackTrace();
      logger.debug("UserController-rePassword:"******"异常错误!");
    }

    return JsonUtils.toJson(vo);
  }
Пример #9
0
 @Override
 public User getUserById(String id) throws Exception {
   UserSystem userSystem = new UserSystem();
   userSystem.setUserId(id);
   List<UserSystem> list = this.userSystemDao.getAll(userSystem);
   StringBuffer systemIds = new StringBuffer("");
   if (list != null && list.size() > 0) {
     for (int i = 0, len = list.size(); i < len; i++) {
       if (i != 0) {
         systemIds.append(",");
       }
       systemIds.append(list.get(i).getSystemId());
     }
   }
   User user = userDao.getUserById(id);
   if (user != null && systemIds.length() > 0) {
     user.setSystemIds(systemIds.toString());
     Department department = this.departmentDao.getDepartmentById(user.getDepartmentId());
     if (department != null) {
       user.setDeptName(department.getName());
     }
   }
   return user;
 }