Ignore:
Timestamp:
10/12/24 21:32:15 (5 weeks ago)
Author:
macagaso <gasoskamarija@…>
Branches:
master
Parents:
743de55
Message:

Updated version

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/main/java/finki/it/terapijamkbackend/spring/controllers/UserController.java

    r743de55 r43c9090  
    4545            response = new HashMap<>();
    4646            response.put("message", "User created successfully!");
    47             System.out.println(response);
    4847            return ResponseEntity.ok(response);
    4948        } catch (Exception e) {
     
    5453    @GetMapping("/editUser")
    5554    public ResponseEntity<User> getUser(@RequestParam String username) {
    56         User user = userService.getUserByUsername(username); // Fetch user data from service
     55        User user = userService.getUserByUsername(username);
    5756        if (user != null) {
    58             return ResponseEntity.ok(user); // Return user data as JSON
     57            return ResponseEntity.ok(user);
    5958        } else {
    60             return ResponseEntity.notFound().build(); // Handle user not found
     59            return ResponseEntity.notFound().build();
    6160        }
    6261    }
     
    7675            String oldUsername=getCookieValue(request, "username");
    7776            User user = userService.updateUser(oldUsername, updatedUser);
    78             return ResponseEntity.ok(user); // Return the updated user in the response
     77            return ResponseEntity.ok(user);
    7978        } catch (UserNotFoundException e) {
    80             return ResponseEntity.status(HttpStatus.NOT_FOUND).build(); // Return a 404 if user is not found
     79            return ResponseEntity.status(HttpStatus.NOT_FOUND).build();
    8180        } catch (Exception e) {
    82             return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).build(); // Return a 500 for other errors
     81            return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).build();
    8382        }
    8483    }
Note: See TracChangeset for help on using the changeset viewer.