fix names and add consts
This commit is contained in:
parent
ff992e6812
commit
67058ad32a
13 changed files with 151 additions and 100 deletions
|
|
@ -7,8 +7,8 @@ import ru.clearing.classes.statics.data.company.Company;
|
|||
import ru.clearing.platform.dictionary.AccountTypeDictionary;
|
||||
import ru.spcex.clearing.account.errors.AccountError;
|
||||
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
||||
import ru.spcex.clearing.platform.messaging.domain.cud.account.AccountCorrespondentNewRequest;
|
||||
import ru.spcex.clearing.platform.messaging.domain.cud.account.AccountCorrespondentUpdateRequest;
|
||||
import ru.spcex.clearing.platform.messaging.domain.cud.account.CorrespondentAccountNewRequest;
|
||||
import ru.spcex.clearing.platform.messaging.domain.cud.account.CorrespondentAccountUpdateRequest;
|
||||
import ru.spcex.clearing.platform.messaging.domain.cud.common.CommonDeleteRequest;
|
||||
import ru.spcex.clearing.validation.common.rules.DictionaryPresentRule;
|
||||
import ru.spcex.clearing.validation.common.rules.EnumPresentRule;
|
||||
|
|
@ -35,27 +35,27 @@ import java.util.function.Function;
|
|||
@Configuration
|
||||
public class AccountValidationConfig {
|
||||
|
||||
@Bean("accountCorrespondentNewRequestValidator")
|
||||
public Function<AccountCorrespondentNewRequest, IValidator> accountCorrespondentNewRequestValidator(
|
||||
@Bean("correspondentAccountNewRequestValidator")
|
||||
public Function<CorrespondentAccountNewRequest, IValidator> correspondentAccountNewRequestValidator(
|
||||
Map<String, Imdg<? extends SpcexObjectBase>> imdgForValidation
|
||||
) {
|
||||
return accountCorrespondentNewRequest -> {
|
||||
ImdgValidationContext<AccountCorrespondentNewRequest> context = new ImdgValidationContext<>();
|
||||
context.setValidatedObject(accountCorrespondentNewRequest);
|
||||
return correspondentAccountNewRequest -> {
|
||||
ImdgValidationContext<CorrespondentAccountNewRequest> context = new ImdgValidationContext<>();
|
||||
context.setValidatedObject(correspondentAccountNewRequest);
|
||||
Consumer<String> addImdg = (s) -> context.addImdg(s, imdgForValidation.get(s));
|
||||
addImdg.accept(IMDGDistributedNames.Map_Company);
|
||||
addImdg.accept(IMDGDistributedNames.Map_Account);
|
||||
addImdg.accept(IMDGDistributedNames.Map_AccountTypeDictionary);
|
||||
return new ValidatorImpl<>(context,
|
||||
IdPresentRule.instance("companyId",
|
||||
AccountCorrespondentNewRequest::getCompanyId,
|
||||
CorrespondentAccountNewRequest::getCompanyId,
|
||||
IMDGDistributedNames.Map_Company,
|
||||
Company.class,
|
||||
AccountError.RequiredFieldEmpty,
|
||||
AccountError.CompanyNotFound,
|
||||
company -> WorkflowStatus.Active.getKey().equals(company.getWorkflowStatus()) ? null : AccountError.CompanyNotActive),
|
||||
FieldRequiredRule.instance("account",
|
||||
AccountCorrespondentNewRequest::getAccount,
|
||||
CorrespondentAccountNewRequest::getAccount,
|
||||
AccountError.RequiredFieldEmpty,
|
||||
accountValue -> {
|
||||
Imdg<Account> accountImdg = context.obtainMap(
|
||||
|
|
@ -70,7 +70,7 @@ public class AccountValidationConfig {
|
|||
return AccountError.AccountAlreadyExist;
|
||||
}),
|
||||
FieldRequiredRule.instance("status",
|
||||
AccountCorrespondentNewRequest::getStatus,
|
||||
CorrespondentAccountNewRequest::getStatus,
|
||||
AccountError.RequiredFieldEmpty,
|
||||
false,
|
||||
statusValue -> {
|
||||
|
|
@ -79,12 +79,12 @@ public class AccountValidationConfig {
|
|||
return AccountError.WrongFieldValue;
|
||||
}),
|
||||
EnumPresentRule.instance("accountType",
|
||||
AccountCorrespondentNewRequest::getAccountType,
|
||||
CorrespondentAccountNewRequest::getAccountType,
|
||||
AccountType.values(),
|
||||
AccountError.WrongFieldValue,
|
||||
AccountError.RequiredFieldEmpty),
|
||||
DictionaryPresentRule.instance("accountType",
|
||||
AccountCorrespondentNewRequest::getAccountType,
|
||||
CorrespondentAccountNewRequest::getAccountType,
|
||||
IMDGDistributedNames.Map_AccountTypeDictionary,
|
||||
AccountTypeDictionary.class,
|
||||
AccountError.RequiredFieldEmpty,
|
||||
|
|
@ -97,32 +97,32 @@ public class AccountValidationConfig {
|
|||
};
|
||||
}
|
||||
|
||||
@Bean("accountCorrespondentUpdateRequestValidator")
|
||||
public Function<AccountCorrespondentUpdateRequest, IValidator> accountCorrespondentUpdateRequestValidator(
|
||||
@Bean("correspondentAccountUpdateRequestValidator")
|
||||
public Function<CorrespondentAccountUpdateRequest, IValidator> correspondentAccountUpdateRequestValidator(
|
||||
Map<String, Imdg<? extends SpcexObjectBase>> imdgForValidation
|
||||
) {
|
||||
return accountCorrespondentUpdateRequest -> {
|
||||
ImdgValidationContext<AccountCorrespondentUpdateRequest> context = new ImdgValidationContext<>();
|
||||
context.setValidatedObject(accountCorrespondentUpdateRequest);
|
||||
return correspondentAccountUpdateRequest -> {
|
||||
ImdgValidationContext<CorrespondentAccountUpdateRequest> context = new ImdgValidationContext<>();
|
||||
context.setValidatedObject(correspondentAccountUpdateRequest);
|
||||
Consumer<String> addImdg = (s) -> context.addImdg(s, imdgForValidation.get(s));
|
||||
addImdg.accept(IMDGDistributedNames.Map_Company);
|
||||
addImdg.accept(IMDGDistributedNames.Map_Account);
|
||||
addImdg.accept(IMDGDistributedNames.Map_AccountTypeDictionary);
|
||||
return new ValidatorImpl<>(context,
|
||||
IdPresentRule.instance("id",
|
||||
AccountCorrespondentUpdateRequest::getId,
|
||||
CorrespondentAccountUpdateRequest::getId,
|
||||
IMDGDistributedNames.Map_Account,
|
||||
Account.class,
|
||||
AccountError.RequiredFieldEmpty,
|
||||
AccountError.AccountNotFound,
|
||||
account -> {
|
||||
String statusFromRequest = accountCorrespondentUpdateRequest.getStatus();
|
||||
String statusFromRequest = correspondentAccountUpdateRequest.getStatus();
|
||||
if (statusFromRequest != null && !statusFromRequest.equalsIgnoreCase(account.getStatus()))
|
||||
return AccountError.WrongFieldValue;
|
||||
return null;
|
||||
}),
|
||||
IdPresentRule.instance("companyId",
|
||||
AccountCorrespondentUpdateRequest::getCompanyId,
|
||||
CorrespondentAccountUpdateRequest::getCompanyId,
|
||||
IMDGDistributedNames.Map_Company,
|
||||
Company.class,
|
||||
AccountError.RequiredFieldEmpty,
|
||||
|
|
@ -130,22 +130,22 @@ public class AccountValidationConfig {
|
|||
false,
|
||||
company -> {
|
||||
IErrorEnumId error = WorkflowStatus.Active.getKey().equals(company.getWorkflowStatus()) ? null : AccountError.CompanyNotActive;
|
||||
error = Objects.equals(company.getId(), accountCorrespondentUpdateRequest.getCompanyId()) ? error : AccountError.WrongFieldValue;
|
||||
error = Objects.equals(company.getId(), correspondentAccountUpdateRequest.getCompanyId()) ? error : AccountError.WrongFieldValue;
|
||||
return error;
|
||||
}),
|
||||
EnumPresentRule.instance("status",
|
||||
AccountCorrespondentUpdateRequest::getStatus,
|
||||
CorrespondentAccountUpdateRequest::getStatus,
|
||||
AccountStatus.values(),
|
||||
false,
|
||||
AccountError.WrongFieldValue,
|
||||
AccountError.RequiredFieldEmpty),
|
||||
EnumPresentRule.instance("accountType",
|
||||
AccountCorrespondentUpdateRequest::getAccountType,
|
||||
CorrespondentAccountUpdateRequest::getAccountType,
|
||||
AccountType.values(),
|
||||
AccountError.WrongFieldValue,
|
||||
AccountError.RequiredFieldEmpty),
|
||||
DictionaryPresentRule.instance("accountType",
|
||||
AccountCorrespondentUpdateRequest::getAccountType,
|
||||
CorrespondentAccountUpdateRequest::getAccountType,
|
||||
IMDGDistributedNames.Map_AccountTypeDictionary,
|
||||
AccountTypeDictionary.class,
|
||||
AccountError.RequiredFieldEmpty,
|
||||
|
|
@ -158,13 +158,13 @@ public class AccountValidationConfig {
|
|||
};
|
||||
}
|
||||
|
||||
@Bean("accountCorrespondentBlockRequestValidator")
|
||||
public Function<CommonDeleteRequest, IValidator> accountCorrespondentBlockRequestValidator(
|
||||
@Bean("correspondentAccountBlockRequestValidator")
|
||||
public Function<CommonDeleteRequest, IValidator> correspondentAccountBlockRequestValidator(
|
||||
Map<String, Imdg<? extends SpcexObjectBase>> imdgForValidation
|
||||
) {
|
||||
return accountDeleteRequest -> {
|
||||
return correspondentAccountBlockRequest -> {
|
||||
ImdgValidationContext<CommonDeleteRequest> context = new ImdgValidationContext<>();
|
||||
context.setValidatedObject(accountDeleteRequest);
|
||||
context.setValidatedObject(correspondentAccountBlockRequest);
|
||||
Consumer<String> addImdg = (s) -> context.addImdg(s, imdgForValidation.get(s));
|
||||
addImdg.accept(IMDGDistributedNames.Map_Account);
|
||||
return new ValidatorImpl<>(context,
|
||||
|
|
|
|||
|
|
@ -0,0 +1,8 @@
|
|||
package ru.spcex.clearing.account.config.validation;
|
||||
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@Configuration
|
||||
public class ClearingAccountValidationConfig {
|
||||
|
||||
}
|
||||
|
|
@ -5,6 +5,7 @@ import org.springframework.context.annotation.Bean;
|
|||
import org.springframework.context.annotation.Configuration;
|
||||
import ru.clearing.classes.statics.data.account.Account;
|
||||
import ru.clearing.classes.statics.data.account.BankAccount;
|
||||
import ru.clearing.classes.statics.data.account.ClearingAccount;
|
||||
import ru.clearing.classes.statics.data.company.ClearingMemberCategory;
|
||||
import ru.clearing.classes.statics.data.company.Company;
|
||||
import ru.clearing.platform.dictionary.CurrencyCodeDictionary;
|
||||
|
|
@ -33,6 +34,7 @@ public class ValidationConfig {
|
|||
addImdg.accept(IMDGDistributedNames.Map_AccountTypeDictionary, Account.class);
|
||||
addImdg.accept(IMDGDistributedNames.Map_BankAccount, BankAccount.class);
|
||||
addImdg.accept(IMDGDistributedNames.Map_CurrencyCodeDictionary, CurrencyCodeDictionary.class);
|
||||
addImdg.accept(IMDGDistributedNames.Map_ClearingAccount, ClearingAccount.class);
|
||||
|
||||
return imdg;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,8 +15,8 @@ import ru.spcex.clearing.account.errors.AccountError;
|
|||
import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
||||
import ru.spcex.clearing.platform.messaging.domain.BaseRequest;
|
||||
import ru.spcex.clearing.platform.messaging.domain.Consts;
|
||||
import ru.spcex.clearing.platform.messaging.domain.cud.account.AccountCorrespondentNewRequest;
|
||||
import ru.spcex.clearing.platform.messaging.domain.cud.account.AccountCorrespondentUpdateRequest;
|
||||
import ru.spcex.clearing.platform.messaging.domain.cud.account.CorrespondentAccountNewRequest;
|
||||
import ru.spcex.clearing.platform.messaging.domain.cud.account.CorrespondentAccountUpdateRequest;
|
||||
import ru.spcex.clearing.platform.messaging.domain.cud.account.sdf01.AccountSdf01Request;
|
||||
import ru.spcex.clearing.platform.messaging.domain.cud.account.sdf01.AccountSdfRequestPart;
|
||||
import ru.spcex.clearing.platform.messaging.domain.cud.balance.AccountSdfToStatementRequestPart;
|
||||
|
|
@ -57,8 +57,8 @@ public class AccountService extends QueueConsumer implements InitializingBean {
|
|||
private final IMessageResolver messageResolver;
|
||||
private final UserRoleVerification userRoleVerification;
|
||||
private final ValidationHelper validationHelper;
|
||||
private final Function<AccountCorrespondentNewRequest, IValidator> accountNewRequestValidator;
|
||||
private final Function<AccountCorrespondentUpdateRequest, IValidator> accountUpdateRequestValidator;
|
||||
private final Function<CorrespondentAccountNewRequest, IValidator> accountNewRequestValidator;
|
||||
private final Function<CorrespondentAccountUpdateRequest, IValidator> accountUpdateRequestValidator;
|
||||
private final Function<CommonDeleteRequest, IValidator> accountBlockRequestValidator;
|
||||
|
||||
@Autowired
|
||||
|
|
@ -69,11 +69,11 @@ public class AccountService extends QueueConsumer implements InitializingBean {
|
|||
IMessageResolver messageResolver,
|
||||
UserRoleVerification userRoleVerification,
|
||||
ValidationHelper validationHelper,
|
||||
@Qualifier("accountCorrespondentNewRequestValidator")
|
||||
Function<AccountCorrespondentNewRequest, IValidator> accountNewRequestValidator,
|
||||
@Qualifier("accountCorrespondentUpdateRequestValidator")
|
||||
Function<AccountCorrespondentUpdateRequest, IValidator> accountUpdateRequestValidator,
|
||||
@Qualifier("accountCorrespondentBlockRequestValidator")
|
||||
@Qualifier("correspondentAccountNewRequestValidator")
|
||||
Function<CorrespondentAccountNewRequest, IValidator> accountNewRequestValidator,
|
||||
@Qualifier("correspondentAccountUpdateRequestValidator")
|
||||
Function<CorrespondentAccountUpdateRequest, IValidator> accountUpdateRequestValidator,
|
||||
@Qualifier("correspondentAccountBlockRequestValidator")
|
||||
Function<CommonDeleteRequest, IValidator> accountBlockRequestValidator) {
|
||||
super(kafkaQueue, kafkaProducer);
|
||||
this.accountMap = imdgProvider.getImdg(
|
||||
|
|
@ -98,21 +98,21 @@ public class AccountService extends QueueConsumer implements InitializingBean {
|
|||
public void afterPropertiesSet() {
|
||||
callback(AccountSdf01Request.class)
|
||||
.setConsumer(this::accountNewSdf01)
|
||||
.forDestination(Consts.ACCOUNT_NEW_SDF01, callbacks::put);
|
||||
callback(AccountCorrespondentNewRequest.class)
|
||||
.forDestination(Consts.CLEARING_ACCOUNT_NEW_SDF01, callbacks::put);
|
||||
callback(CorrespondentAccountNewRequest.class)
|
||||
.setConsumer(this::accountCorrespondentNew)
|
||||
.forDestination(Consts.DESTINATION_ACCOUNT_CORRESPONDENT_NEW, callbacks::put);
|
||||
callback(AccountCorrespondentUpdateRequest.class)
|
||||
.setConsumer(this::accountCorrespondentUpdate)
|
||||
.forDestination(Consts.DESTINATION_ACCOUNT_CORRESPONDENT_UPDATE, callbacks::put);
|
||||
.forDestination(Consts.DESTINATION_CORRESPONDENT_ACCOUNT_NEW, callbacks::put);
|
||||
callback(CorrespondentAccountUpdateRequest.class)
|
||||
.setConsumer(this::correspondentAccountUpdate)
|
||||
.forDestination(Consts.DESTINATION_CORRESPONDENT_ACCOUNT_UPDATE, callbacks::put);
|
||||
callback(CommonDeleteRequest.class)
|
||||
.setConsumer(this::accountCorrespondentBlock)
|
||||
.forDestination(Consts.DESTINATION_ACCOUNT_CORRESPONDENT_BLOCK, callbacks::put);
|
||||
.setConsumer(this::correspondentAccountBlock)
|
||||
.forDestination(Consts.DESTINATION_CORRESPONDENT_ACCOUNT_BLOCK, callbacks::put);
|
||||
init();
|
||||
}
|
||||
|
||||
public RequestInfoUpdate accountCorrespondentNew(BaseRequest<AccountCorrespondentNewRequest> userRequest) {
|
||||
log.debug("AccountCorrespondentNewRequest received");
|
||||
public RequestInfoUpdate accountCorrespondentNew(BaseRequest<CorrespondentAccountNewRequest> userRequest) {
|
||||
log.debug("CorrespondentAccountNewRequest received");
|
||||
|
||||
RequestInfoUpdate requestInfoUpdate = userRoleVerification.validateRoleAndGetResult(userRequest);
|
||||
if (requestInfoUpdate != null) return requestInfoUpdate;
|
||||
|
|
@ -120,42 +120,36 @@ public class AccountService extends QueueConsumer implements InitializingBean {
|
|||
requestInfoUpdate = validationHelper.validateTillFirstError(userRequest, accountNewRequestValidator);
|
||||
if (requestInfoUpdate != null) return requestInfoUpdate;
|
||||
|
||||
AccountCorrespondentNewRequest req = userRequest.getRequestPayload();
|
||||
CorrespondentAccountNewRequest req = userRequest.getRequestPayload();
|
||||
|
||||
Long companyId = req.getCompanyId();
|
||||
ImdgPredicateBuilder clearingMemberCategoryPredicateBuilder = clearingMemberCategoryMap.predicateBuilder();
|
||||
ImdgPredicate companyIdEquals = clearingMemberCategoryPredicateBuilder.equals("companyId", companyId);
|
||||
Collection<ClearingMemberCategory> clearingMemberCategories = clearingMemberCategoryMap.getCollectionObjectsByPredicate(companyIdEquals);
|
||||
|
||||
// todo выяснить у репортера, что делать в такой ситуации (нужна ли отдельная ошибка)
|
||||
if (clearingMemberCategories.isEmpty()) {
|
||||
if (clearingMemberCategories.isEmpty())
|
||||
return makeError(AccountError.ClearingCategoryNotFound, "clearingMemberCategory[companyId]", userRequest.getId());
|
||||
}
|
||||
if (clearingMemberCategories.size() > 1) {
|
||||
if (clearingMemberCategories.size() > 1)
|
||||
log.warn("ClearingMemberCategory for companyId {} contains multiply elements, use first", companyId);
|
||||
}
|
||||
ClearingMemberCategory clearingMemberCategory = clearingMemberCategories.iterator().next();
|
||||
|
||||
ImdgPredicateBuilder relationPredicateBuilder = relationMap.predicateBuilder();
|
||||
ImdgPredicate consumerIdPredicate = relationPredicateBuilder.equals("consumerId", companyId);
|
||||
ImdgPredicate servicePredicate = null;
|
||||
ClearingMemberCategory clearingMemberCategory = clearingMemberCategories.iterator().next();
|
||||
String clearingCategoryValue = clearingMemberCategory.getClearingMemberCategory();
|
||||
if (IEnumKey.contains(clearingCategoryValue, ClearingCategory.B, ClearingCategory.I, ClearingCategory.V)) {
|
||||
servicePredicate = relationPredicateBuilder.equals("service", ru.spcex.platform.enumeration.Service.MKR.getKey());
|
||||
} else if (IEnumKey.contains(clearingCategoryValue, ClearingCategory.F, ClearingCategory.C)) {
|
||||
servicePredicate = relationPredicateBuilder.equals("service", ru.spcex.platform.enumeration.Service.FOND.getKey());
|
||||
} else {
|
||||
// todo выяснить у репортера, что делать в такой ситуации
|
||||
return makeError(AccountError.ClearingCategoryNotFound, "relation[consumerId = companyId].service", userRequest.getId());
|
||||
}
|
||||
ImdgPredicate finalRelationPredicate = relationPredicateBuilder.and(consumerIdPredicate, servicePredicate);
|
||||
Collection<Relation> relations = relationMap.getCollectionObjectsByPredicate(finalRelationPredicate);
|
||||
if (relations.isEmpty()) {
|
||||
return makeError(AccountError.WrongFieldValue, "companyId", userRequest.getId());
|
||||
}
|
||||
if (relations.size() > 1) {
|
||||
|
||||
if (relations.isEmpty()) return makeError(AccountError.WrongFieldValue, "companyId", userRequest.getId());
|
||||
if (relations.size() > 1)
|
||||
log.warn("Relation for consumerId {} contains multiply elements, use first", companyId);
|
||||
}
|
||||
Relation relation = relations.iterator().next();
|
||||
|
||||
Collection<Account> companies = accountMap.getCollectionObjectsByFieldValues(Map.of("companyId", companyId));
|
||||
|
|
@ -176,8 +170,8 @@ public class AccountService extends QueueConsumer implements InitializingBean {
|
|||
return null;
|
||||
}
|
||||
|
||||
public RequestInfoUpdate accountCorrespondentUpdate(BaseRequest<AccountCorrespondentUpdateRequest> userRequest) {
|
||||
log.debug("AccountCorrespondentUpdateRequest received");
|
||||
public RequestInfoUpdate correspondentAccountUpdate(BaseRequest<CorrespondentAccountUpdateRequest> userRequest) {
|
||||
log.debug("CorrespondentAccountUpdateRequest received");
|
||||
|
||||
RequestInfoUpdate requestInfoUpdate = userRoleVerification.validateRoleAndGetResult(userRequest);
|
||||
if (requestInfoUpdate != null) return requestInfoUpdate;
|
||||
|
|
@ -185,7 +179,7 @@ public class AccountService extends QueueConsumer implements InitializingBean {
|
|||
requestInfoUpdate = validationHelper.validateTillFirstError(userRequest, accountUpdateRequestValidator);
|
||||
if (requestInfoUpdate != null) return requestInfoUpdate;
|
||||
|
||||
AccountCorrespondentUpdateRequest request = userRequest.getRequestPayload();
|
||||
CorrespondentAccountUpdateRequest request = userRequest.getRequestPayload();
|
||||
|
||||
Account account = accountMap.getSingleObjectByID(request.getId());
|
||||
|
||||
|
|
@ -199,7 +193,7 @@ public class AccountService extends QueueConsumer implements InitializingBean {
|
|||
return null;
|
||||
}
|
||||
|
||||
public RequestInfoUpdate accountCorrespondentBlock(BaseRequest<CommonDeleteRequest> userRequest) {
|
||||
public RequestInfoUpdate correspondentAccountBlock(BaseRequest<CommonDeleteRequest> userRequest) {
|
||||
log.debug("AccountBlockRequest received");
|
||||
|
||||
RequestInfoUpdate requestInfoUpdate = userRoleVerification.validateRoleAndGetResult(userRequest);
|
||||
|
|
|
|||
|
|
@ -0,0 +1,47 @@
|
|||
package ru.spcex.clearing.account.service;
|
||||
|
||||
import org.apache.kafka.clients.consumer.Consumer;
|
||||
import org.apache.kafka.clients.producer.Producer;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import ru.spcex.clearing.platform.messaging.service.QueueConsumer;
|
||||
import ru.spcex.clearing.platform.messaging.service.RequestInfoUpdate;
|
||||
import ru.spcex.clearing.util.security.UserRoleVerification;
|
||||
import ru.spcex.clearing.validation.common.ValidationHelper;
|
||||
|
||||
@Service
|
||||
public class ClearingAccountService extends QueueConsumer implements InitializingBean {
|
||||
private final Logger log = LoggerFactory.getLogger(getClass());
|
||||
private final UserRoleVerification userRoleVerification;
|
||||
private final ValidationHelper validationHelper;
|
||||
|
||||
@Autowired
|
||||
public ClearingAccountService(Consumer<String, Object> kafkaQueue,
|
||||
Producer<String, Object> kafkaResponseQueue,
|
||||
UserRoleVerification userRoleVerification,
|
||||
ValidationHelper validationHelper) {
|
||||
super(kafkaQueue, kafkaResponseQueue);
|
||||
this.userRoleVerification = userRoleVerification;
|
||||
this.validationHelper = validationHelper;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterPropertiesSet() throws Exception {
|
||||
init();
|
||||
}
|
||||
|
||||
public RequestInfoUpdate clearingAccountNew() {
|
||||
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public RequestInfoUpdate clearingAccountUpdate() {
|
||||
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
@ -29,8 +29,8 @@ import ru.spcex.clearing.imdg.IMDGDistributedNames;
|
|||
import ru.spcex.clearing.platform.messaging.domain.ActionType;
|
||||
import ru.spcex.clearing.platform.messaging.domain.BaseRequest;
|
||||
import ru.spcex.clearing.platform.messaging.domain.Consts;
|
||||
import ru.spcex.clearing.platform.messaging.domain.cud.account.AccountCorrespondentNewRequest;
|
||||
import ru.spcex.clearing.platform.messaging.domain.cud.account.AccountCorrespondentUpdateRequest;
|
||||
import ru.spcex.clearing.platform.messaging.domain.cud.account.CorrespondentAccountNewRequest;
|
||||
import ru.spcex.clearing.platform.messaging.domain.cud.account.CorrespondentAccountUpdateRequest;
|
||||
import ru.spcex.clearing.platform.messaging.domain.cud.account.sdf01.AccountSdf01Request;
|
||||
import ru.spcex.clearing.platform.messaging.domain.cud.account.sdf01.AccountSdfRequestPart;
|
||||
import ru.spcex.clearing.platform.messaging.domain.cud.balance.AccountSdfToStatementRequestPart;
|
||||
|
|
@ -67,7 +67,7 @@ class AccountServiceTest {
|
|||
public static final MatcherFactory.Matcher<Account> ACCOUNT_MATCHER = usingIgnoringFieldsComparator();
|
||||
public static final MatcherFactory.Matcher<RequestInfo> REQUEST_INFO_MATCHER_MATCHER = usingIgnoringFieldsComparator("created");
|
||||
private static final int PARTITION = 0;
|
||||
private static final String TOPIC_ACCOUNT_NEW = Consts.ACCOUNT_NEW_SDF01;
|
||||
private static final String TOPIC_ACCOUNT_NEW = Consts.CLEARING_ACCOUNT_NEW_SDF01;
|
||||
private static final String account = "123456789123";
|
||||
private static final Long companyId = 0L;
|
||||
private static final Long relationId = 0L;
|
||||
|
|
@ -133,11 +133,11 @@ class AccountServiceTest {
|
|||
void accountCorrespondentNew() {
|
||||
String uniqueAccount = account + UUID.randomUUID();
|
||||
|
||||
AccountCorrespondentNewRequest accountCorrespondentNewRequest = new AccountCorrespondentNewRequest();
|
||||
accountCorrespondentNewRequest.setAccount(uniqueAccount);
|
||||
accountCorrespondentNewRequest.setAccountType(AccountType.Corr.getKey());
|
||||
accountCorrespondentNewRequest.setCompanyId(companyId);
|
||||
accountCorrespondentNewRequest.setStatus(AccountStatus.ACTIVE.getKey());
|
||||
CorrespondentAccountNewRequest correspondentAccountNewRequest = new CorrespondentAccountNewRequest();
|
||||
correspondentAccountNewRequest.setAccount(uniqueAccount);
|
||||
correspondentAccountNewRequest.setAccountType(AccountType.Corr.getKey());
|
||||
correspondentAccountNewRequest.setCompanyId(companyId);
|
||||
correspondentAccountNewRequest.setStatus(AccountStatus.ACTIVE.getKey());
|
||||
|
||||
Account predictableAccount = new Account();
|
||||
predictableAccount.setAccount(uniqueAccount);
|
||||
|
|
@ -147,10 +147,10 @@ class AccountServiceTest {
|
|||
predictableAccount.setStatus(AccountStatus.ACTIVE.getKey());
|
||||
predictableAccount.setRelationId(relationId);
|
||||
|
||||
String jsonString = getJsonStringForNew(accountCorrespondentNewRequest, 0L);
|
||||
String jsonString = getJsonStringForNew(correspondentAccountNewRequest, 0L);
|
||||
|
||||
addRecordToKafka((MockConsumer) accountService.getConsumer(),
|
||||
Consts.DESTINATION_ACCOUNT_CORRESPONDENT_NEW,
|
||||
Consts.DESTINATION_CORRESPONDENT_ACCOUNT_NEW,
|
||||
PARTITION,
|
||||
0,
|
||||
jsonString);
|
||||
|
|
@ -176,19 +176,19 @@ class AccountServiceTest {
|
|||
existAccount.setCompanyId(companyId);
|
||||
Long accountId = accountImdg.insert(existAccount);
|
||||
|
||||
AccountCorrespondentUpdateRequest accountCorrespondentUpdateRequest = new AccountCorrespondentUpdateRequest();
|
||||
accountCorrespondentUpdateRequest.setAccount(updatedAccount);
|
||||
accountCorrespondentUpdateRequest.setAccountType(AccountType.Corr.getKey());
|
||||
accountCorrespondentUpdateRequest.setStatus(AccountStatus.ACTIVE.getKey());
|
||||
accountCorrespondentUpdateRequest.setCompanyId(companyId);
|
||||
accountCorrespondentUpdateRequest.setId(accountId);
|
||||
CorrespondentAccountUpdateRequest correspondentAccountUpdateRequest = new CorrespondentAccountUpdateRequest();
|
||||
correspondentAccountUpdateRequest.setAccount(updatedAccount);
|
||||
correspondentAccountUpdateRequest.setAccountType(AccountType.Corr.getKey());
|
||||
correspondentAccountUpdateRequest.setStatus(AccountStatus.ACTIVE.getKey());
|
||||
correspondentAccountUpdateRequest.setCompanyId(companyId);
|
||||
correspondentAccountUpdateRequest.setId(accountId);
|
||||
|
||||
|
||||
String jsonString = getJsonStringForUPDATE(accountCorrespondentUpdateRequest, 0);
|
||||
String jsonString = getJsonStringForUPDATE(correspondentAccountUpdateRequest, 0);
|
||||
|
||||
//ACT
|
||||
addRecordToKafka((MockConsumer) accountService.getConsumer(),
|
||||
Consts.DESTINATION_ACCOUNT_CORRESPONDENT_UPDATE,
|
||||
Consts.DESTINATION_CORRESPONDENT_ACCOUNT_UPDATE,
|
||||
PARTITION,
|
||||
0,
|
||||
jsonString);
|
||||
|
|
@ -220,7 +220,7 @@ class AccountServiceTest {
|
|||
|
||||
//ACT
|
||||
addRecordToKafka((MockConsumer) accountService.getConsumer(),
|
||||
Consts.DESTINATION_ACCOUNT_CORRESPONDENT_BLOCK,
|
||||
Consts.DESTINATION_CORRESPONDENT_ACCOUNT_BLOCK,
|
||||
PARTITION,
|
||||
0,
|
||||
jsonString);
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ public class AccountController extends AbstractQueueController {
|
|||
public CudResponse add(
|
||||
@ApiParam(value = "Параметры команды в JSON формате.", required = true)
|
||||
@RequestBody AccountNewAction accountNewAction) throws ExecutionException, InterruptedException {
|
||||
return processRequest(Consts.DESTINATION_ACCOUNT_NEW, accountNewAction);
|
||||
return processRequest(Consts.DESTINATION_CORRESPONDENT_ACCOUNT_NEW, accountNewAction);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "update account.")
|
||||
|
|
@ -68,7 +68,7 @@ public class AccountController extends AbstractQueueController {
|
|||
@ApiParam(value = "Новые значения полей объекта.", required = true)
|
||||
@RequestBody AccountUpdateAction accountUpdateAction) throws ExecutionException, InterruptedException {
|
||||
accountUpdateAction.setId(id);
|
||||
return processRequest(Consts.DESTINATION_ACCOUNT_UPDATE, accountUpdateAction);
|
||||
return processRequest(Consts.DESTINATION_CORRESPONDENT_ACCOUNT_UPDATE, accountUpdateAction);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "delete account.")
|
||||
|
|
@ -79,7 +79,7 @@ public class AccountController extends AbstractQueueController {
|
|||
@PathVariable("id") Long id) throws ExecutionException, InterruptedException {
|
||||
CommonDeleteAction deleteAction = new CommonDeleteAction();
|
||||
deleteAction.setId(id);
|
||||
return processRequest(Consts.DESTINATION_ACCOUNT_DELETE, deleteAction);
|
||||
return processRequest(Consts.DESTINATION_CORRESPONDENT_ACCOUNT_BLOCK, deleteAction);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ class AccountControllerTest extends AbstractControllerTest {
|
|||
|
||||
//ACT and ASSERT
|
||||
checkAddingByRestApi(REST_URL, accountNewAction);
|
||||
checkSendedMessegeFromKafka(Consts.DESTINATION_ACCOUNT_NEW, accountNewAction);
|
||||
checkSendedMessegeFromKafka(Consts.DESTINATION_CORRESPONDENT_ACCOUNT_NEW, accountNewAction);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -69,7 +69,7 @@ class AccountControllerTest extends AbstractControllerTest {
|
|||
//ACT and ASSERT
|
||||
checkUpdatingWithIdVolidationByRestApi(IMDGDistributedNames.Map_Account, account,
|
||||
REST_URL, accountUpdateAction, id);
|
||||
checkSendedMessegeFromKafka(Consts.DESTINATION_ACCOUNT_UPDATE, accountUpdateAction);
|
||||
checkSendedMessegeFromKafka(Consts.DESTINATION_CORRESPONDENT_ACCOUNT_UPDATE, accountUpdateAction);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -88,7 +88,7 @@ class AccountControllerTest extends AbstractControllerTest {
|
|||
//ACT and ASSERT
|
||||
checkDeletingWithIdVolidationByRestApi(IMDGDistributedNames.Map_Account, account,
|
||||
REST_URL, id);
|
||||
checkSendedMessegeFromKafka(Consts.DESTINATION_ACCOUNT_DELETE, deleteAction);
|
||||
checkSendedMessegeFromKafka(Consts.DESTINATION_CORRESPONDENT_ACCOUNT_BLOCK, deleteAction);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -106,7 +106,7 @@ public class StatementService extends QueueConsumer implements InitializingBean
|
|||
exportRequest.setNameOfTable(service.exportTableName());
|
||||
kafkaReqProducer.sendRequestToQueue(Consts.EXPORT_PROCESS, exportRequest);
|
||||
} else {
|
||||
kafkaReqProducer.sendRequestToQueue(Consts.ACCOUNT_NEW_SDF01, createAccountsRequest(statementRequest.getGroupId(), res.getAccountRequests()));
|
||||
kafkaReqProducer.sendRequestToQueue(Consts.CLEARING_ACCOUNT_NEW_SDF01, createAccountsRequest(statementRequest.getGroupId(), res.getAccountRequests()));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -130,7 +130,7 @@ class StatementServiceServiceTest extends AbstractServiceTest {
|
|||
BaseRequest<Object> baseRequest = (BaseRequest<Object>) producerRecord.getValue().value();
|
||||
RequestInfo resultRequestInfo = requestInfoImdg.getSingleObjectByID(baseRequest.getId());
|
||||
|
||||
assertEquals(Consts.ACCOUNT_NEW_SDF01, producerRecord.getValue().topic());
|
||||
assertEquals(Consts.CLEARING_ACCOUNT_NEW_SDF01, producerRecord.getValue().topic());
|
||||
assertNotNull(baseRequest);
|
||||
assertNotNull(resultRequestInfo);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -54,16 +54,17 @@ public interface Consts {
|
|||
String DESTINATION_CLEARING_MEMBER_CATEGORY_UPDATE = "clearing-member-category-update";
|
||||
String DESTINATION_CLEARING_MEMBER_CATEGORY_DELETE = "clearing-member-category-delete";
|
||||
|
||||
String DESTINATION_ACCOUNT_DELETE = "account-delete";
|
||||
String DESTINATION_ACCOUNT_UPDATE = "account-update";
|
||||
String DESTINATION_ACCOUNT_NEW = "account-new";
|
||||
|
||||
String DESTINATION_CORRESPONDENT_ACCOUNT_NEW = "correspondent-account-new";
|
||||
String DESTINATION_CORRESPONDENT_ACCOUNT_UPDATE = "correspondent-account-update";
|
||||
String DESTINATION_CORRESPONDENT_ACCOUNT_BLOCK = "correspondent-account-block";
|
||||
|
||||
String DESTINATION_BANK_ACCOUNT_DELETE = "bank-account-delete";
|
||||
String DESTINATION_BANK_ACCOUNT_UPDATE = "bank-account-update";
|
||||
String DESTINATION_BANK_ACCOUNT_NEW = "bank-account-new";
|
||||
|
||||
String DESTINATION_ACCOUNT_CORRESPONDENT_NEW = "account-correspondent-new";
|
||||
String DESTINATION_ACCOUNT_CORRESPONDENT_UPDATE = "account-correspondent-update";
|
||||
String DESTINATION_ACCOUNT_CORRESPONDENT_BLOCK = "account-correspondent-block";
|
||||
String CLEARING_ACCOUNT_NEW_SDF01 = "clearing-account-new-sdf01";
|
||||
String CLEARING_ACCOUNT_UPDATE_SDF52 = "clearing-account-update-sdf52";
|
||||
|
||||
String DESTINATION_RELATION_UPDATE = "relation-update";
|
||||
String DESTINATION_PROFILE_DOCUMENT_NEW = "profile-document-new";
|
||||
|
|
@ -91,7 +92,6 @@ public interface Consts {
|
|||
String SDF03_PROCESS = "sdf03-process";
|
||||
String SDF11_PROCESS = "sdf11-process";
|
||||
String EXPORT_PROCESS = "export-process";
|
||||
String ACCOUNT_NEW_SDF01 = "account-new-sdf01";
|
||||
String ACCOUNT_TERMINATION = "account-termination";
|
||||
String BALANCE_ACCOUNT_NEW = "balance-account-new";
|
||||
String BALANCE_ACCOUNT_UPDATE = "balance-account-update";
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ package ru.spcex.clearing.platform.messaging.domain.cud.account;
|
|||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
public class AccountCorrespondentNewRequest {
|
||||
public class CorrespondentAccountNewRequest {
|
||||
@JsonProperty
|
||||
public Long companyId;
|
||||
|
||||
|
|
@ -2,7 +2,7 @@ package ru.spcex.clearing.platform.messaging.domain.cud.account;
|
|||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
public class AccountCorrespondentUpdateRequest {
|
||||
public class CorrespondentAccountUpdateRequest {
|
||||
@JsonProperty
|
||||
public Long id;
|
||||
|
||||
Loading…
Add table
Reference in a new issue