|
|
|
|
@ -2,12 +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.stereotype.Service;
|
|
|
|
|
import org.springframework.web.client.RestTemplate;
|
|
|
|
|
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
|
|
@Service
|
|
|
|
|
public class LoanAccountService {
|
|
|
|
|
@ -15,9 +13,9 @@ public class LoanAccountService {
|
|
|
|
|
@Value("${app.loan.uri}")
|
|
|
|
|
private String loanURI;
|
|
|
|
|
|
|
|
|
|
private final RestTemplate restTemplate;
|
|
|
|
|
public LoanAccountService(RestTemplate restTemplate) {
|
|
|
|
|
this.restTemplate = restTemplate;
|
|
|
|
|
private final WebClientConfig webClientConfig;
|
|
|
|
|
public LoanAccountService(WebClientConfig webClientConfig) {
|
|
|
|
|
this.webClientConfig = webClientConfig;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Object createIndividualLoan(WorkflowRequestDTO workflowRequestDTO, String token) {
|
|
|
|
|
@ -29,16 +27,12 @@ public class LoanAccountService {
|
|
|
|
|
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();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Object approvalIndividualLoan(WorkflowApprovalDTO workflowRequestDTO, String token) {
|
|
|
|
|
@ -50,16 +44,12 @@ public class LoanAccountService {
|
|
|
|
|
headers.set("SUS_USERCODE", workflowRequestDTO.getSusUserCode());
|
|
|
|
|
headers.setContentType(MediaType.APPLICATION_JSON);
|
|
|
|
|
|
|
|
|
|
HttpEntity<WorkflowApprovalDTO> entity = new HttpEntity<>(workflowRequestDTO, headers);
|
|
|
|
|
|
|
|
|
|
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();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|