示例#1
0
 private void validateAccountNonExistence(Account account) {
   if (accountMapper.getAccountByName(account.getName()) != null) {
     throw new ForbiddenException(
         ExceptionCode.ACCOUNT_NAME_EXISTS,
         MessageFormat.format("Account Name:{0} already exists ", account.getName()));
   }
 }
示例#2
0
 public synchronized Long insertAccount(Account account) {
   validateAccountNonExistence(account);
   account.setAmount(defaultAmount);
   accountMapper.insertAccount(account);
   logger.info("New Account ID:{} and Name:{} created", account.getId(), account.getName());
   return account.getId();
 }
示例#3
0
 public Account getAccount(Long accountId) {
   Account account = accountMapper.getAccountById(accountId);
   if (account == null) {
     throw new BadRequestException(
         BadRequestException.ExceptionCode.INVALID_ACCOUNT_ID,
         MessageFormat.format("Invalid account ID:{0} ", accountId));
   }
   return account;
 }