forked from 790hanu/Annex-qr-code-simulator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
IdProofValidationController.java
67 lines (55 loc) · 2.11 KB
/
IdProofValidationController.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
package com.simactivation.controller;
import javax.validation.Valid;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.simactivation.dto.SimDetailsDTO;
import com.simactivation.entity.Customer;
import com.simactivation.service.CustomerServices;
import com.simactivation.validation.ValidateIdProof;
@RestController
@RequestMapping(value = "/customer/idproof")
@Validated
public class IdProofValidationController {
@Autowired
private CustomerServices customerServices;
@PutMapping(value = "/validate")
public ResponseEntity<String> validateIdproof(@Valid @RequestBody ValidateIdProof val){
Customer customer = customerServices.VerifyIdProof(val.getIdNumber());
if(customer == null)
{
return ResponseEntity.ok("Invalid details");
}
else {
if(customer.getFirstName().matches(val.getFirstname()) &&
customer.getLastName().matches(val.getLastname())&&
customer.getDateOfBirth().equals(val.getDobDate()))
{
SimDetailsDTO simdetailsdto = customerServices.verifysimstatus(customer.getSimId());
if(simdetailsdto.getSimStatus().matches("active"))
return ResponseEntity.ok("Sim status is active");
else if(simdetailsdto.getSimStatus().matches("inactive"))
{
customerServices.updatesimstatus("active", customer.getSimId());
return ResponseEntity.ok("sim status is activated");
}
else
{
return ResponseEntity.ok("Enter Valid Details");
}
}
else if(customer.getFirstName().matches(val.getFirstname()) &&
customer.getLastName().matches(val.getLastname()))
{
return ResponseEntity.ok("Incorrect date of birth details");
}
else {
return ResponseEntity.ok("Invalid Details");
}
}
}
}