コード例 #1
0
ファイル: UserServiceImpl.java プロジェクト: ltyuanmu/money
 @Override
 public void modifyUserPassword(InUser inUser) throws BusinessException {
   // 密码校验
   String username = inUser.getUsername();
   String password = inUser.getPassword();
   String oldPassword = inUser.getOldPassword();
   oldPassword = LtStringUtil.encoderByMd5(oldPassword);
   User user = this.getUserByUserName(username);
   if (user == null) {
     throw new BusinessException(UserCode.USERERROR);
   }
   if (!user.getPassword().equals(oldPassword)) {
     throw new BusinessException(UserCode.USERERROR);
   }
   password = LtStringUtil.encoderByMd5(password);
   user.setPassword(password);
   this.userDaoService.updateByPrimaryKeySelective(user);
 }
コード例 #2
0
ファイル: UserServiceImpl.java プロジェクト: ltyuanmu/money
 @Override
 public String getToken(InUser inUser) throws BusinessException {
   // 密码校验
   String username = inUser.getUsername();
   String password = inUser.getPassword();
   password = LtStringUtil.encoderByMd5(password);
   User user = this.getUserByUserName(username);
   if (user == null) {
     throw new BusinessException(UserCode.USERERROR);
   }
   if (!user.getPassword().equals(password)) {
     throw new BusinessException(UserCode.USERERROR);
   }
   // 生成token
   String token = UserToken.getToken(username, user.getId());
   return token;
 }
コード例 #3
0
ファイル: UserServiceImpl.java プロジェクト: ltyuanmu/money
 @Override
 public String createUser(InUser inUser) throws BusinessException {
   String username = inUser.getUsername();
   String password = inUser.getPassword();
   User user = this.getUserByUserName(username);
   if (user != null) {
     throw new BusinessException(UserCode.USERERROR);
   }
   password = LtStringUtil.encoderByMd5(password);
   user = new User();
   user.setId(KeyGenerator.getUuid());
   user.setPassword(password);
   user.setUsername(username);
   user.setCreateTime(new Date());
   this.userDaoService.insert(user);
   String token = UserToken.getToken(username, user.getId());
   return token;
 }