Search in sources :

Example 1 with TbAccount

use of com.netsteadfast.greenstep.po.hbm.TbAccount in project bamboobsc by billchen198318.

the class AccountServiceImpl method generateNewPassword.

@Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = { RuntimeException.class, IOException.class, Exception.class })
@Override
public String generateNewPassword(String account) throws ServiceException, Exception {
    if (StringUtils.isBlank(account)) {
        throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.PARAMS_BLANK));
    }
    TbAccount entity = new TbAccount();
    entity.setAccount(account);
    entity = this.findByEntityUK(entity);
    if (entity == null || StringUtils.isBlank(entity.getOid())) {
        throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.DATA_NO_EXIST));
    }
    String newPasswordStr = SimpleUtils.createRandomString(5);
    entity.setPassword(this.tranPassword(newPasswordStr));
    this.update(entity);
    return newPasswordStr;
}
Also used : ServiceException(com.netsteadfast.greenstep.base.exception.ServiceException) TbAccount(com.netsteadfast.greenstep.po.hbm.TbAccount) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

ServiceException (com.netsteadfast.greenstep.base.exception.ServiceException)1 TbAccount (com.netsteadfast.greenstep.po.hbm.TbAccount)1 Transactional (org.springframework.transaction.annotation.Transactional)1