public String getTeamName(long id) {
   User user = get(id);
   if ((user == null) || (user.getTeamId() == null)) {
     return null;
   }
   Team team = this.teamService.get(user.getTeamId());
   return team == null ? null : team.getName();
 }
 public void add(User user) {
   if (nameExists(user.getName())) {
     throw new IllegalArgumentException(String.format("User %s 已经存在", user.getName()));
   }
   Date time = new Date();
   user.setCreateTime(time);
   user.setUpdateTime(time);
   this.userDao.insertSelective(user);
 }
 public void regenToken(long userId) {
   User user = this.userDao.selectByPrimaryKey(userId);
   if (user == null) {
     throw new IllegalArgumentException(String.format("UserId(%s) 不存在存在", userId));
   }
   User record = new User();
   record.setId(userId);
   record.setToken(UUID.randomUUID().toString());
   record.setUpdateTime(new Date());
   this.userDao.updateByPrimaryKeySelective(record);
 }
 public List<NameValuePair> list() {
   UserExample example = new UserExample();
   List<User> users = this.userDao.selectByExample(example);
   List<NameValuePair> result = new ArrayList<NameValuePair>();
   for (User user : users) {
     NameValuePair pair = new NameValuePair();
     pair.setValue(user.getId());
     pair.setName(user.getName());
     result.add(pair);
   }
   return result;
 }
 public void resetPassword(long userId) {
   User user = this.userDao.selectByPrimaryKey(userId);
   User record = new User();
   record.setId(userId);
   record.setUpdateTime(new Date());
   record.setPassword(PasswordEncoder.encode(user.getName()));
   this.userDao.updateByPrimaryKeySelective(record);
 }