|
|
|
|
@ -2,13 +2,10 @@ package com.mfsys.aconnect.client.service;
|
|
|
|
|
|
|
|
|
|
import com.mfsys.aconnect.client.dto.WorkflowApprovalDTO;
|
|
|
|
|
import com.mfsys.aconnect.client.dto.WorkflowRequestDTO;
|
|
|
|
|
import com.mfsys.aconnect.configuration.config.WebClientConfig;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
|
|
import org.springframework.http.*;
|
|
|
|
|
import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
import org.springframework.web.client.RestTemplate;
|
|
|
|
|
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
|
|
@Service
|
|
|
|
|
public class DepositAccountService {
|
|
|
|
|
@ -16,10 +13,9 @@ public class DepositAccountService {
|
|
|
|
|
@Value("${app.deposit.uri}")
|
|
|
|
|
private String depositURI;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private final RestTemplate restTemplate;
|
|
|
|
|
public DepositAccountService(RestTemplate restTemplate) {
|
|
|
|
|
this.restTemplate = restTemplate;
|
|
|
|
|
private final WebClientConfig webClientConfig;
|
|
|
|
|
public DepositAccountService(WebClientConfig webClientConfig) {
|
|
|
|
|
this.webClientConfig = webClientConfig;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Object createIndividualDeposit(WorkflowRequestDTO workflowRequestDTO, String token) {
|
|
|
|
|
@ -31,16 +27,12 @@ public class DepositAccountService {
|
|
|
|
|
headers.set("SUS_USERCODE", workflowRequestDTO.getSusUsercode());
|
|
|
|
|
headers.setContentType(MediaType.APPLICATION_JSON);
|
|
|
|
|
|
|
|
|
|
HttpEntity<WorkflowRequestDTO> entity = new HttpEntity<>(workflowRequestDTO, headers);
|
|
|
|
|
|
|
|
|
|
ResponseEntity<Map> response = restTemplate.exchange(
|
|
|
|
|
return webClientConfig.post(
|
|
|
|
|
url,
|
|
|
|
|
HttpMethod.POST,
|
|
|
|
|
entity,
|
|
|
|
|
Map.class
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
return ResponseEntity.status(response.getStatusCode()).body(response.getBody());
|
|
|
|
|
workflowRequestDTO,
|
|
|
|
|
headers
|
|
|
|
|
)
|
|
|
|
|
.getBody();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -53,17 +45,12 @@ public class DepositAccountService {
|
|
|
|
|
headers.set("SUS_USERCODE", workflowRequestDTO.getSusUserCode());
|
|
|
|
|
headers.setContentType(MediaType.APPLICATION_JSON);
|
|
|
|
|
|
|
|
|
|
HttpEntity<WorkflowApprovalDTO> entity = new HttpEntity<>(workflowRequestDTO, headers);
|
|
|
|
|
restTemplate.setRequestFactory(new HttpComponentsClientHttpRequestFactory());
|
|
|
|
|
|
|
|
|
|
ResponseEntity<Map> response = restTemplate.exchange(
|
|
|
|
|
return webClientConfig.patch(
|
|
|
|
|
url,
|
|
|
|
|
HttpMethod.PATCH,
|
|
|
|
|
entity,
|
|
|
|
|
Map.class
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
return ResponseEntity.status(response.getStatusCode()).body(response.getBody());
|
|
|
|
|
workflowRequestDTO,
|
|
|
|
|
headers
|
|
|
|
|
)
|
|
|
|
|
.getBody();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Object createBusinessDeposit(WorkflowRequestDTO workflowRequestDTO, String token) {
|
|
|
|
|
@ -75,15 +62,11 @@ public class DepositAccountService {
|
|
|
|
|
headers.set("SUS_USERCODE", workflowRequestDTO.getSusUsercode());
|
|
|
|
|
headers.setContentType(MediaType.APPLICATION_JSON);
|
|
|
|
|
|
|
|
|
|
HttpEntity<WorkflowRequestDTO> entity = new HttpEntity<>(workflowRequestDTO, headers);
|
|
|
|
|
|
|
|
|
|
ResponseEntity<Map> response = restTemplate.exchange(
|
|
|
|
|
return webClientConfig.post(
|
|
|
|
|
url,
|
|
|
|
|
HttpMethod.POST,
|
|
|
|
|
entity,
|
|
|
|
|
Map.class
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
return ResponseEntity.status(response.getStatusCode()).body(response.getBody());
|
|
|
|
|
workflowRequestDTO,
|
|
|
|
|
headers
|
|
|
|
|
)
|
|
|
|
|
.getBody();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|