Refactor transaction controllers and services structure

Split transaction-related endpoints into dedicated controllers and services for authorization, cancellation, rejection, and reversal. Renamed LoginController and LoginService to AuthController and AuthService. Added DTOs for account-to-account and GL-to-account transactions, updated TransactionService to handle new transaction types, and adjusted URI constants and token bypass lists accordingly. Removed EnvironmentDetectionService as part of the refactor.
FMFI-PRE-PRODUCTION-TRX
Naeem Ullah 1 month ago
parent 9c7f195e98
commit 1e375887e5

@ -1,7 +1,7 @@
package com.mfsys.aconnect.client.controller; package com.mfsys.aconnect.client.controller;
import com.mfsys.aconnect.client.dto.SigninRequest; import com.mfsys.aconnect.client.dto.SigninRequest;
import com.mfsys.aconnect.client.service.LoginService; import com.mfsys.aconnect.client.service.AuthService;
import com.mfsys.common.configuration.constant.AconnectURI; import com.mfsys.common.configuration.constant.AconnectURI;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
@ -12,12 +12,12 @@ import org.springframework.web.bind.annotation.RestController;
import java.util.Map; import java.util.Map;
@RestController @RestController
public class LoginController { public class AuthController {
LoginService loginService; AuthService loginService;
@Autowired @Autowired
public LoginController(LoginService loginService) { public AuthController(AuthService loginService) {
this.loginService = loginService; this.loginService = loginService;
} }

@ -0,0 +1,7 @@
package com.mfsys.aconnect.client.controller;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class CRMController {
}

@ -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);
}
}

@ -1,6 +1,9 @@
package com.mfsys.aconnect.client.controller; package com.mfsys.aconnect.client.controller;
import com.mfsys.aconnect.client.dto.*; import com.mfsys.aconnect.client.dto.AccountToAccountDTO;
import com.mfsys.aconnect.client.dto.AccountGLTransactionRequest;
import com.mfsys.aconnect.client.dto.GLtoGLRequest;
import com.mfsys.aconnect.client.dto.GlToAccountDTO;
import com.mfsys.aconnect.client.service.TransactionService; import com.mfsys.aconnect.client.service.TransactionService;
import com.mfsys.common.configuration.constant.AconnectURI; import com.mfsys.common.configuration.constant.AconnectURI;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -45,52 +48,16 @@ public class TransactionController {
return transactionService.processGLTransaction(request, token); return transactionService.processGLTransaction(request, token);
} }
@PostMapping(AconnectURI.DEPOSIT_AUTHORIZATION_URI) @PostMapping(AconnectURI.ACCOUNT_TO_ACCOUNT_TRANSACTION_URI)
public Object depositAuthorizationTransaction(@RequestBody DepositAuthorizationRequest authorizationRequest, public Object accToAccTransaction(@RequestBody AccountToAccountDTO request,
@RequestHeader("Authorization") String token) { @RequestHeader("Authorization") String token) {
return transactionService.processDepositAuthTransaction(authorizationRequest, token); return transactionService.processAccToAccTransaction(request, token);
} }
@PostMapping(AconnectURI.GENERALLEDGER_AUTHORIZATION_URI) @PostMapping(AconnectURI.GL_TO_ACCOUNT_TRANSACTION_URI)
public Object glAuthorizationTransaction(@RequestBody GLAuthorizationDTO glAuthorizationRequest, public Object glToAccTransaction(@RequestBody GlToAccountDTO glToAccountDTO,
@RequestHeader("Authorization") String token) { @RequestHeader("Authorization") String token) {
return transactionService.processGLAuthTransaction(glAuthorizationRequest, token); return transactionService.processGLtoAccTransaction(glToAccountDTO, token);
}
@PostMapping(AconnectURI.DEPOSIT_CANCELLATION_URI)
public Object depositCancellationTransaction(@RequestBody DepositCancellationDTO depositCancellationDTO,
@RequestHeader("Authorization") String token) {
return transactionService.processDepositCancellationTransaction(depositCancellationDTO, token);
}
@PostMapping(AconnectURI.GENERALLEDGER_CANCELLATION_URI)
public Object glCancellationTransaction(@RequestBody GLCancellationDTO glCancellationRequest,
@RequestHeader("Authorization") String token) {
return transactionService.processGLCancellationTransaction(glCancellationRequest, token);
}
@PostMapping(AconnectURI.DEPOSIT_TRANSACTION_REVERSAL_URI)
public Object depositReversalTransaction(@RequestBody DepositReversalDTO depositReversalDTO,
@RequestHeader("Authorization") String token) {
return transactionService.processDepositReversalTransaction(depositReversalDTO, token);
}
@PostMapping(AconnectURI.GENERALLEDGER_TRANSACTION_REVERSAL_URI)
public Object glReversalTransaction(@RequestBody GLReversalDTO glReversalRequest,
@RequestHeader("Authorization") String token) {
return transactionService.processGLReversalTransaction(glReversalRequest, token);
}
@PostMapping(AconnectURI.DEPOSIT_TRANSACTION_REJECT_URI)
public Object depositRejectionTransaction(@RequestBody DepositRejectDTO rejectRequest,
@RequestHeader("Authorization") String token) {
return transactionService.processDepositRejectionTransaction(rejectRequest, token);
}
@PostMapping(AconnectURI.GENERALLEDGER_TRANSACTION_REJECT_URI)
public Object glRejectionTransaction(@RequestBody DepositRejectDTO rejectRequest,
@RequestHeader("Authorization") String token) {
return transactionService.processGLRejectionTransaction(rejectRequest, 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,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;
}
}

@ -2,7 +2,6 @@ package com.mfsys.aconnect.client.service;
import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import org.springframework.beans.factory.annotation.Autowired;
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;
@ -12,7 +11,7 @@ import java.util.HashMap;
import java.util.Map; import java.util.Map;
@Service @Service
public class LoginService { public class AuthService {
@Value("${app.organization.uri}") @Value("${app.organization.uri}")
private String OrgaCode; private String OrgaCode;
@ -20,20 +19,10 @@ public class LoginService {
@Value("${app.security.uri}") @Value("${app.security.uri}")
private String securityURI; private String securityURI;
@Autowired
private EnvironmentDetectionService environmentDetectionService;
private final RestTemplate restTemplate = new RestTemplate(); private final RestTemplate restTemplate = new RestTemplate();
private final ObjectMapper objectMapper = new ObjectMapper(); private final ObjectMapper objectMapper = new ObjectMapper();
public Map<String, Object> authenticate(Map<String, String> payload) { public Map<String, Object> authenticate(Map<String, String> payload) {
String username = payload.get("username");
String password = payload.get("password");
// // Detect environment and get security URI based on username
// String userEnvironment = environmentDetectionService.detectEnvironmentFromUsername(username);
// String securityUri = environmentDetectionService.getSecurityUriForUser(username);
// boolean isUserMapped = environmentDetectionService.isUserMapped(username);
HttpHeaders headers = new HttpHeaders(); HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON); headers.setContentType(MediaType.APPLICATION_JSON);
@ -44,12 +33,6 @@ public class LoginService {
HttpEntity<Map<String, String>> request = new HttpEntity<>(requestPayload, headers); HttpEntity<Map<String, String>> request = new HttpEntity<>(requestPayload, headers);
try { try {
// System.out.println("=== Environment-Based Routing ===");
// System.out.println("Username: " + username);
// System.out.println("Detected Environment: " + userEnvironment);
// System.out.println("Security Service: " + securityUri);
// System.out.println("User Explicitly Mapped: " + isUserMapped);
ResponseEntity<String> response = restTemplate.postForEntity(securityURI, request, String.class); ResponseEntity<String> response = restTemplate.postForEntity(securityURI, request, String.class);
JsonNode jsonNode = objectMapper.readTree(response.getBody()); JsonNode jsonNode = objectMapper.readTree(response.getBody());
@ -57,18 +40,9 @@ public class LoginService {
result.put("authenticated", jsonNode.get("authenticated").asBoolean()); result.put("authenticated", jsonNode.get("authenticated").asBoolean());
result.put("token", jsonNode.get("token").asText()); result.put("token", jsonNode.get("token").asText());
result.put("userName", jsonNode.get("userName").asText()); result.put("userName", jsonNode.get("userName").asText());
// result.put("securityServiceUsed", securityUri);
// result.put("userEnvironment", userEnvironment);
// result.put("userExplicitlyMapped", isUserMapped);
return result; return result;
} catch (Exception e) { } catch (Exception e) {
// System.err.println("Authentication failed for user: " + username);
// System.err.println("Environment: " + userEnvironment);
// System.err.println("Security Service: " + securityUri);
// System.err.println("Error: " + e.getMessage());
return Map.of( return Map.of(
"authenticated", false, "authenticated", false,
"error", "Authentication failed: " + e.getMessage() "error", "Authentication failed: " + e.getMessage()

@ -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());
}
}

@ -25,6 +25,9 @@ public class TransactionService {
@Value("${app.generalledger.uri}") @Value("${app.generalledger.uri}")
private String generalledgerURI; private String generalledgerURI;
@Value("${app.onlinebanking.uri}")
private String onlinebankingURI;
private final RestTemplate restTemplate = new RestTemplate(); private final RestTemplate restTemplate = new RestTemplate();
public ResponseEntity getActiveAccountDetails(String porOrgacode, String mbmBkmsnumber, LocalDate sgtGntrvaluedate, String tokenHeader, String userCode) { public ResponseEntity getActiveAccountDetails(String porOrgacode, String mbmBkmsnumber, LocalDate sgtGntrvaluedate, String tokenHeader, String userCode) {
@ -108,90 +111,19 @@ public class TransactionService {
return ResponseEntity.status(response.getStatusCode()).body(response.getBody()); return ResponseEntity.status(response.getStatusCode()).body(response.getBody());
} }
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);
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 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);
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 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);
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 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; public Object processAccToAccTransaction(AccountToAccountDTO accountToAccountDTO, String tokenHeader) {
String porOrgacode = accountToAccountDTO.getPorOrgacode();
String url = depositURI + "/deposit/" + "transactions/account-account";
HttpHeaders headers = new HttpHeaders(); HttpHeaders headers = new HttpHeaders();
headers.set("Authorization", tokenHeader); headers.set("Authorization", tokenHeader);
headers.set("POR_ORGACODE", porOrgacode); headers.set("POR_ORGACODE", porOrgacode);
headers.set("SUS_USERCODE", reversalRequest.getSusUsercode()); headers.set("SUS_USERCODE", accountToAccountDTO.getSgtGntrcreateusr());
headers.setContentType(MediaType.APPLICATION_JSON); headers.setContentType(MediaType.APPLICATION_JSON);
headers.setAccept(java.util.List.of(MediaType.APPLICATION_JSON));
HttpEntity<AccountToAccountDTO> entity = new HttpEntity<>(accountToAccountDTO, headers);
HttpEntity<GLReversalDTO> entity = new HttpEntity<>(reversalRequest, headers);
RestTemplate restTemplate = new RestTemplate(); RestTemplate restTemplate = new RestTemplate();
ResponseEntity<Map> response = restTemplate.exchange( ResponseEntity<Map> response = restTemplate.exchange(
url, url,
HttpMethod.POST, HttpMethod.POST,
@ -200,66 +132,22 @@ public class TransactionService {
); );
return ResponseEntity.status(response.getStatusCode()).body(response.getBody()); return ResponseEntity.status(response.getStatusCode()).body(response.getBody());
}
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);
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 processGLRejectionTransaction(DepositRejectDTO rejectRequest, String tokenHeader) { public Object processGLtoAccTransaction(GlToAccountDTO glToAccountDTO, 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);
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 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();
String porOrgacode = glToAccountDTO.getPorOrgacode();
String url = depositURI + "/deposit/" + "transactions/gl-account";
HttpHeaders headers = new HttpHeaders(); HttpHeaders headers = new HttpHeaders();
headers.set("Authorization", tokenHeader); headers.set("Authorization", tokenHeader);
headers.set("POR_ORGACODE", porOrgacode); headers.set("POR_ORGACODE", porOrgacode);
headers.set("SUS_USERCODE", depositCancellationDTO.getSusUsercode()); headers.set("SUS_USERCODE", glToAccountDTO.getSgtGntrcreateusr());
headers.setContentType(MediaType.APPLICATION_JSON); headers.setContentType(MediaType.APPLICATION_JSON);
headers.setAccept(java.util.List.of(MediaType.APPLICATION_JSON));
HttpEntity<GlToAccountDTO> entity = new HttpEntity<>(glToAccountDTO, headers);
HttpEntity<DepositCancellationDTO> entity = new HttpEntity<>(depositCancellationDTO, headers);
RestTemplate restTemplate = new RestTemplate(); RestTemplate restTemplate = new RestTemplate();
ResponseEntity<Map> response = restTemplate.exchange( ResponseEntity<Map> response = restTemplate.exchange(
url, url,
HttpMethod.POST, HttpMethod.POST,
@ -270,28 +158,5 @@ public class TransactionService {
return ResponseEntity.status(response.getStatusCode()).body(response.getBody()); 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,5 +1,6 @@
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.organization.uri=0005 app.organization.uri=0005

@ -20,6 +20,8 @@ public interface AconnectURI {
String TRANSACTION_ACCOUNT_GL_URI = TRANSACTION_URI + "/accounttogl"; String TRANSACTION_ACCOUNT_GL_URI = TRANSACTION_URI + "/accounttogl";
String TRANSACTION_GL_GL_URI = TRANSACTION_URI + "/gltogls"; String TRANSACTION_GL_GL_URI = TRANSACTION_URI + "/gltogls";
String ACCOUNT_TO_ACCOUNT_TRANSACTION_URI = TRANSACTION_URI + "/accounttoaccount";
String GL_TO_ACCOUNT_TRANSACTION_URI = TRANSACTION_URI + "/gl-account";
String TRANSACTION_CANCEL_URI = TRANSACTION_URI + CANCEL_URI + "/nodes/{nodeId}/trannums/{sgtGntrtranlink}"; String TRANSACTION_CANCEL_URI = TRANSACTION_URI + CANCEL_URI + "/nodes/{nodeId}/trannums/{sgtGntrtranlink}";
String DEPOSIT_TRANSACTION_REJECT_URI = DEPOSIT + TRANSACTION_URI + REJECT_URI; String DEPOSIT_TRANSACTION_REJECT_URI = DEPOSIT + TRANSACTION_URI + REJECT_URI;
String GENERALLEDGER_TRANSACTION_REJECT_URI = GENERALLEDGER + TRANSACTION_URI + REJECT_URI; String GENERALLEDGER_TRANSACTION_REJECT_URI = GENERALLEDGER + TRANSACTION_URI + REJECT_URI;

@ -13,6 +13,8 @@ public interface TokenBypassURI {
"/deposit/account/miscDetails", "/deposit/account/miscDetails",
"/aconnect/account/getAccountDetails", "/aconnect/account/getAccountDetails",
"/aconnect/transactions/gltogls", "/aconnect/transactions/gltogls",
"/aconnect/transactions/accounttoaccount",
"/aconnect/transactions/gl-account",
"/aconnect/deposit/authorizations", "/aconnect/deposit/authorizations",
"/aconnect/generalledger/authorizations", "/aconnect/generalledger/authorizations",
"/aconnect/deposit/authorizations", "/aconnect/deposit/authorizations",

Loading…
Cancel
Save