@@ -63,6 +63,26 @@ public class GlobalSearchController {
|
||||
return ResponseEntity.ok(response);
|
||||
}
|
||||
|
||||
@GetMapping("/actual-task")
|
||||
public ResponseEntity<?> getStatus(@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));
|
||||
}
|
||||
|
||||
Long userId = authService.useUserAuthToken(tokenHeader);
|
||||
|
||||
Optional<GlobalSearchTask> taskOptional = searchTaskRepository.findByUserIdAndStatus(userId,
|
||||
"PROCESSING");
|
||||
|
||||
if (taskOptional.isEmpty()) return ResponseEntity.ok().body("Task not found");
|
||||
|
||||
return ResponseEntity.ok(taskOptional.get());
|
||||
}
|
||||
|
||||
@GetMapping("/status/{taskId}")
|
||||
public ResponseEntity<?> getStatus(@PathVariable String taskId,
|
||||
@RequestHeader(value = "Authorization", required = false) String tokenHeader) {
|
||||
|
||||
@@ -14,6 +14,8 @@ import java.util.Optional;
|
||||
public interface GlobalSearchTaskRepository extends JpaRepository<GlobalSearchTask, String> {
|
||||
Optional<GlobalSearchTask> findByTaskIdAndUserId(String taskId, Long userId);
|
||||
|
||||
Optional<GlobalSearchTask> findByUserIdAndStatus(Long userId, String status);
|
||||
|
||||
List<GlobalSearchTask> findByUserIdOrderByCreatedAtDesc(Long userId);
|
||||
|
||||
List<GlobalSearchTask> findByUserIdAndCreatedAtAfterOrderByCreatedAtDesc(Long userId, LocalDateTime date);
|
||||
|
||||
Reference in New Issue
Block a user