dev fix add count
Test Workflow / test (push) Has been cancelled

This commit is contained in:
2026-04-28 16:37:00 +07:00
parent a87567e45d
commit e5d4ec2f07
2 changed files with 64 additions and 29 deletions
@@ -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<>();