@@ -110,37 +110,36 @@ public class GlobalSearchController {
|
||||
return ResponseEntity.ok(taskOptional.get());
|
||||
}
|
||||
|
||||
// @GetMapping("/violation-summary")
|
||||
// public ResponseEntity<?> getSummary(@RequestHeader(value = "Authorization", required = false) String tokenHeader) {
|
||||
//
|
||||
// if (tokenHeader == null || tokenHeader.isBlank()) {
|
||||
// Map<String, Object> errorData = new HashMap<>();
|
||||
// errorData.put("token", tokenHeader);
|
||||
//
|
||||
// return ResponseEntity.ok().body(Map.of("error", errorData));
|
||||
// }
|
||||
//
|
||||
// List<FileViolationSummaryDTO> fileViolationsSummary;
|
||||
//
|
||||
// try {
|
||||
// Long userId = authService.useUserAuthToken(tokenHeader);
|
||||
//
|
||||
// fileViolationsSummary =
|
||||
// violationService.getFileViolationsSummary(userId);
|
||||
//
|
||||
// if (fileViolationsSummary.isEmpty()) return ResponseEntity.ok().body("Violations summary not found");
|
||||
// } catch (NotFoundAuthToken e) {
|
||||
// Map<String, Object> errorData = new HashMap<>();
|
||||
// errorData.put("token", tokenHeader);
|
||||
//
|
||||
// return ResponseEntity.ok().body(Map.of("error", errorData));
|
||||
// }
|
||||
//
|
||||
// return ResponseEntity.ok(fileViolationsSummary);
|
||||
// }
|
||||
@GetMapping("/violation-summary")
|
||||
public ResponseEntity<?> getSummary(@RequestHeader(value = "Authorization", required = false) String tokenHeader) {
|
||||
|
||||
if (tokenHeader == null || tokenHeader.isBlank()) {
|
||||
Map<String, Object> errorData = new HashMap<>();
|
||||
errorData.put("token", tokenHeader);
|
||||
|
||||
return ResponseEntity.ok().body(Map.of("error", errorData));
|
||||
}
|
||||
|
||||
List<FileViolationSummaryDTO> fileViolationsSummary;
|
||||
|
||||
try {
|
||||
Long userId = authService.useUserAuthToken(tokenHeader);
|
||||
|
||||
fileViolationsSummary = violationService.getFileViolationsSummary(userId);
|
||||
|
||||
if (fileViolationsSummary.isEmpty()) return ResponseEntity.ok().body("Violations summary not found");
|
||||
} catch (NotFoundAuthToken e) {
|
||||
Map<String, Object> errorData = new HashMap<>();
|
||||
errorData.put("token", tokenHeader);
|
||||
|
||||
return ResponseEntity.ok().body(Map.of("error", errorData));
|
||||
}
|
||||
|
||||
return ResponseEntity.ok(fileViolationsSummary);
|
||||
}
|
||||
|
||||
|
||||
@PostMapping("/violation-summary")
|
||||
@PostMapping("v2/violation-summary")
|
||||
public ResponseEntity<?> getViolations(@RequestBody ViolationRequest request) {
|
||||
if (request.getToken() == null || request.getToken().isBlank()) {
|
||||
Map<String, Object> errorData = new HashMap<>();
|
||||
|
||||
Reference in New Issue
Block a user