|
|
|
|
@ -2,12 +2,10 @@ package com.mfsys.aconnect.client.service;
|
|
|
|
|
|
|
|
|
|
import com.mfsys.aconnect.client.dto.DepositCancellationDTO;
|
|
|
|
|
import com.mfsys.aconnect.client.dto.GLCancellationDTO;
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
|
|
import static com.mfsys.common.configuration.constant.AconnectURI.ACONNECT;
|
|
|
|
|
import static com.mfsys.common.configuration.constant.AconnectURI.GENERALLEDGER;
|
|
|
|
|
@ -21,12 +19,12 @@ public class CancellationTransactionService {
|
|
|
|
|
@Value("${app.generalledger.uri}")
|
|
|
|
|
private String generalledgerURI;
|
|
|
|
|
|
|
|
|
|
private final RestTemplate restTemplate;
|
|
|
|
|
public CancellationTransactionService(RestTemplate restTemplate) {
|
|
|
|
|
this.restTemplate = restTemplate;
|
|
|
|
|
private final WebClientConfig webClientConfig;
|
|
|
|
|
public CancellationTransactionService(WebClientConfig webClientConfig) {
|
|
|
|
|
this.webClientConfig = webClientConfig;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Object processDepositCancellationTransaction(DepositCancellationDTO depositCancellationDTO, String tokenHeader) {
|
|
|
|
|
public ResponseEntity<Object> processDepositCancellationTransaction(DepositCancellationDTO depositCancellationDTO, String tokenHeader) {
|
|
|
|
|
String porOrgacode = depositCancellationDTO.getPorOrgacode();
|
|
|
|
|
String url = depositURI + "/deposit" + "/organizations/" + depositCancellationDTO.getPorOrgacode() +
|
|
|
|
|
"/transactions" + ACONNECT + "/cancel/nodes/" + depositCancellationDTO.getNodeId() +
|
|
|
|
|
@ -37,20 +35,16 @@ public class CancellationTransactionService {
|
|
|
|
|
headers.set("POR_ORGACODE", porOrgacode);
|
|
|
|
|
headers.set("SUS_USERCODE", depositCancellationDTO.getSusUsercode());
|
|
|
|
|
headers.setContentType(MediaType.APPLICATION_JSON);
|
|
|
|
|
headers.setAccept(java.util.List.of(MediaType.APPLICATION_JSON));
|
|
|
|
|
|
|
|
|
|
HttpEntity<DepositCancellationDTO> entity = new HttpEntity<>(depositCancellationDTO, headers);
|
|
|
|
|
|
|
|
|
|
ResponseEntity<Map> response = restTemplate.exchange(
|
|
|
|
|
return webClientConfig.post(
|
|
|
|
|
url,
|
|
|
|
|
HttpMethod.POST,
|
|
|
|
|
entity,
|
|
|
|
|
Map.class
|
|
|
|
|
depositCancellationDTO,
|
|
|
|
|
headers
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
return ResponseEntity.status(response.getStatusCode()).body(response.getBody());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Object processGLCancellationTransaction(GLCancellationDTO glCancellationDTO, String tokenHeader) {
|
|
|
|
|
public ResponseEntity<Object> processGLCancellationTransaction(GLCancellationDTO glCancellationDTO, String tokenHeader) {
|
|
|
|
|
String porOrgacode = glCancellationDTO.getPorOrgacode();
|
|
|
|
|
String url = generalledgerURI + GENERALLEDGER + "/organizations/" + glCancellationDTO.getPorOrgacode() +
|
|
|
|
|
"/transactions" + ACONNECT + "/cancel/nodes/" + glCancellationDTO.getNodeId() +
|
|
|
|
|
@ -61,16 +55,13 @@ public class CancellationTransactionService {
|
|
|
|
|
headers.set("POR_ORGACODE", porOrgacode);
|
|
|
|
|
headers.set("SUS_USERCODE", glCancellationDTO.getSusUsercode());
|
|
|
|
|
headers.setContentType(MediaType.APPLICATION_JSON);
|
|
|
|
|
headers.setAccept(java.util.List.of(MediaType.APPLICATION_JSON));
|
|
|
|
|
|
|
|
|
|
HttpEntity<GLCancellationDTO> entity = new HttpEntity<>(glCancellationDTO, headers);
|
|
|
|
|
ResponseEntity<Map> response = restTemplate.exchange(
|
|
|
|
|
return webClientConfig.post(
|
|
|
|
|
url,
|
|
|
|
|
HttpMethod.POST,
|
|
|
|
|
entity,
|
|
|
|
|
Map.class
|
|
|
|
|
glCancellationDTO,
|
|
|
|
|
headers
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
return ResponseEntity.status(response.getStatusCode()).body(response.getBody());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|