Updated PendingDepositApplicationsService from Rest Template to Web Client

WebClient
parent a13f5643b9
commit 7300455f96

@ -1,10 +1,10 @@
package com.mfsys.aconnect.client.service; package com.mfsys.aconnect.client.service;
import com.mfsys.aconnect.client.dto.*; import com.mfsys.aconnect.client.dto.*;
import com.mfsys.aconnect.configuration.config.WebClientConfig;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.*; import org.springframework.http.*;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -16,9 +16,10 @@ public class PendingDepositApplicationsService {
@Value("${app.deposit.uri}") @Value("${app.deposit.uri}")
private String depositURI; private String depositURI;
private final RestTemplate restTemplate; private final WebClientConfig webClientConfig;
public PendingDepositApplicationsService(WebClientConfig webClientConfig) {
public PendingDepositApplicationsService(RestTemplate restTemplate) {this.restTemplate = restTemplate;} this.webClientConfig = webClientConfig;
}
private Map<String, Object> param(String columnName, Object columnValue, String columnType, String conditionType) { private Map<String, Object> param(String columnName, Object columnValue, String columnType, String conditionType) {
return Map.of("columnName", columnName, "columnValue", columnValue, return Map.of("columnName", columnName, "columnValue", columnValue,
@ -196,13 +197,10 @@ public class PendingDepositApplicationsService {
headers.set("SUS_USERCODE", susUserCode); headers.set("SUS_USERCODE", susUserCode);
headers.setContentType(MediaType.APPLICATION_JSON); headers.setContentType(MediaType.APPLICATION_JSON);
HttpEntity<LazyListRequestDTO> entity = new HttpEntity<>(payload, headers); return webClientConfig.postForString(
return restTemplate.exchange(
url, url,
HttpMethod.POST, payload,
entity, headers
String.class
); );
} }
@ -219,13 +217,10 @@ public class PendingDepositApplicationsService {
headers.set("SUS_USERCODE", susUserCode); headers.set("SUS_USERCODE", susUserCode);
headers.setContentType(MediaType.APPLICATION_JSON); headers.setContentType(MediaType.APPLICATION_JSON);
HttpEntity<LazyListRequestDTO> entity = new HttpEntity<>(payload, headers); return webClientConfig.postForString(
return restTemplate.exchange(
url, url,
HttpMethod.POST, payload,
entity, headers
String.class
); );
} }
@ -259,11 +254,10 @@ public class PendingDepositApplicationsService {
headers.set("SUS_USERCODE", susUserCode); headers.set("SUS_USERCODE", susUserCode);
headers.setContentType(MediaType.APPLICATION_JSON); headers.setContentType(MediaType.APPLICATION_JSON);
return restTemplate.exchange( return webClientConfig.postForString(
url, url,
HttpMethod.POST, dto,
new HttpEntity<>(dto, headers), headers
String.class
); );
} }
@ -296,11 +290,10 @@ public class PendingDepositApplicationsService {
headers.set("SUS_USERCODE", susUserCode); headers.set("SUS_USERCODE", susUserCode);
headers.setContentType(MediaType.APPLICATION_JSON); headers.setContentType(MediaType.APPLICATION_JSON);
return restTemplate.exchange( return webClientConfig.postForString(
url, url,
HttpMethod.POST, dto,
new HttpEntity<>(dto, headers), headers
String.class
); );
} }

Loading…
Cancel
Save