account-service http://jira.mfd.msk:8088/browse/CLS-577 улучшил текст валидации

This commit is contained in:
AKurakin 2023-11-01 13:57:02 +03:00
parent afeede8baa
commit 31de64e5bb

View file

@ -49,7 +49,7 @@ public class AccountSymbolsValidationConfig {
if (AccountType.Depo.equalsByKey(account.getAccountType())) {
return null;
} else {
return AccountError.AccountDepoTypeRequired;//todo data.xml!!!
return AccountError.AccountDepoTypeRequired;
}
}
),
@ -78,7 +78,23 @@ public class AccountSymbolsValidationConfig {
return empty();
} else {
AccountSymbols existAS = existAccSymbols.iterator().next();
return of(AccountError.AccountAlreadyExist, existAS.getAccountId() + "," + existAS.getAccountSymbolValue());
String duplicateMsg = "";
if (validatedObject.getAccountId() != null && validatedObject.getAccountId().equals(existAS.getAccountId())) {
Imdg<Account> accountImdg = context.obtainMap(IMDGDistributedNames.Map_Account, Account.class);
Account linkedAccount = accountImdg.getSingleObjectByID(existAS.getAccountId());
if (linkedAccount != null) {
duplicateMsg = linkedAccount.getAccount();
} else {
duplicateMsg = "" + existAS.getAccountId();
}
}
if (validatedObject.getAccountSymbolValue() != null &&
validatedObject.getAccountSymbolValue().equals(existAS.getAccountSymbolValue())) {
if (!duplicateMsg.isEmpty())
duplicateMsg += ", ";
duplicateMsg += existAS.getAccountSymbolValue();
}
return of(AccountError.AccountAlreadyExist, duplicateMsg);
}
}
}