diff --git a/backend/src/main/java/com/group1/cuisines/controllers/UserController.java b/backend/src/main/java/com/group1/cuisines/controllers/UserController.java index de506bfc..6eedc554 100644 --- a/backend/src/main/java/com/group1/cuisines/controllers/UserController.java +++ b/backend/src/main/java/com/group1/cuisines/controllers/UserController.java @@ -84,12 +84,16 @@ public ResponseEntity followUser(@PathVariable Integer userId) { public ResponseEntity getUserFollowing(@PathVariable Integer userId) { // Validate the provided user ID if (userId == null) { - return ResponseEntity.badRequest().body("Invalid user ID provided"); + + return ResponseEntity.ok(new ErrorResponse(204,"Invalid user ID provided") ); + } + if(userRepository.findById(userId).isEmpty()){ + return ResponseEntity.ok(new ErrorResponse(204,"User not found") ); } Set following = userService.getUserFollowing(userId); if (following.isEmpty()) { - return ResponseEntity.ok().body("User is not following anyone"); + return ResponseEntity.ok(new ErrorResponse(204,"User is not following anyone")); } else { Set followingDto = following.stream() .map(user -> UserDto.builder() @@ -102,7 +106,7 @@ public ResponseEntity getUserFollowing(@PathVariable Integer userId) { .recipeCount(user.getRecipeCount()) .build()) .collect(Collectors.toSet()); - return ResponseEntity.ok().body(followingDto); + return ResponseEntity.ok(new SuccessResponse<>(200,followingDto, "User following fetched successfully")); } } @GetMapping("/{userId}/followers")