Add deposit and loan account services and update controllers
Introduced DepositAccountService and LoanAccountService for handling deposit and loan account operations. Updated DepositAccountController and LoanAccountController to use these services and added new endpoints for individual and business deposit/loan creation and approval. Added RestTemplate configuration and updated AconnectURI and TokenBypassURI constants. Modified PermissionDTO to use a String for permissions and adjusted UserService accordingly. Increased requestBody column length in Logger entity. Added Apache HttpClient5 dependency.ACONNECT-DEPOSITACCOUNT-API
parent
2426fb7c7e
commit
63f10ef2fc
@ -1,7 +1,38 @@
|
|||||||
package com.mfsys.aconnect.client.controller;
|
package com.mfsys.aconnect.client.controller;
|
||||||
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import com.mfsys.aconnect.client.dto.WorkflowRequestDTO;
|
||||||
|
import com.mfsys.aconnect.client.service.CRMService;
|
||||||
|
import com.mfsys.aconnect.client.service.DepositAccountService;
|
||||||
|
import com.mfsys.common.configuration.constant.AconnectURI;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
public class DepositAccountController {
|
public class DepositAccountController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private DepositAccountService depositAccountService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
public DepositAccountController(DepositAccountService depositAccountService) {
|
||||||
|
this.depositAccountService = depositAccountService;
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping(AconnectURI.INDIVIDUAL_DEPOSIT_CREATION_URI)
|
||||||
|
public Object createIndividualDeposit(@RequestBody WorkflowRequestDTO workflowRequestDTO,
|
||||||
|
@RequestHeader("Authorization") String token) {
|
||||||
|
return depositAccountService.createIndividualDeposit(workflowRequestDTO, token);
|
||||||
|
}
|
||||||
|
|
||||||
|
@PatchMapping(AconnectURI.UPDATE_DEPOSIT_CREATION_URI)
|
||||||
|
public Object updateIndividualDeposit(@RequestBody WorkflowRequestDTO workflowRequestDTO,
|
||||||
|
@RequestHeader("Authorization") String token) {
|
||||||
|
return depositAccountService.approvalIndividualDeposit(workflowRequestDTO, token);
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping(AconnectURI.BUSINESS_DEPOSIT_CREATION_URI)
|
||||||
|
public Object createBusinessCRM(@RequestBody WorkflowRequestDTO workflowRequestDTO,
|
||||||
|
@RequestHeader("Authorization") String token) {
|
||||||
|
return depositAccountService.createBusinessDeposit(workflowRequestDTO, token);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,7 +1,30 @@
|
|||||||
package com.mfsys.aconnect.client.controller;
|
package com.mfsys.aconnect.client.controller;
|
||||||
|
|
||||||
|
import com.mfsys.aconnect.client.dto.WorkflowRequestDTO;
|
||||||
|
import com.mfsys.aconnect.client.service.DepositAccountService;
|
||||||
|
import com.mfsys.aconnect.client.service.LoanAccountService;
|
||||||
|
import com.mfsys.common.configuration.constant.AconnectURI;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RequestHeader;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
public class LoanAccountController {
|
public class LoanAccountController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private LoanAccountService loanAccountService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
public LoanAccountController(LoanAccountService loanAccountService) {
|
||||||
|
this.loanAccountService = loanAccountService;
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping(AconnectURI.INDIVIDUAL_LOAN_CREATION_URI)
|
||||||
|
public Object createIndividualCRM(@RequestBody WorkflowRequestDTO workflowRequestDTO,
|
||||||
|
@RequestHeader("Authorization") String token) {
|
||||||
|
return loanAccountService.createIndividualLoan(workflowRequestDTO, token);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,88 @@
|
|||||||
|
package com.mfsys.aconnect.client.service;
|
||||||
|
|
||||||
|
import com.mfsys.aconnect.client.dto.WorkflowRequestDTO;
|
||||||
|
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 {
|
||||||
|
|
||||||
|
@Value("${app.deposit.uri}")
|
||||||
|
private String depositURI;
|
||||||
|
|
||||||
|
|
||||||
|
private final RestTemplate restTemplate;
|
||||||
|
public DepositAccountService(RestTemplate restTemplate) {
|
||||||
|
this.restTemplate = restTemplate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Object createIndividualDeposit(WorkflowRequestDTO workflowRequestDTO, String token) {
|
||||||
|
String porOrgacode = workflowRequestDTO.getPorOrgacode();
|
||||||
|
String url = depositURI + "/deposit" + "/mongodb/formdata" ;
|
||||||
|
HttpHeaders headers = new HttpHeaders();
|
||||||
|
headers.set("Authorization", token);
|
||||||
|
headers.set("POR_ORGACODE", porOrgacode);
|
||||||
|
headers.set("SUS_USERCODE", workflowRequestDTO.getSusUsercode());
|
||||||
|
headers.setContentType(MediaType.APPLICATION_JSON);
|
||||||
|
|
||||||
|
HttpEntity<WorkflowRequestDTO> entity = new HttpEntity<>(workflowRequestDTO, headers);
|
||||||
|
|
||||||
|
ResponseEntity<Map> response = restTemplate.exchange(
|
||||||
|
url,
|
||||||
|
HttpMethod.POST,
|
||||||
|
entity,
|
||||||
|
Map.class
|
||||||
|
);
|
||||||
|
|
||||||
|
return ResponseEntity.status(response.getStatusCode()).body(response.getBody());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public Object approvalIndividualDeposit(WorkflowRequestDTO workflowRequestDTO, String token) {
|
||||||
|
String porOrgacode = workflowRequestDTO.getPorOrgacode();
|
||||||
|
String url = depositURI + "/deposit" + "/mongodb/formdata" ;
|
||||||
|
HttpHeaders headers = new HttpHeaders();
|
||||||
|
headers.set("Authorization", token);
|
||||||
|
headers.set("POR_ORGACODE", porOrgacode);
|
||||||
|
headers.set("SUS_USERCODE", workflowRequestDTO.getSusUsercode());
|
||||||
|
headers.setContentType(MediaType.APPLICATION_JSON);
|
||||||
|
|
||||||
|
HttpEntity<WorkflowRequestDTO> entity = new HttpEntity<>(workflowRequestDTO, headers);
|
||||||
|
restTemplate.setRequestFactory(new HttpComponentsClientHttpRequestFactory());
|
||||||
|
|
||||||
|
ResponseEntity<Map> response = restTemplate.exchange(
|
||||||
|
url,
|
||||||
|
HttpMethod.PATCH,
|
||||||
|
entity,
|
||||||
|
Map.class
|
||||||
|
);
|
||||||
|
|
||||||
|
return ResponseEntity.status(response.getStatusCode()).body(response.getBody());
|
||||||
|
}
|
||||||
|
|
||||||
|
public Object createBusinessDeposit(WorkflowRequestDTO workflowRequestDTO, String token) {
|
||||||
|
String porOrgacode = workflowRequestDTO.getPorOrgacode();
|
||||||
|
String url = depositURI + "/deposit" + "/mongodb/formdata" ;
|
||||||
|
HttpHeaders headers = new HttpHeaders();
|
||||||
|
headers.set("Authorization", token);
|
||||||
|
headers.set("POR_ORGACODE", porOrgacode);
|
||||||
|
headers.set("SUS_USERCODE", workflowRequestDTO.getSusUsercode());
|
||||||
|
headers.setContentType(MediaType.APPLICATION_JSON);
|
||||||
|
|
||||||
|
HttpEntity<WorkflowRequestDTO> entity = new HttpEntity<>(workflowRequestDTO, headers);
|
||||||
|
|
||||||
|
ResponseEntity<Map> response = restTemplate.exchange(
|
||||||
|
url,
|
||||||
|
HttpMethod.POST,
|
||||||
|
entity,
|
||||||
|
Map.class
|
||||||
|
);
|
||||||
|
|
||||||
|
return ResponseEntity.status(response.getStatusCode()).body(response.getBody());
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,41 @@
|
|||||||
|
package com.mfsys.aconnect.client.service;
|
||||||
|
|
||||||
|
import com.mfsys.aconnect.client.dto.WorkflowRequestDTO;
|
||||||
|
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 {
|
||||||
|
|
||||||
|
@Value("${app.loan.uri}")
|
||||||
|
private String loanURI;
|
||||||
|
|
||||||
|
private final RestTemplate restTemplate = new RestTemplate();
|
||||||
|
|
||||||
|
|
||||||
|
public Object createIndividualLoan(WorkflowRequestDTO workflowRequestDTO, String token) {
|
||||||
|
String porOrgacode = workflowRequestDTO.getPorOrgacode();
|
||||||
|
String url = loanURI + "/loan" + "/mongodb/formdata" ;
|
||||||
|
HttpHeaders headers = new HttpHeaders();
|
||||||
|
headers.set("Authorization", token);
|
||||||
|
headers.set("POR_ORGACODE", porOrgacode);
|
||||||
|
headers.set("SUS_USERCODE", workflowRequestDTO.getSusUsercode());
|
||||||
|
headers.setContentType(MediaType.APPLICATION_JSON);
|
||||||
|
|
||||||
|
HttpEntity<WorkflowRequestDTO> entity = new HttpEntity<>(workflowRequestDTO, headers);
|
||||||
|
|
||||||
|
ResponseEntity<Map> response = restTemplate.exchange(
|
||||||
|
url,
|
||||||
|
HttpMethod.POST,
|
||||||
|
entity,
|
||||||
|
Map.class
|
||||||
|
);
|
||||||
|
|
||||||
|
return ResponseEntity.status(response.getStatusCode()).body(response.getBody());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,15 @@
|
|||||||
|
package com.mfsys.aconnect.configuration.config;
|
||||||
|
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
|
||||||
|
import org.springframework.web.client.RestTemplate;
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
public class RestTemplateConfig {
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public RestTemplate restTemplate() {
|
||||||
|
return new RestTemplate(new HttpComponentsClientHttpRequestFactory());
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue