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);
 }
 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);
 }