Exemplo n.º 1
0
 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();
 }
Exemplo n.º 2
0
 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);
 }
Exemplo n.º 3
0
 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);
 }
Exemplo n.º 4
0
 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;
 }
Exemplo n.º 5
0
 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);
 }