This commit is contained in:
parent
b3f56db198
commit
95758276ca
7 changed files with 75 additions and 3 deletions
|
|
@ -180,6 +180,7 @@ public class ClientCodeValidationConfig {
|
|||
addImdg.accept(IMDGDistributedNames.Map_DepoAccount);
|
||||
addImdg.accept(IMDGDistributedNames.Map_ClientCode);
|
||||
return new ValidatorImpl<>(context,
|
||||
GatewayUpdateEksClientCodeValidationRule.RequiredAndCorrectsFields,
|
||||
GatewayUpdateEksClientCodeValidationRule.CompanyPresent,
|
||||
GatewayUpdateEksClientCodeValidationRule.TkrIsPresent,
|
||||
GatewayUpdateEksClientCodeValidationRule.DepoAccountIsValid,
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ public enum GatewayClientCodeValidationRule implements IValidationRule<ImdgValid
|
|||
Map.of("tradingCode", String.valueOf(tradingCode))
|
||||
);
|
||||
if (company == null) {
|
||||
return of(AccountError.COMPANY_NOT_FOUND_GTW, "trading_code");
|
||||
return of(AccountError.COMPANY_NOT_FOUND_GTW, tradingCode);
|
||||
}
|
||||
|
||||
context.storeObject(ClientCodeStoreObjects.COMPANY, company);
|
||||
|
|
|
|||
|
|
@ -34,10 +34,19 @@ public enum GatewayEksClientCodeValidationRule implements IValidationRule<ImdgVa
|
|||
public Optional<EnumMessage> validate(ImdgValidationContext<TkrAccount> context) {
|
||||
TkrAccount validatedObject = context.getValidatedObject();
|
||||
|
||||
if (!StringUtils.hasText(validatedObject.getCompanyId())) {
|
||||
return of(AccountError.RequiredFieldEmpty, "companyId");
|
||||
}
|
||||
if (!StringUtils.hasText(validatedObject.getTypeOperationClient())) {
|
||||
return of(AccountError.RequiredFieldEmpty, "typeOperationClient");
|
||||
}
|
||||
for (MoneyAccountMsgRequest msg : validatedObject.getMoneyAccounts()) {
|
||||
if (!StringUtils.hasText(msg.getAccount()) && !StringUtils.hasText(msg.getEks_account())) {
|
||||
return of(AccountError.RequiredFieldEmpty, "account+eks_account");
|
||||
}
|
||||
if (!StringUtils.hasText(msg.getStatus())) {
|
||||
return of(AccountError.RequiredFieldEmpty, "status");
|
||||
}
|
||||
if (!msg.getStatus().equals("NEW")) {
|
||||
return of(AccountError.WrongFieldValue, "status");
|
||||
}
|
||||
|
|
@ -59,7 +68,7 @@ public enum GatewayEksClientCodeValidationRule implements IValidationRule<ImdgVa
|
|||
Map.of("tradingCode", String.valueOf(tradingCode))
|
||||
);
|
||||
if (company == null) {
|
||||
return of(AccountError.COMPANY_NOT_FOUND_GTW, "trading_code");
|
||||
return of(AccountError.COMPANY_NOT_FOUND_GTW, tradingCode);
|
||||
}
|
||||
|
||||
context.storeObject(ClientCodeStoreObjects.COMPANY, company);
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ package ru.spcex.clearing.account.validation;
|
|||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
|
@ -21,11 +22,13 @@ import ru.spcex.clearing.platform.messaging.domain.cud.account.TkrAccount;
|
|||
import ru.spcex.clearing.platform.messaging.domain.cud.gateway.MoneyAccountMsgRequest;
|
||||
import ru.spcex.platform.enumeration.AccountType;
|
||||
import ru.spcex.platform.enumeration.CurrencyCode;
|
||||
import ru.spcex.platform.enumeration.MoneyAccountStatus;
|
||||
import ru.spcex.platform.enumeration.Status;
|
||||
import ru.spcex.platform.imdg.api.Imdg;
|
||||
import ru.spcex.platform.imdg.api.predicate.ImdgPredicateBuilder;
|
||||
import ru.spcex.platform.imdg.validation.ImdgValidationContext;
|
||||
import ru.spcex.platform.utils.enumeration.EnumMessage;
|
||||
import ru.spcex.platform.utils.enumeration.IEnumKey;
|
||||
import ru.spcex.platform.utils.validation.IValidationRule;
|
||||
|
||||
public enum GatewayUpdateEksClientCodeValidationRule implements IValidationRule<ImdgValidationContext<TkrAccount>> {
|
||||
|
|
@ -43,7 +46,7 @@ public enum GatewayUpdateEksClientCodeValidationRule implements IValidationRule<
|
|||
Map.of("tradingCode", String.valueOf(tradingCode))
|
||||
);
|
||||
if (company == null) {
|
||||
return of(AccountError.COMPANY_NOT_FOUND_GTW, "trading_code");
|
||||
return of(AccountError.COMPANY_NOT_FOUND_GTW, tradingCode);
|
||||
}
|
||||
|
||||
context.storeObject(ClientCodeStoreObjects.COMPANY, company);
|
||||
|
|
@ -51,6 +54,38 @@ public enum GatewayUpdateEksClientCodeValidationRule implements IValidationRule<
|
|||
}
|
||||
},
|
||||
|
||||
RequiredAndCorrectsFields() {
|
||||
@Override
|
||||
public Optional<EnumMessage> validate(ImdgValidationContext<TkrAccount> context) {
|
||||
TkrAccount validatedObject = context.getValidatedObject();
|
||||
|
||||
if (!StringUtils.hasText(validatedObject.getCompanyId())) {
|
||||
return of(AccountError.RequiredFieldEmpty, "companyId");
|
||||
}
|
||||
|
||||
if (!StringUtils.hasText(validatedObject.getTypeOperationClient())) {
|
||||
return of(AccountError.RequiredFieldEmpty, "typeOperationClient");
|
||||
}
|
||||
|
||||
List<MoneyAccountMsgRequest> moneyAccounts = validatedObject.getMoneyAccounts();
|
||||
if (moneyAccounts == null) moneyAccounts = Collections.emptyList();
|
||||
for (MoneyAccountMsgRequest moneyAccount : moneyAccounts) {
|
||||
if (!StringUtils.hasText(moneyAccount.getStatus())) {
|
||||
return of(AccountError.RequiredFieldEmpty, "status");
|
||||
}
|
||||
if (!IEnumKey.contains(moneyAccount.getStatus(), MoneyAccountStatus.NEW, MoneyAccountStatus.NOW)) {
|
||||
return of(AccountError.WrongFieldValue, "status");
|
||||
}
|
||||
if (!StringUtils.hasText(moneyAccount.getAccount())
|
||||
&& !StringUtils.hasText(moneyAccount.getEks_account())) {
|
||||
return of(AccountError.RequiredFieldEmpty, "account & eks_account");
|
||||
}
|
||||
}
|
||||
|
||||
return Optional.empty();
|
||||
}
|
||||
},
|
||||
|
||||
TkrIsPresent() {
|
||||
@Override
|
||||
public Optional<EnumMessage> validate(ImdgValidationContext<TkrAccount> context) {
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ public class TkrAdapter {
|
|||
public TkrAccount toTkrResponse(InfoAccount infoAccount) {
|
||||
TkrAccount tkrResponse = new TkrAccount();
|
||||
tkrResponse.setCompanyId(infoAccount.getCompanyId());
|
||||
tkrResponse.setTypeOperationClient(infoAccount.getTypeOperationClient());
|
||||
tkrResponse.setTradingCode(infoAccount.getTradingCode());
|
||||
tkrResponse.setClientCode(infoAccount.getClientCode());
|
||||
tkrResponse.setEnabled(infoAccount.getEnabled());
|
||||
|
|
|
|||
|
|
@ -0,0 +1,18 @@
|
|||
package ru.spcex.platform.enumeration;
|
||||
|
||||
import ru.spcex.platform.utils.enumeration.IEnumKey;
|
||||
|
||||
public enum MoneyAccountStatus implements IEnumKey {
|
||||
NEW("NEW"), NOW("NOW"), ;
|
||||
|
||||
private final String key;
|
||||
|
||||
MoneyAccountStatus(String key) {
|
||||
this.key = key;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getKey() {
|
||||
return key;
|
||||
}
|
||||
}
|
||||
|
|
@ -22,6 +22,14 @@ public class TkrAccount {
|
|||
@JsonProperty
|
||||
private List<MoneyAccountMsgRequest> moneyAccounts;
|
||||
|
||||
public String getTypeOperationClient() {
|
||||
return typeOperationClient;
|
||||
}
|
||||
|
||||
public void setTypeOperationClient(String typeOperationClient) {
|
||||
this.typeOperationClient = typeOperationClient;
|
||||
}
|
||||
|
||||
public String getCompanyId() {
|
||||
return companyId;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue