validation
parent
2ed521330c
commit
b12c933b41
@ -0,0 +1,37 @@
|
||||
package com.mfsys.aconnect.validation.controller;
|
||||
|
||||
import com.mfsys.aconnect.validation.service.ValidationService;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestHeader;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
public class ValidationController {
|
||||
|
||||
private final ValidationService validationService;
|
||||
|
||||
public ValidationController(ValidationService validationService) {
|
||||
this.validationService = validationService;
|
||||
}
|
||||
|
||||
@GetMapping("/validate-primary")
|
||||
public boolean validatePrimaryIdenNo(
|
||||
@RequestHeader("Authorization") String token,
|
||||
@RequestHeader("SUS_USERCODE") String userCode,
|
||||
@RequestHeader("POR_ORGACODE") String porOrgacode,
|
||||
@RequestParam String primaryIdenNo) {
|
||||
return validationService.validatePrimaryIdenNo(porOrgacode, primaryIdenNo, userCode, token);
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("/validate-customer")
|
||||
public boolean validateCustomerNo(
|
||||
@RequestHeader("Authorization") String token,
|
||||
@RequestHeader("SUS_USERCODE") String userCode,
|
||||
@RequestHeader("POR_ORGACODE") String porOrgacode,
|
||||
@RequestParam String cmpCustcode) {
|
||||
return validationService.validateCustomerNo(porOrgacode, cmpCustcode, userCode, token);
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,52 @@
|
||||
package com.mfsys.aconnect.validation.service;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.http.*;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
||||
import static com.mfsys.common.configuration.constant.AconnectURI.DEPOSIT;
|
||||
|
||||
@Service
|
||||
public class ValidationService {
|
||||
|
||||
@Value("${app.deposit.uri}")
|
||||
private String depositURI;
|
||||
|
||||
private final RestTemplate restTemplate;
|
||||
public ValidationService(RestTemplate restTemplate) {
|
||||
this.restTemplate = restTemplate;
|
||||
}
|
||||
|
||||
public boolean validatePrimaryIdenNo(String porOrgacode, String primaryIdenNo, String userCode, String tokenHeader) {
|
||||
String url = depositURI + DEPOSIT + "/validate-cnicno" + "?porOrgacode=" + porOrgacode + "&pitIdenvalue=" + primaryIdenNo;
|
||||
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.set("Authorization", tokenHeader);
|
||||
headers.set("POR_ORGACODE", porOrgacode);
|
||||
headers.set("SUS_USERCODE", userCode);
|
||||
headers.setAccept(java.util.List.of(MediaType.APPLICATION_JSON));
|
||||
|
||||
HttpEntity<Void> entity = new HttpEntity<>(headers);
|
||||
ResponseEntity<Boolean> response = restTemplate.exchange(url, HttpMethod.GET,entity,Boolean.class);
|
||||
Boolean result = response.getBody();
|
||||
return result != null && result;
|
||||
|
||||
}
|
||||
|
||||
public boolean validateCustomerNo(String porOrgacode, String cmpCustcode, String userCode, String tokenHeader) {
|
||||
String url = depositURI + DEPOSIT + "/validate-customerno" + "?porOrgacode=" + porOrgacode + "&cmpCustcode=" + cmpCustcode;
|
||||
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.set("Authorization", tokenHeader);
|
||||
headers.set("POR_ORGACODE", porOrgacode);
|
||||
headers.set("SUS_USERCODE", userCode);
|
||||
headers.setAccept(java.util.List.of(MediaType.APPLICATION_JSON));
|
||||
|
||||
HttpEntity<Void> entity = new HttpEntity<>(headers);
|
||||
ResponseEntity<Boolean> response = restTemplate.exchange(url, HttpMethod.GET,entity,Boolean.class);
|
||||
Boolean result = response.getBody();
|
||||
return result != null && result;
|
||||
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue