add active account (#61)
Some checks are pending
Maven Deploy Artifact / deploy (push) Waiting to run

This commit is contained in:
Gregory 2024-10-28 11:27:48 +03:00 committed by GitHub
parent efd3c87623
commit fd05aaefa7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 12 additions and 8 deletions

View File

@ -8,6 +8,6 @@ public interface AccountDao {
Account save(Account account);
List<Account> getAll();
List<Account> getAllActive();
}

View File

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

View File

@ -12,6 +12,7 @@ public class BalanceInfoToAccountConverter {
account.setCurrency(source.getCurrency());
account.setNumber(source.getAccountId());
account.setProviderId(providerId);
account.setActive(Boolean.TRUE);
return account;
}
}

View File

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

View File

@ -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());

View File

@ -0,0 +1,2 @@
ALTER TABLE scrooge.account
ADD COLUMN IF NOT EXISTS active BOOLEAN NOT NULL DEFAULT true;

View File

@ -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());