|
1 | 1 | package systems.rajshah.controller;
|
2 | 2 |
|
3 | 3 | import java.io.ByteArrayInputStream;
|
4 |
| -import java.util.ArrayList; |
5 | 4 | import java.util.List;
|
| 5 | +import java.util.Map; |
6 | 6 | import java.util.concurrent.ExecutionException;
|
7 |
| -import java.util.stream.IntStream; |
8 | 7 |
|
9 | 8 | import org.springframework.beans.factory.annotation.Autowired;
|
10 | 9 | import org.springframework.core.io.InputStreamResource;
|
|
25 | 24 | import systems.rajshah.model.FullInvestorInfo;
|
26 | 25 | import systems.rajshah.model.InvestorInfo;
|
27 | 26 | import systems.rajshah.model.QueryObjectDetails;
|
| 27 | +import systems.rajshah.model.ReportGenObject; |
28 | 28 | import systems.rajshah.model.UserInfo;
|
29 | 29 | import systems.rajshah.service.IfirebaseUser;
|
30 | 30 |
|
31 | 31 | @RestController
|
32 | 32 | public class FdprojectRestController {
|
33 | 33 | @Autowired(required = false)
|
34 | 34 | IfirebaseUser ifirebaseuser;
|
| 35 | + |
35 | 36 | @GetMapping("/")
|
36 | 37 | public ResponseEntity<String> greetMessage() {
|
37 |
| - return new ResponseEntity<String>("***** Welcome To Data CRM System .Please Authenticate *****",HttpStatus.UNAUTHORIZED); |
| 38 | + return new ResponseEntity<String>("***** Welcome To Data CRM System .Please Authenticate *****", |
| 39 | + HttpStatus.UNAUTHORIZED); |
38 | 40 | }
|
39 |
| - @GetMapping(value="/users/{currentUid}",produces="application/json") |
40 |
| - public UserInfo getUserInfoByemail(@PathVariable("currentUid") String currentUid) throws FirebaseAuthException, InterruptedException, ExecutionException { |
| 41 | + |
| 42 | + @GetMapping(value = "/users/{currentUid}", produces = "application/json") |
| 43 | + public UserInfo getUserInfoByemail(@PathVariable("currentUid") String currentUid) |
| 44 | + throws FirebaseAuthException, InterruptedException, ExecutionException { |
41 | 45 | return ifirebaseuser.getCurrentUserDetails(currentUid);
|
42 | 46 | }
|
43 |
| - |
44 |
| - @PostMapping(value="/{currentUid}/addInvestor",consumes = "application/json") |
45 |
| - public String creaInvestorInfo(@RequestBody InvestorInfo investorInfo,@PathVariable("currentUid") String currentUid) throws FirebaseAuthException, InterruptedException, ExecutionException { |
46 |
| - return ifirebaseuser.createInvestorInfo(investorInfo,currentUid); |
| 47 | + |
| 48 | + @PostMapping(value = "/{currentUid}/addInvestor", consumes = "application/json") |
| 49 | + public String creaInvestorInfo(@RequestBody InvestorInfo investorInfo, |
| 50 | + @PathVariable("currentUid") String currentUid) |
| 51 | + throws FirebaseAuthException, InterruptedException, ExecutionException { |
| 52 | + return ifirebaseuser.createInvestorInfo(investorInfo, currentUid); |
47 | 53 | }
|
48 |
| - @PostMapping(value="/{currentUid}/addfdinfo",consumes = "application/json") |
49 |
| - public String addFdInfo(@RequestBody FdInfo fdInfo,@PathVariable("currentUid") String currentUid) throws FirebaseAuthException, InterruptedException, ExecutionException { |
50 |
| - return ifirebaseuser.createFdInfo(fdInfo,currentUid); |
| 54 | + |
| 55 | + @PostMapping(value = "/{currentUid}/addfdinfo", consumes = "application/json") |
| 56 | + public String addFdInfo(@RequestBody FdInfo fdInfo, @PathVariable("currentUid") String currentUid) |
| 57 | + throws FirebaseAuthException, InterruptedException, ExecutionException { |
| 58 | + return ifirebaseuser.createFdInfo(fdInfo, currentUid); |
51 | 59 | }
|
52 |
| - @GetMapping(value="/{currentUid}/getCustomer/{id}",produces = "application/json") |
53 |
| - public FullInvestorInfo getCustomerInfo(@PathVariable("id") String idvarable,@PathVariable("currentUid") String currentUid ) throws FirebaseAuthException, InterruptedException, ExecutionException { |
54 |
| - return ifirebaseuser.getfullInfo(idvarable,currentUid); |
| 60 | + |
| 61 | + @GetMapping(value = "/{currentUid}/getCustomer/{id}", produces = "application/json") |
| 62 | + public FullInvestorInfo getCustomerInfo(@PathVariable("id") String idvarable, |
| 63 | + @PathVariable("currentUid") String currentUid) |
| 64 | + throws FirebaseAuthException, InterruptedException, ExecutionException { |
| 65 | + return ifirebaseuser.getfullInfo(idvarable, currentUid); |
55 | 66 | }
|
56 |
| - @GetMapping(value="/{currentUid}/getClientDataByRange",produces = "application/json") |
57 |
| - public List<FullInvestorInfo> getAllBetweenRangesMaturaty(@RequestBody QueryObjectDetails queryFullDetails,@PathVariable("currentUid") String currentUid) throws FirebaseAuthException, InterruptedException, ExecutionException{ |
| 67 | + |
| 68 | + @GetMapping(value = "/{currentUid}/getClientDataByRange", produces = "application/json") |
| 69 | + public List<FullInvestorInfo> getAllBetweenRangesMaturaty(@RequestBody QueryObjectDetails queryFullDetails, |
| 70 | + @PathVariable("currentUid") String currentUid) |
| 71 | + throws FirebaseAuthException, InterruptedException, ExecutionException { |
58 | 72 | return ifirebaseuser.getInvestInfoBtDates(queryFullDetails, currentUid);
|
59 |
| - } |
60 |
| - @GetMapping(value="/{currentUid}/getCustomersByFid/{id}",produces = "application/json") |
61 |
| - public List<FullInvestorInfo> getInfoByFamilyCode(@PathVariable("id") String idvarable,@RequestBody QueryObjectDetails queryFullDetails,@PathVariable("currentUid") String currentUid) throws FirebaseAuthException, InterruptedException, ExecutionException{ |
62 |
| - return ifirebaseuser.getfullInfoByFamilyCode(idvarable,queryFullDetails, currentUid); |
63 | 73 | }
|
64 |
| - @GetMapping(value="/{currentUid}/generateCustIntiByFid/{id}") |
65 |
| - public ResponseEntity<InputStreamResource> generateCustInByFid(@PathVariable("id") String idvarable,@RequestBody QueryObjectDetails queryFullDetails,@PathVariable("currentUid") String currentUid) throws FirebaseAuthException, InterruptedException, ExecutionException, DocumentException{ |
66 |
| - ByteArrayInputStream bis= ifirebaseuser.generateCustomerIntimationReport(idvarable, queryFullDetails, currentUid); |
| 74 | + |
| 75 | + @GetMapping(value = "/{currentUid}/getCustomersByFid/{id}", produces = "application/json") |
| 76 | + public List<FullInvestorInfo> getInfoByFamilyCode(@PathVariable("id") String idvarable, |
| 77 | + @RequestBody QueryObjectDetails queryFullDetails, @PathVariable("currentUid") String currentUid) |
| 78 | + throws FirebaseAuthException, InterruptedException, ExecutionException { |
| 79 | + return ifirebaseuser.getfullInfoByFamilyCode(idvarable, queryFullDetails, currentUid); |
| 80 | + } |
| 81 | + |
| 82 | + @GetMapping(value = "/{currentUid}/generateCustIntiByFid/{id}") |
| 83 | + public ResponseEntity<InputStreamResource> generateCustInByFid(@PathVariable("id") String idvarable, |
| 84 | + @RequestBody QueryObjectDetails queryFullDetails, @PathVariable("currentUid") String currentUid) |
| 85 | + throws FirebaseAuthException, InterruptedException, ExecutionException, DocumentException { |
| 86 | + ByteArrayInputStream bis = ifirebaseuser.generateCustomerIntimationReport(idvarable, queryFullDetails, |
| 87 | + currentUid); |
67 | 88 | HttpHeaders headers = new HttpHeaders();
|
68 |
| - headers.add("Content-Disposition", "inline; filename="+idvarable+".pdf"); |
69 |
| - return ResponseEntity |
70 |
| - .ok() |
71 |
| - .headers(headers) |
72 |
| - .contentType(MediaType.APPLICATION_PDF) |
73 |
| - .body(new InputStreamResource(bis)); |
74 |
| - } |
75 |
| - @GetMapping(value="/{currentUid}/getFamilyHeadDetails/{id}",produces="application/json") |
76 |
| - public InvestorInfo getFamilyHeadDetails(@PathVariable("id") String idvarable,@PathVariable("currentUid") String currentUid) throws FirebaseAuthException, InterruptedException, ExecutionException{ |
77 |
| - return ifirebaseuser.getFamliyHeadForFamilyCode(idvarable,currentUid); |
| 89 | + headers.add("Content-Disposition", "inline; filename=" + idvarable + ".pdf"); |
| 90 | + return ResponseEntity.ok().headers(headers).contentType(MediaType.APPLICATION_PDF) |
| 91 | + .body(new InputStreamResource(bis)); |
78 | 92 | }
|
79 |
| - @GetMapping(value="/{currentUid}/getReportBwtDates") |
80 |
| - public List<ResponseEntity<InputStreamResource>> getReportBwtDates(@PathVariable("currentUid") String currentUid,@RequestBody QueryObjectDetails queryFullDetails) throws FirebaseAuthException, InterruptedException, ExecutionException { |
81 |
| - List<ByteArrayInputStream> bis= ifirebaseuser.getCustReportByDates(queryFullDetails, currentUid); |
82 |
| - List<ResponseEntity<InputStreamResource>> repsonse= new ArrayList<>(); |
83 |
| - IntStream.range(0,bis.size()).forEach(e->{ |
84 |
| - HttpHeaders headers = new HttpHeaders(); |
85 |
| - headers.add("Content-Disposition", "inline; filename="+"Test"+".pdf"); |
86 |
| - repsonse.add(ResponseEntity |
87 |
| - .ok() |
88 |
| - .headers(headers) |
89 |
| - .contentType(MediaType.APPLICATION_PDF) |
90 |
| - .body(new InputStreamResource(bis.get(e)))); |
91 |
| - }); |
92 |
| - return repsonse; |
93 |
| - |
| 93 | + |
| 94 | + @GetMapping(value = "/{currentUid}/getFamilyHeadDetails/{id}", produces = "application/json") |
| 95 | + public InvestorInfo getFamilyHeadDetails(@PathVariable("id") String idvarable, |
| 96 | + @PathVariable("currentUid") String currentUid) |
| 97 | + throws FirebaseAuthException, InterruptedException, ExecutionException { |
| 98 | + return ifirebaseuser.getFamliyHeadForFamilyCode(idvarable, currentUid); |
| 99 | + } |
| 100 | + |
| 101 | + @GetMapping(value = "/{currentUid}/getReportJSON") |
| 102 | + public ResponseEntity<Map<String, ReportGenObject>> getReportJSON(@PathVariable("currentUid") String currentUid, |
| 103 | + @RequestBody QueryObjectDetails queryFullDetails) |
| 104 | + throws FirebaseAuthException, InterruptedException, ExecutionException { |
| 105 | + Map<String, ReportGenObject> responseMap = ifirebaseuser.getReportJSONService(queryFullDetails, currentUid); |
| 106 | + ResponseEntity.status(HttpStatus.ACCEPTED).build(); |
| 107 | + return ResponseEntity.ok(responseMap); |
| 108 | + |
94 | 109 | }
|
95 | 110 |
|
| 111 | + @GetMapping(value="/{currentUid}/PrintMultiReportPDF") |
| 112 | + public ResponseEntity<InputStreamResource> printMultiReportPDF( |
| 113 | + @RequestBody QueryObjectDetails queryFullDetails, @PathVariable("currentUid") String currentUid) |
| 114 | + throws FirebaseAuthException, InterruptedException, ExecutionException, DocumentException { |
| 115 | + ByteArrayInputStream bis = ifirebaseuser.generateFullClientReport(queryFullDetails, currentUid); |
| 116 | + HttpHeaders headers = new HttpHeaders(); |
| 117 | + |
| 118 | + headers.add("Content-Disposition", "inline; filename=" + "FullCustReport" + ".pdf"); |
| 119 | + return ResponseEntity.ok().headers(headers).contentType(MediaType.APPLICATION_PDF) |
| 120 | + .body(new InputStreamResource(bis)); |
| 121 | + } |
96 | 122 | }
|
0 commit comments