|
|
|
@ -194,43 +194,6 @@ public class MainController { |
|
|
|
return "modules/food_scheme/driverreport"; |
|
|
|
} |
|
|
|
|
|
|
|
@GetMapping("/petdashboard") |
|
|
|
public String petdashboard(Model model, HttpSession session) { |
|
|
|
String authToken = ""; |
|
|
|
try { |
|
|
|
RestTemplate restTemplate = new RestTemplate(); |
|
|
|
|
|
|
|
// Request body |
|
|
|
Map<String, String> requestBody = new HashMap<>(); |
|
|
|
requestBody.put("username", "admin@getryt.io"); |
|
|
|
requestBody.put("password", "Reset@123"); |
|
|
|
|
|
|
|
HttpHeaders headers = new HttpHeaders(); |
|
|
|
headers.setContentType(MediaType.APPLICATION_JSON); |
|
|
|
|
|
|
|
HttpEntity<Map<String, String>> request = new HttpEntity<>(requestBody, headers); |
|
|
|
|
|
|
|
ResponseEntity<String> response = restTemplate.postForEntity(LOGIN_URL, request, String.class); |
|
|
|
|
|
|
|
if (response.getStatusCode() != HttpStatus.OK) { |
|
|
|
throw new RuntimeException("Login failed"); |
|
|
|
} |
|
|
|
|
|
|
|
// Parse JSON response |
|
|
|
ObjectMapper mapper = new ObjectMapper(); |
|
|
|
JsonNode root = mapper.readTree(response.getBody()); |
|
|
|
|
|
|
|
// Equivalent to: json.data.session |
|
|
|
authToken = root.path("data").path("session").asText(); |
|
|
|
System.out.println("Auth Token: " + authToken); |
|
|
|
session.setAttribute("AUTH_TOKEN", authToken); |
|
|
|
} catch (Exception e) { |
|
|
|
e.printStackTrace(); |
|
|
|
} |
|
|
|
model.addAttribute("AUTH_TOKEN", authToken); |
|
|
|
return "modules/pet/petreport"; |
|
|
|
} |
|
|
|
|
|
|
|
@GetMapping("/healthcampreport") |
|
|
|
public String abstractreport(Model model) { |
|
|
|
|
|
|
|
|