mirror of
https://github.com/valitydev/scrooge.git
synced 2024-11-06 01:55:19 +00:00
add active account (#61)
Some checks are pending
Maven Deploy Artifact / deploy (push) Waiting to run
Some checks are pending
Maven Deploy Artifact / deploy (push) Waiting to run
This commit is contained in:
parent
efd3c87623
commit
fd05aaefa7
@ -8,6 +8,6 @@ public interface AccountDao {
|
||||
|
||||
Account save(Account account);
|
||||
|
||||
List<Account> getAll();
|
||||
List<Account> getAllActive();
|
||||
|
||||
}
|
||||
|
@ -4,7 +4,7 @@ import dev.vality.mapper.RecordRowMapper;
|
||||
import dev.vality.scrooge.dao.domain.tables.pojos.Account;
|
||||
import dev.vality.scrooge.dao.domain.tables.records.AccountRecord;
|
||||
import org.jooq.Query;
|
||||
import org.jooq.SelectWhereStep;
|
||||
import org.jooq.SelectConditionStep;
|
||||
import org.springframework.jdbc.core.RowMapper;
|
||||
import org.springframework.jdbc.support.GeneratedKeyHolder;
|
||||
import org.springframework.stereotype.Component;
|
||||
@ -39,9 +39,10 @@ public class AccountDaoImpl extends AbstractDao implements AccountDao {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Account> getAll() {
|
||||
SelectWhereStep<AccountRecord> where = getDslContext()
|
||||
.selectFrom(ACCOUNT);
|
||||
public List<Account> getAllActive() {
|
||||
SelectConditionStep<AccountRecord> where = getDslContext()
|
||||
.selectFrom(ACCOUNT)
|
||||
.where(ACCOUNT.ACTIVE.eq(Boolean.TRUE));
|
||||
return fetch(where, listRecordRowMapper);
|
||||
}
|
||||
}
|
||||
|
@ -12,6 +12,7 @@ public class BalanceInfoToAccountConverter {
|
||||
account.setCurrency(source.getCurrency());
|
||||
account.setNumber(source.getAccountId());
|
||||
account.setProviderId(providerId);
|
||||
account.setActive(Boolean.TRUE);
|
||||
return account;
|
||||
}
|
||||
}
|
||||
|
@ -35,7 +35,7 @@ public class AccountSurveyServiceImpl implements AccountSurveyService {
|
||||
log.info("Success response from adapter {} , balanceInfo: {}", url, balanceInfo);
|
||||
return balanceInfo;
|
||||
} catch (TException | WRuntimeException e) {
|
||||
log.error("Error call adapter with url={}", url, e);
|
||||
log.warn("Error call adapter with url={}, error: {}", url, e.getMessage());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ public class BalanceRenewalService {
|
||||
@SchedulerLock(name = "balance_renewal_process")
|
||||
public void renew() {
|
||||
log.info("Start update balances");
|
||||
List<Account> accounts = accountDao.getAll();
|
||||
List<Account> accounts = accountDao.getAllActive();
|
||||
for (Account account : accounts) {
|
||||
log.info("Try update balance for account with number: {}, terminal: {}",
|
||||
account.getNumber(), account.getTerminalRef());
|
||||
|
@ -0,0 +1,2 @@
|
||||
ALTER TABLE scrooge.account
|
||||
ADD COLUMN IF NOT EXISTS active BOOLEAN NOT NULL DEFAULT true;
|
@ -84,7 +84,7 @@ class AccountDaoImplTest {
|
||||
.set(dslContext.newRecord(ACCOUNT, account))
|
||||
.execute();
|
||||
|
||||
List<Account> all = accountDao.getAll();
|
||||
List<Account> all = accountDao.getAllActive();
|
||||
|
||||
assertEquals(1, all.size());
|
||||
assertEquals(account.getNumber(), all.get(0).getNumber());
|
||||
|
Loading…
Reference in New Issue
Block a user