Class UserController

java.lang.Object
com.mindstore.backend.controller.UserController

@RestController @RequestMapping("/users") public class UserController extends Object
REST controller for user actions
  • Constructor Details

    • UserController

      public UserController(UserService userService, org.springframework.security.crypto.password.PasswordEncoder passwordEncoder, org.springframework.security.core.userdetails.UserDetailsService userDetailsService)
      user controller
      Parameters:
      userService - for managing users
      passwordEncoder - for encoding user passwords
      userDetailsService - spring user details
  • Method Details

    • getAllUsers

      @GetMapping("/all") public List<User> getAllUsers()
      function: return all users available, usually this will be only 1-2 users note: the initializer creates a test user. This user should always be there.
      Returns:
      a list of users
    • getUserById

      @GetMapping("/id/{Id}") public Optional<User> getUserById(@PathVariable Long Id)
      function: get a singular user
      Parameters:
      Id - of the user that is requested
      Returns:
      Optional User
    • getRecentUser

      @GetMapping("/recent-users") public User getRecentUser(@RequestParam String email, @RequestParam @DateTimeFormat(iso=DATE_TIME) LocalDateTime createdAt)
      function: get a user based on their email and the date they were created in the database. For example, you might want to check if user with email text@text.at was created before 2024-07-01T14:30:00
      Parameters:
      email - the email of the user
      createdAt - the time of creation, in ISO time format
      Returns:
      User
    • deleteUser

      @DeleteMapping("/{userId}") public org.springframework.http.ResponseEntity<?> deleteUser(@PathVariable Long userId)
      function: delete a user that is not needed
      Parameters:
      userId - the id of the user that is supposed to be deleted
      Returns:
      ok ---> if successfull, else: 401