add new fields
This commit is contained in:
parent
69e815f984
commit
224179a9e1
7 changed files with 75 additions and 5 deletions
|
|
@ -4,6 +4,8 @@ import java.util.List;
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
|
||||||
public class InfoAccount {
|
public class InfoAccount {
|
||||||
|
@JsonProperty("type_operation_client")
|
||||||
|
private String typeOperationClient;
|
||||||
@JsonProperty("company_id")
|
@JsonProperty("company_id")
|
||||||
private String companyId;
|
private String companyId;
|
||||||
@JsonProperty("trading_code")
|
@JsonProperty("trading_code")
|
||||||
|
|
@ -19,6 +21,14 @@ public class InfoAccount {
|
||||||
@JsonProperty("money_account")
|
@JsonProperty("money_account")
|
||||||
private List<MoneyAccount> moneyAccounts;
|
private List<MoneyAccount> moneyAccounts;
|
||||||
|
|
||||||
|
public String getTypeOperationClient() {
|
||||||
|
return typeOperationClient;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTypeOperationClient(String typeOperationClient) {
|
||||||
|
this.typeOperationClient = typeOperationClient;
|
||||||
|
}
|
||||||
|
|
||||||
public String getCompanyId() {
|
public String getCompanyId() {
|
||||||
return companyId;
|
return companyId;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,8 @@ public class MoneyAccount {
|
||||||
private String currCode;
|
private String currCode;
|
||||||
@JsonProperty("account")
|
@JsonProperty("account")
|
||||||
private String account;
|
private String account;
|
||||||
|
@JsonProperty("status")
|
||||||
|
private String status;
|
||||||
|
|
||||||
public String getCurrCode() {
|
public String getCurrCode() {
|
||||||
return currCode;
|
return currCode;
|
||||||
|
|
@ -23,4 +25,12 @@ public class MoneyAccount {
|
||||||
public void setAccount(String account) {
|
public void setAccount(String account) {
|
||||||
this.account = account;
|
this.account = account;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getStatus() {
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStatus(String status) {
|
||||||
|
this.status = status;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,25 @@
|
||||||
|
package ru.spcex.clearing.gatewayapi.enums;
|
||||||
|
|
||||||
|
import ru.spcex.platform.utils.enumeration.IEnumKey;
|
||||||
|
|
||||||
|
public enum TypeOperations implements IEnumKey{
|
||||||
|
CHECK("CHECK"),
|
||||||
|
ADD("ADD"),
|
||||||
|
UPDATE("UPD");
|
||||||
|
|
||||||
|
private final String key;
|
||||||
|
|
||||||
|
TypeOperations(String key) {
|
||||||
|
this.key = key;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getKey() {
|
||||||
|
return this.key;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equalsByKey(String key) {
|
||||||
|
return IEnumKey.super.equalsByKey(key);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,9 +1,10 @@
|
||||||
package ru.spcex.clearing.gatewayapi.service;
|
package ru.spcex.clearing.gatewayapi.service;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.util.StringUtils;
|
|
||||||
import ru.spcex.clearing.gatewayapi.controller.inbound.request.tkr.request.TkrRequest;
|
import ru.spcex.clearing.gatewayapi.controller.inbound.request.tkr.request.TkrRequest;
|
||||||
|
import ru.spcex.clearing.gatewayapi.enums.TypeOperations;
|
||||||
import ru.spcex.clearing.gatewayapi.service.adapter.TkrAdapter;
|
import ru.spcex.clearing.gatewayapi.service.adapter.TkrAdapter;
|
||||||
import ru.spcex.clearing.platform.messaging.domain.Consts;
|
import ru.spcex.clearing.platform.messaging.domain.Consts;
|
||||||
import ru.spcex.clearing.platform.messaging.domain.cud.account.TkrAccount;
|
import ru.spcex.clearing.platform.messaging.domain.cud.account.TkrAccount;
|
||||||
|
|
@ -23,12 +24,16 @@ public class TkrService {
|
||||||
|
|
||||||
public void processedTkrRequest(TkrRequest tkrRequest) {
|
public void processedTkrRequest(TkrRequest tkrRequest) {
|
||||||
List<TkrAccount> tkrAccountsForCheck = tkrRequest.getInfoAccount()
|
List<TkrAccount> tkrAccountsForCheck = tkrRequest.getInfoAccount()
|
||||||
.stream().filter(infoAccount -> !StringUtils.hasText(infoAccount.getClientCode()))
|
.stream().filter(infoAccount -> TypeOperations.CHECK.equalsByKey(infoAccount.getTypeOperationClient()))
|
||||||
.map(tkrAdapter::toTkrResponse).toList();
|
.map(tkrAdapter::toTkrResponse)
|
||||||
|
.filter(Objects::nonNull)
|
||||||
|
.toList();
|
||||||
|
|
||||||
List<TkrAccount> tkrAccountsForNew = tkrRequest.getInfoAccount()
|
List<TkrAccount> tkrAccountsForNew = tkrRequest.getInfoAccount()
|
||||||
.stream().filter(infoAccount -> !StringUtils.hasText(infoAccount.getTkrCode()))
|
.stream().filter(infoAccount -> TypeOperations.ADD.equalsByKey(infoAccount.getTypeOperationClient()))
|
||||||
.map(tkrAdapter::toTkrResponse).toList();
|
.map(tkrAdapter::toTkrResponse)
|
||||||
|
.filter(Objects::nonNull)
|
||||||
|
.toList();
|
||||||
|
|
||||||
if (!tkrAccountsForCheck.isEmpty()) {
|
if (!tkrAccountsForCheck.isEmpty()) {
|
||||||
TkrAccountsGatewayRequest tkrAccountsRequest = new TkrAccountsGatewayRequest();
|
TkrAccountsGatewayRequest tkrAccountsRequest = new TkrAccountsGatewayRequest();
|
||||||
|
|
|
||||||
|
|
@ -1,22 +1,38 @@
|
||||||
package ru.spcex.clearing.gatewayapi.service.adapter;
|
package ru.spcex.clearing.gatewayapi.service.adapter;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.util.StringUtils;
|
||||||
import ru.spcex.clearing.gatewayapi.controller.inbound.request.tkr.request.InfoAccount;
|
import ru.spcex.clearing.gatewayapi.controller.inbound.request.tkr.request.InfoAccount;
|
||||||
import ru.spcex.clearing.gatewayapi.controller.inbound.request.tkr.request.MoneyAccount;
|
import ru.spcex.clearing.gatewayapi.controller.inbound.request.tkr.request.MoneyAccount;
|
||||||
|
import ru.spcex.clearing.gatewayapi.enums.TypeOperations;
|
||||||
import ru.spcex.clearing.platform.messaging.domain.cud.gateway.MoneyAccountMsg;
|
import ru.spcex.clearing.platform.messaging.domain.cud.gateway.MoneyAccountMsg;
|
||||||
import ru.spcex.clearing.platform.messaging.domain.cud.account.TkrAccount;
|
import ru.spcex.clearing.platform.messaging.domain.cud.account.TkrAccount;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class TkrAdapter {
|
public class TkrAdapter {
|
||||||
|
private final Logger log = LoggerFactory.getLogger(getClass());
|
||||||
public TkrAccount toTkrResponse(InfoAccount infoAccount) {
|
public TkrAccount toTkrResponse(InfoAccount infoAccount) {
|
||||||
TkrAccount tkrResponse = new TkrAccount();
|
TkrAccount tkrResponse = new TkrAccount();
|
||||||
tkrResponse.setCompanyId(infoAccount.getCompanyId());
|
tkrResponse.setCompanyId(infoAccount.getCompanyId());
|
||||||
tkrResponse.setTradingCode(infoAccount.getTradingCode());
|
tkrResponse.setTradingCode(infoAccount.getTradingCode());
|
||||||
tkrResponse.setClientCode(infoAccount.getClientCode());
|
tkrResponse.setClientCode(infoAccount.getClientCode());
|
||||||
tkrResponse.setEnabled(infoAccount.getEnabled());
|
tkrResponse.setEnabled(infoAccount.getEnabled());
|
||||||
|
if (TypeOperations.CHECK.equalsByKey(infoAccount.getTypeOperationClient()) &&
|
||||||
|
!StringUtils.hasText(infoAccount.getTkrCode())){
|
||||||
|
log.warn("For check action trk_code is required, skip this account.client_code: {}", infoAccount.getClientCode());
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
if (TypeOperations.ADD.equalsByKey(infoAccount.getTypeOperationClient()) &&
|
||||||
|
!StringUtils.hasText(infoAccount.getClientCode())){
|
||||||
|
log.warn("For check action client_code is required, skip this account.tkr_code: {}", infoAccount.getTkrCode());
|
||||||
|
return null;
|
||||||
|
}
|
||||||
tkrResponse.setTkrCode(infoAccount.getTkrCode());
|
tkrResponse.setTkrCode(infoAccount.getTkrCode());
|
||||||
tkrResponse.setDepoAccount(infoAccount.getDepoAccount());
|
tkrResponse.setDepoAccount(infoAccount.getDepoAccount());
|
||||||
|
|
||||||
if (infoAccount.getMoneyAccounts() != null) {
|
if (infoAccount.getMoneyAccounts() != null) {
|
||||||
List<MoneyAccountMsg> moneyAccountMsgs = infoAccount.getMoneyAccounts().stream()
|
List<MoneyAccountMsg> moneyAccountMsgs = infoAccount.getMoneyAccounts().stream()
|
||||||
.map(this::toMoneyAccountMsg).toList();
|
.map(this::toMoneyAccountMsg).toList();
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,8 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
import ru.spcex.clearing.platform.messaging.domain.cud.gateway.MoneyAccountMsg;
|
import ru.spcex.clearing.platform.messaging.domain.cud.gateway.MoneyAccountMsg;
|
||||||
|
|
||||||
public class TkrAccount {
|
public class TkrAccount {
|
||||||
|
@JsonProperty
|
||||||
|
private String typeOperationClient;
|
||||||
@JsonProperty
|
@JsonProperty
|
||||||
private String companyId;
|
private String companyId;
|
||||||
@JsonProperty
|
@JsonProperty
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,8 @@ public class MoneyAccountMsg {
|
||||||
private String currCode;
|
private String currCode;
|
||||||
@JsonProperty("account")
|
@JsonProperty("account")
|
||||||
private String account;
|
private String account;
|
||||||
|
@JsonProperty("status")
|
||||||
|
private String status;
|
||||||
|
|
||||||
public String getCurrCode() {
|
public String getCurrCode() {
|
||||||
return currCode;
|
return currCode;
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue