ACONNECT-CRM-API
#6
Open
naeem.ullah
wants to merge 2 commits from ACONNECT-CRM-API into FMFI-PRE-PRODUCTION
@ -0,0 +1,34 @@
|
|||||||
|
package com.mfsys.aconnect.client.controller;
|
||||||
|
|
||||||
|
import com.mfsys.aconnect.client.dto.WorkflowRequestDTO;
|
||||||
|
import com.mfsys.aconnect.client.service.CRMService;
|
||||||
|
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;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
public class CRMController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private CRMService crmService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
public CRMController(CRMService crmService) {
|
||||||
|
this.crmService = crmService;
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping(AconnectURI.INDIVIDUAL_CRM_CREATION_URI)
|
||||||
|
public Object createIndividualCRM(@RequestBody WorkflowRequestDTO workflowRequestDTO,
|
||||||
|
@RequestHeader("Authorization") String token) {
|
||||||
|
return crmService.createIndividualCRM(workflowRequestDTO, token);
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping(AconnectURI.BUSINESS_CRM_CREATION_URI)
|
||||||
|
public Object createBusinessCRM(@RequestBody WorkflowRequestDTO workflowRequestDTO,
|
||||||
|
@RequestHeader("Authorization") String token) {
|
||||||
|
return crmService.createBusinessCRM(workflowRequestDTO, token);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,7 @@
|
|||||||
|
package com.mfsys.aconnect.client.controller;
|
||||||
|
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
public class DepositAccountController {
|
||||||
|
}
|
||||||
@ -0,0 +1,7 @@
|
|||||||
|
package com.mfsys.aconnect.client.controller;
|
||||||
|
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
public class LoanAccountController {
|
||||||
|
}
|
||||||
@ -0,0 +1,35 @@
|
|||||||
|
package com.mfsys.aconnect.client.controller;
|
||||||
|
|
||||||
|
import com.mfsys.aconnect.client.dto.DepositAuthorizationRequest;
|
||||||
|
import com.mfsys.aconnect.client.dto.GLAuthorizationDTO;
|
||||||
|
import com.mfsys.aconnect.client.service.TransactionAuthorizationService;
|
||||||
|
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;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
public class TransactionAuthorizationController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private TransactionAuthorizationService transactionAuthorizationService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
public TransactionAuthorizationController(TransactionAuthorizationService transactionAuthorizationService) {
|
||||||
|
this.transactionAuthorizationService = transactionAuthorizationService;
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping(AconnectURI.DEPOSIT_AUTHORIZATION_URI)
|
||||||
|
public Object depositAuthorizationTransaction(@RequestBody DepositAuthorizationRequest authorizationRequest,
|
||||||
|
@RequestHeader("Authorization") String token) {
|
||||||
|
return transactionAuthorizationService.processDepositAuthTransaction(authorizationRequest, token);
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping(AconnectURI.GENERALLEDGER_AUTHORIZATION_URI)
|
||||||
|
public Object glAuthorizationTransaction(@RequestBody GLAuthorizationDTO glAuthorizationRequest,
|
||||||
|
@RequestHeader("Authorization") String token) {
|
||||||
|
return transactionAuthorizationService.processGLAuthTransaction(glAuthorizationRequest, token);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,36 @@
|
|||||||
|
package com.mfsys.aconnect.client.controller;
|
||||||
|
|
||||||
|
import com.mfsys.aconnect.client.dto.DepositCancellationDTO;
|
||||||
|
import com.mfsys.aconnect.client.dto.GLCancellationDTO;
|
||||||
|
import com.mfsys.aconnect.client.service.CancellationTransactionService;
|
||||||
|
import com.mfsys.aconnect.client.service.TransactionService;
|
||||||
|
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;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
public class TransactionCancellationController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private CancellationTransactionService cancellationTransactionService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
public TransactionCancellationController(CancellationTransactionService cancellationTransactionService) {
|
||||||
|
this.cancellationTransactionService = cancellationTransactionService;
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping(AconnectURI.DEPOSIT_CANCELLATION_URI)
|
||||||
|
public Object depositCancellationTransaction(@RequestBody DepositCancellationDTO depositCancellationDTO,
|
||||||
|
@RequestHeader("Authorization") String token) {
|
||||||
|
return cancellationTransactionService.processDepositCancellationTransaction(depositCancellationDTO, token);
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping(AconnectURI.GENERALLEDGER_CANCELLATION_URI)
|
||||||
|
public Object glCancellationTransaction(@RequestBody GLCancellationDTO glCancellationRequest,
|
||||||
|
@RequestHeader("Authorization") String token) {
|
||||||
|
return cancellationTransactionService.processGLCancellationTransaction(glCancellationRequest, token);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,35 @@
|
|||||||
|
package com.mfsys.aconnect.client.controller;
|
||||||
|
|
||||||
|
import com.mfsys.aconnect.client.dto.DepositRejectDTO;
|
||||||
|
import com.mfsys.aconnect.client.service.RejectTransactionService;
|
||||||
|
import com.mfsys.aconnect.client.service.TransactionService;
|
||||||
|
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;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
public class TransactionRejectController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private RejectTransactionService rejectTransactionService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
public TransactionRejectController(RejectTransactionService rejectTransactionService) {
|
||||||
|
this.rejectTransactionService = rejectTransactionService;
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping(AconnectURI.DEPOSIT_TRANSACTION_REJECT_URI)
|
||||||
|
public Object depositRejectionTransaction(@RequestBody DepositRejectDTO rejectRequest,
|
||||||
|
@RequestHeader("Authorization") String token) {
|
||||||
|
return rejectTransactionService.processDepositRejectionTransaction(rejectRequest, token);
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping(AconnectURI.GENERALLEDGER_TRANSACTION_REJECT_URI)
|
||||||
|
public Object glRejectionTransaction(@RequestBody DepositRejectDTO rejectRequest,
|
||||||
|
@RequestHeader("Authorization") String token) {
|
||||||
|
return rejectTransactionService.processGLRejectionTransaction(rejectRequest, token);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,36 @@
|
|||||||
|
package com.mfsys.aconnect.client.controller;
|
||||||
|
|
||||||
|
import com.mfsys.aconnect.client.dto.DepositReversalDTO;
|
||||||
|
import com.mfsys.aconnect.client.dto.GLReversalDTO;
|
||||||
|
import com.mfsys.aconnect.client.service.ReversalTransactionService;
|
||||||
|
import com.mfsys.aconnect.client.service.TransactionService;
|
||||||
|
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;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
public class TransactionReversalController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ReversalTransactionService reversalTransactionService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
public TransactionReversalController(ReversalTransactionService reversalTransactionService) {
|
||||||
|
this.reversalTransactionService = reversalTransactionService;
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping(AconnectURI.DEPOSIT_TRANSACTION_REVERSAL_URI)
|
||||||
|
public Object depositReversalTransaction(@RequestBody DepositReversalDTO depositReversalDTO,
|
||||||
|
@RequestHeader("Authorization") String token) {
|
||||||
|
return reversalTransactionService.processDepositReversalTransaction(depositReversalDTO, token);
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping(AconnectURI.GENERALLEDGER_TRANSACTION_REVERSAL_URI)
|
||||||
|
public Object glReversalTransaction(@RequestBody GLReversalDTO glReversalRequest,
|
||||||
|
@RequestHeader("Authorization") String token) {
|
||||||
|
return reversalTransactionService.processGLReversalTransaction(glReversalRequest, token);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,41 @@
|
|||||||
|
package com.mfsys.aconnect.client.dto;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.time.LocalDate;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class AccountToAccountDTO {
|
||||||
|
|
||||||
|
private AdditionalInfo additionalInfo;
|
||||||
|
|
||||||
|
private AccountTranInfo debitAcc;
|
||||||
|
private AccountTranInfo creditAcc;
|
||||||
|
|
||||||
|
private String plcLocacode;
|
||||||
|
private String porOrgacode;
|
||||||
|
private String ppmPymdcode;
|
||||||
|
private String sgtGntrcreateusr;
|
||||||
|
private String sgtGntrnarration;
|
||||||
|
private LocalDate sgtGntrvaluedate;
|
||||||
|
|
||||||
|
// ---------------- INNER CLASSES ----------------
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public static class AdditionalInfo {
|
||||||
|
private String sgtBnfowner;
|
||||||
|
private String sgtPrcRlcscodec;
|
||||||
|
private String sgtPtrtrancode;
|
||||||
|
private String sgtRelwithbnfowner;
|
||||||
|
private String sgtTranreason;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public static class AccountTranInfo {
|
||||||
|
private String mbmBkmsnumber;
|
||||||
|
private BigDecimal sgtGntramtfc;
|
||||||
|
private String pitInstcode;
|
||||||
|
private String sgtGntrinstrumentno;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,49 @@
|
|||||||
|
package com.mfsys.aconnect.client.dto;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class GlToAccountDTO {
|
||||||
|
|
||||||
|
private Map<String, Object> additionalInfo;
|
||||||
|
|
||||||
|
private DebitGl debitGl;
|
||||||
|
private CreditAcc creditAcc;
|
||||||
|
|
||||||
|
private String plcLocacode;
|
||||||
|
private String porOrgacode;
|
||||||
|
private String ppmPymdcode;
|
||||||
|
private String sgtGntrcreateusr;
|
||||||
|
private String sgtGntrnarration;
|
||||||
|
private LocalDate sgtGntrvaluedate;
|
||||||
|
|
||||||
|
private String sgtGntrtmudf1;
|
||||||
|
private String sgtGntrtmudf2;
|
||||||
|
private String sgtGntrudf3;
|
||||||
|
private String sgtGntrudf4;
|
||||||
|
private String sgtGntrudf5;
|
||||||
|
private String refNo;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public static class DebitGl {
|
||||||
|
private String pcaGlaccode;
|
||||||
|
private String plcLocacode;
|
||||||
|
private BigDecimal sgtGntramtfc;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public static class CreditAcc {
|
||||||
|
private String mbmBkmsnumber;
|
||||||
|
private BigDecimal sgtGntramtfc;
|
||||||
|
private String accsgtGntrnarration;
|
||||||
|
private String accsgtGntrudf3;
|
||||||
|
private String accsgtGntrudf4;
|
||||||
|
private String accsgtGntrudf5;
|
||||||
|
private String pitInstcode;
|
||||||
|
private String sgtGntrinstrumentno;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,39 @@
|
|||||||
|
package com.mfsys.aconnect.client.dto;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class WorkflowRequestDTO {
|
||||||
|
|
||||||
|
private String workFlowId;
|
||||||
|
|
||||||
|
@JsonProperty("SUS_USERCODE")
|
||||||
|
private String susUsercode;
|
||||||
|
|
||||||
|
private Map<String, Object> filesMap;
|
||||||
|
private List<AutoIncrementField> autoIncrementFields;
|
||||||
|
private String formId;
|
||||||
|
private String postProcessFormId;
|
||||||
|
private String payload;
|
||||||
|
private String operation;
|
||||||
|
|
||||||
|
@JsonProperty("POR_ORGACODE")
|
||||||
|
private String porOrgacode;
|
||||||
|
|
||||||
|
private List<List<String>> uniqueConstraints;
|
||||||
|
private List<Object> formCounters;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public static class AutoIncrementField {
|
||||||
|
private String key;
|
||||||
|
private String type;
|
||||||
|
private List<Object> position;
|
||||||
|
private Boolean incrementByCategoryTag;
|
||||||
|
private Boolean incrementIfFlowTerminated;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@ -0,0 +1,26 @@
|
|||||||
|
package com.mfsys.aconnect.client.model;
|
||||||
|
|
||||||
|
public enum IDType {
|
||||||
|
|
||||||
|
cnic("CNIC","01"),
|
||||||
|
poc("POC","04"),
|
||||||
|
nicop("NICOP","05"),
|
||||||
|
passport("PASSPORT","02");
|
||||||
|
|
||||||
|
private final String value;
|
||||||
|
private final String code;
|
||||||
|
|
||||||
|
IDType(String value, String code) {
|
||||||
|
this.value = value;
|
||||||
|
this.code = code;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getValue() {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getCode() {
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,61 @@
|
|||||||
|
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 CRMService {
|
||||||
|
|
||||||
|
@Value("${app.crm.uri}")
|
||||||
|
private String crmURI;
|
||||||
|
|
||||||
|
private final RestTemplate restTemplate = new RestTemplate();
|
||||||
|
public Object createIndividualCRM(WorkflowRequestDTO workflowRequestDTO, String token) {
|
||||||
|
String porOrgacode = workflowRequestDTO.getPorOrgacode();
|
||||||
|
String url = crmURI + "/crm" + "/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 createBusinessCRM(WorkflowRequestDTO workflowRequestDTO, String token) {
|
||||||
|
String porOrgacode = workflowRequestDTO.getPorOrgacode();
|
||||||
|
String url = crmURI + "/crm" + "/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,74 @@
|
|||||||
|
package com.mfsys.aconnect.client.service;
|
||||||
|
|
||||||
|
import com.mfsys.aconnect.client.dto.DepositCancellationDTO;
|
||||||
|
import com.mfsys.aconnect.client.dto.GLCancellationDTO;
|
||||||
|
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;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class CancellationTransactionService {
|
||||||
|
|
||||||
|
@Value("${app.deposit.uri}")
|
||||||
|
private String depositURI;
|
||||||
|
|
||||||
|
@Value("${app.generalledger.uri}")
|
||||||
|
private String generalledgerURI;
|
||||||
|
|
||||||
|
public Object processDepositCancellationTransaction(DepositCancellationDTO depositCancellationDTO, String tokenHeader) {
|
||||||
|
String porOrgacode = depositCancellationDTO.getPorOrgacode();
|
||||||
|
String url = depositURI + "/deposit" + "/organizations/" + depositCancellationDTO.getPorOrgacode() +
|
||||||
|
"/transactions" + ACONNECT + "/cancel/nodes/" + depositCancellationDTO.getNodeId() +
|
||||||
|
"/trannums/" + depositCancellationDTO.getSgtGntrtranlink();
|
||||||
|
|
||||||
|
HttpHeaders headers = new HttpHeaders();
|
||||||
|
headers.set("Authorization", tokenHeader);
|
||||||
|
headers.set("POR_ORGACODE", porOrgacode);
|
||||||
|
headers.set("SUS_USERCODE", depositCancellationDTO.getSusUsercode());
|
||||||
|
headers.setContentType(MediaType.APPLICATION_JSON);
|
||||||
|
|
||||||
|
HttpEntity<DepositCancellationDTO> entity = new HttpEntity<>(depositCancellationDTO, headers);
|
||||||
|
RestTemplate restTemplate = new RestTemplate();
|
||||||
|
|
||||||
|
ResponseEntity<Map> response = restTemplate.exchange(
|
||||||
|
url,
|
||||||
|
HttpMethod.POST,
|
||||||
|
entity,
|
||||||
|
Map.class
|
||||||
|
);
|
||||||
|
|
||||||
|
return ResponseEntity.status(response.getStatusCode()).body(response.getBody());
|
||||||
|
}
|
||||||
|
|
||||||
|
public Object processGLCancellationTransaction(GLCancellationDTO glCancellationDTO, String tokenHeader) {
|
||||||
|
String porOrgacode = glCancellationDTO.getPorOrgacode();
|
||||||
|
String url = generalledgerURI + GENERALLEDGER + "/organizations/" + glCancellationDTO.getPorOrgacode() +
|
||||||
|
"/transactions" + ACONNECT + "/cancel/nodes/" + glCancellationDTO.getNodeId() +
|
||||||
|
"/trannums/" + glCancellationDTO.getSgtGntrtranlink();
|
||||||
|
|
||||||
|
HttpHeaders headers = new HttpHeaders();
|
||||||
|
headers.set("Authorization", tokenHeader);
|
||||||
|
headers.set("POR_ORGACODE", porOrgacode);
|
||||||
|
headers.set("SUS_USERCODE", glCancellationDTO.getSusUsercode());
|
||||||
|
headers.setContentType(MediaType.APPLICATION_JSON);
|
||||||
|
|
||||||
|
HttpEntity<GLCancellationDTO> entity = new HttpEntity<>(glCancellationDTO, headers);
|
||||||
|
RestTemplate restTemplate = new RestTemplate();
|
||||||
|
|
||||||
|
ResponseEntity<Map> response = restTemplate.exchange(
|
||||||
|
url,
|
||||||
|
HttpMethod.POST,
|
||||||
|
entity,
|
||||||
|
Map.class
|
||||||
|
);
|
||||||
|
|
||||||
|
return ResponseEntity.status(response.getStatusCode()).body(response.getBody());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -1,60 +0,0 @@
|
|||||||
package com.mfsys.aconnect.client.service;
|
|
||||||
|
|
||||||
import org.springframework.core.env.Environment;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
@Service
|
|
||||||
public class EnvironmentDetectionService {
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private Environment environment;
|
|
||||||
|
|
||||||
public String detectEnvironmentFromUsername(String username) {
|
|
||||||
// Check if user has specific environment mapping
|
|
||||||
String userEnvironment = environment.getProperty("app.user." + username + ".environment");
|
|
||||||
|
|
||||||
if (userEnvironment != null) {
|
|
||||||
return userEnvironment;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Default environment if user not mapped
|
|
||||||
return environment.getProperty("app.environment.default", "dev");
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getSecurityUriForEnvironment(String environmentType) {
|
|
||||||
// Get security URI for the detected environment
|
|
||||||
String securityUri = environment.getProperty("app.environment." + environmentType + ".securityUri");
|
|
||||||
|
|
||||||
if (securityUri != null) {
|
|
||||||
return securityUri;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Fallback to default
|
|
||||||
return environment.getProperty("app.security.uri.default",
|
|
||||||
"http://localhost:9090/security/auth/user");
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getSecurityUriForUser(String username) {
|
|
||||||
String userEnvironment = detectEnvironmentFromUsername(username);
|
|
||||||
return getSecurityUriForEnvironment(userEnvironment);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isUserMapped(String username) {
|
|
||||||
return environment.getProperty("app.user." + username + ".environment") != null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Map<String, String> getUserEnvironmentInfo(String username) {
|
|
||||||
String environment = detectEnvironmentFromUsername(username);
|
|
||||||
String securityUri = getSecurityUriForEnvironment(environment);
|
|
||||||
|
|
||||||
return Map.of(
|
|
||||||
"username", username,
|
|
||||||
"environment", environment,
|
|
||||||
"securityUri", securityUri,
|
|
||||||
"isMapped", String.valueOf(isUserMapped(username))
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -0,0 +1,66 @@
|
|||||||
|
package com.mfsys.aconnect.client.service;
|
||||||
|
|
||||||
|
import com.mfsys.aconnect.client.dto.DepositRejectDTO;
|
||||||
|
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;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class RejectTransactionService {
|
||||||
|
|
||||||
|
@Value("${app.deposit.uri}")
|
||||||
|
private String depositURI;
|
||||||
|
|
||||||
|
@Value("${app.generalledger.uri}")
|
||||||
|
private String generalledgerURI;
|
||||||
|
|
||||||
|
private final RestTemplate restTemplate = new RestTemplate();
|
||||||
|
|
||||||
|
public Object processDepositRejectionTransaction(DepositRejectDTO rejectRequest, String tokenHeader) {
|
||||||
|
String porOrgacode = rejectRequest.getPorOrgacode();
|
||||||
|
String url = depositURI + "/deposit/" + "/organizations/" + porOrgacode + "/transactions" + ACONNECT +"/rejection";
|
||||||
|
HttpHeaders headers = new HttpHeaders();
|
||||||
|
headers.set("Authorization", tokenHeader);
|
||||||
|
headers.set("POR_ORGACODE", porOrgacode);
|
||||||
|
headers.set("SUS_USERCODE", rejectRequest.getSusUsercode());
|
||||||
|
headers.setContentType(MediaType.APPLICATION_JSON);
|
||||||
|
|
||||||
|
HttpEntity<DepositRejectDTO> entity = new HttpEntity<>(rejectRequest, headers);
|
||||||
|
|
||||||
|
ResponseEntity<Map> response = restTemplate.exchange(
|
||||||
|
url,
|
||||||
|
HttpMethod.POST,
|
||||||
|
entity,
|
||||||
|
Map.class
|
||||||
|
);
|
||||||
|
|
||||||
|
return ResponseEntity.status(response.getStatusCode()).body(response.getBody());
|
||||||
|
}
|
||||||
|
|
||||||
|
public Object processGLRejectionTransaction(DepositRejectDTO rejectRequest, String tokenHeader) {
|
||||||
|
String porOrgacode = rejectRequest.getPorOrgacode();
|
||||||
|
String url = generalledgerURI + "/generalledger/" + "/organizations/" + porOrgacode + "/transactions" + ACONNECT +"/rejection";
|
||||||
|
HttpHeaders headers = new HttpHeaders();
|
||||||
|
headers.set("Authorization", tokenHeader);
|
||||||
|
headers.set("POR_ORGACODE", porOrgacode);
|
||||||
|
headers.set("SUS_USERCODE", rejectRequest.getSusUsercode());
|
||||||
|
headers.setContentType(MediaType.APPLICATION_JSON);
|
||||||
|
|
||||||
|
HttpEntity<DepositRejectDTO> entity = new HttpEntity<>(rejectRequest, headers);
|
||||||
|
|
||||||
|
ResponseEntity<Map> response = restTemplate.exchange(
|
||||||
|
url,
|
||||||
|
HttpMethod.POST,
|
||||||
|
entity,
|
||||||
|
Map.class
|
||||||
|
);
|
||||||
|
|
||||||
|
return ResponseEntity.status(response.getStatusCode()).body(response.getBody());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,71 @@
|
|||||||
|
package com.mfsys.aconnect.client.service;
|
||||||
|
|
||||||
|
import com.mfsys.aconnect.client.dto.DepositReversalDTO;
|
||||||
|
import com.mfsys.aconnect.client.dto.GLReversalDTO;
|
||||||
|
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;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class ReversalTransactionService {
|
||||||
|
|
||||||
|
@Value("${app.deposit.uri}")
|
||||||
|
private String depositURI;
|
||||||
|
|
||||||
|
@Value("${app.generalledger.uri}")
|
||||||
|
private String generalledgerURI;
|
||||||
|
|
||||||
|
private final RestTemplate restTemplate = new RestTemplate();
|
||||||
|
public Object processDepositReversalTransaction(DepositReversalDTO reversalRequest, String tokenHeader) {
|
||||||
|
String porOrgacode = reversalRequest.getPorOrgacode();
|
||||||
|
String nodeID = reversalRequest.getNodeId();
|
||||||
|
String sgtGntrtranlink = reversalRequest.getSgtGntrtranlink();
|
||||||
|
String url = depositURI + "/deposit/" + "/organizations/" + porOrgacode + "/transactions" + ACONNECT + "/reversals/nodes/" + nodeID + "/trannums/" + sgtGntrtranlink;
|
||||||
|
HttpHeaders headers = new HttpHeaders();
|
||||||
|
headers.set("Authorization", tokenHeader);
|
||||||
|
headers.set("POR_ORGACODE", porOrgacode);
|
||||||
|
headers.set("SUS_USERCODE", reversalRequest.getSusUsercode());
|
||||||
|
headers.setContentType(MediaType.APPLICATION_JSON);
|
||||||
|
|
||||||
|
HttpEntity<DepositReversalDTO> entity = new HttpEntity<>(reversalRequest, headers);
|
||||||
|
|
||||||
|
ResponseEntity<Map> response = restTemplate.exchange(
|
||||||
|
url,
|
||||||
|
HttpMethod.POST,
|
||||||
|
entity,
|
||||||
|
Map.class
|
||||||
|
);
|
||||||
|
|
||||||
|
return ResponseEntity.status(response.getStatusCode()).body(response.getBody());
|
||||||
|
}
|
||||||
|
|
||||||
|
public Object processGLReversalTransaction(GLReversalDTO reversalRequest, String tokenHeader) {
|
||||||
|
String porOrgacode = reversalRequest.getPorOrgacode();
|
||||||
|
String nodeID = reversalRequest.getNodeId();
|
||||||
|
String sgtGntrtranlink = reversalRequest.getSgtGntrtranlink();
|
||||||
|
|
||||||
|
String url = generalledgerURI + "/generalledger/" + "/organizations/" + porOrgacode + "/transactions"+ ACONNECT +"/reversals/nodes/" + nodeID + "/trannums/" + sgtGntrtranlink;
|
||||||
|
HttpHeaders headers = new HttpHeaders();
|
||||||
|
headers.set("Authorization", tokenHeader);
|
||||||
|
headers.set("POR_ORGACODE", porOrgacode);
|
||||||
|
headers.set("SUS_USERCODE", reversalRequest.getSusUsercode());
|
||||||
|
headers.setContentType(MediaType.APPLICATION_JSON);
|
||||||
|
|
||||||
|
HttpEntity<GLReversalDTO> entity = new HttpEntity<>(reversalRequest, headers);
|
||||||
|
|
||||||
|
ResponseEntity<Map> response = restTemplate.exchange(
|
||||||
|
url,
|
||||||
|
HttpMethod.POST,
|
||||||
|
entity,
|
||||||
|
Map.class
|
||||||
|
);
|
||||||
|
|
||||||
|
return ResponseEntity.status(response.getStatusCode()).body(response.getBody());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,68 @@
|
|||||||
|
package com.mfsys.aconnect.client.service;
|
||||||
|
|
||||||
|
import com.mfsys.aconnect.client.dto.DepositAuthorizationRequest;
|
||||||
|
import com.mfsys.aconnect.client.dto.GLAuthorizationDTO;
|
||||||
|
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;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class TransactionAuthorizationService {
|
||||||
|
|
||||||
|
@Value("${app.deposit.uri}")
|
||||||
|
private String depositURI;
|
||||||
|
|
||||||
|
@Value("${app.generalledger.uri}")
|
||||||
|
private String generalledgerURI;
|
||||||
|
|
||||||
|
private final RestTemplate restTemplate = new RestTemplate();
|
||||||
|
|
||||||
|
public Object processDepositAuthTransaction(DepositAuthorizationRequest authorizationRequest, String tokenHeader) {
|
||||||
|
String porOrgacode = authorizationRequest.getPorOrgacode();
|
||||||
|
String url = depositURI + "/deposit/" + "/organizations/" + porOrgacode + "/transactions" + ACONNECT + "/authorizations";
|
||||||
|
HttpHeaders headers = new HttpHeaders();
|
||||||
|
headers.set("Authorization", tokenHeader);
|
||||||
|
headers.set("POR_ORGACODE", porOrgacode);
|
||||||
|
headers.set("SUS_USERCODE", authorizationRequest.getSusUsercode());
|
||||||
|
headers.setContentType(MediaType.APPLICATION_JSON);
|
||||||
|
headers.setAccept(java.util.List.of(MediaType.APPLICATION_JSON));
|
||||||
|
|
||||||
|
HttpEntity<DepositAuthorizationRequest> entity = new HttpEntity<>(authorizationRequest, headers);
|
||||||
|
|
||||||
|
ResponseEntity<Map> response = restTemplate.exchange(
|
||||||
|
url,
|
||||||
|
HttpMethod.POST,
|
||||||
|
entity,
|
||||||
|
Map.class
|
||||||
|
);
|
||||||
|
|
||||||
|
return ResponseEntity.status(response.getStatusCode()).body(response.getBody());
|
||||||
|
}
|
||||||
|
|
||||||
|
public Object processGLAuthTransaction(GLAuthorizationDTO authorizationRequest, String tokenHeader) {
|
||||||
|
String porOrgacode = authorizationRequest.getPorOrgacode();
|
||||||
|
String url = generalledgerURI + "/generalledger/" + "/organizations/" + porOrgacode + "/transactions/authorizations";
|
||||||
|
HttpHeaders headers = new HttpHeaders();
|
||||||
|
headers.set("Authorization", tokenHeader);
|
||||||
|
headers.set("POR_ORGACODE", porOrgacode);
|
||||||
|
headers.set("SUS_USERCODE", authorizationRequest.getSusUsercode());
|
||||||
|
headers.setContentType(MediaType.APPLICATION_JSON);
|
||||||
|
|
||||||
|
HttpEntity<GLAuthorizationDTO> entity = new HttpEntity<>(authorizationRequest, headers);
|
||||||
|
|
||||||
|
ResponseEntity<Map> response = restTemplate.exchange(
|
||||||
|
url,
|
||||||
|
HttpMethod.POST,
|
||||||
|
entity,
|
||||||
|
Map.class
|
||||||
|
);
|
||||||
|
|
||||||
|
return ResponseEntity.status(response.getStatusCode()).body(response.getBody());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -1,5 +1,8 @@
|
|||||||
app.security.uri=http://localhost:9090/security/auth/user
|
app.security.uri=http://localhost:9090/security/auth/user
|
||||||
app.deposit.uri=http://localhost:9095
|
app.deposit.uri=http://localhost:9095
|
||||||
app.generalledger.uri=http://localhost:9093
|
app.generalledger.uri=http://localhost:9093
|
||||||
|
app.onlinebanking.uri=http://localhost:9099
|
||||||
|
app.crm.uri=http://localhost:9096
|
||||||
|
app.loan.uri=http://localhost:9094
|
||||||
app.organization.uri=0005
|
app.organization.uri=0005
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue