Package com.mindstore.backend.controller
Class UserController
java.lang.Object
com.mindstore.backend.controller.UserController
REST controller for user actions
-
Constructor Summary
ConstructorsConstructorDescriptionUserController(UserService userService, org.springframework.security.crypto.password.PasswordEncoder passwordEncoder, org.springframework.security.core.userdetails.UserDetailsService userDetailsService) user controller -
Method Summary
Modifier and TypeMethodDescriptionorg.springframework.http.ResponseEntity<?> deleteUser(Long userId) function: delete a user that is not neededfunction: return all users available, usually this will be only 1-2 users note: the initializer creates a test user.getRecentUser(String email, LocalDateTime createdAt) function: get a user based on their email and the date they were created in the database.getUserById(Long Id) function: get a singular user
-
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 userspasswordEncoder- for encoding user passwordsuserDetailsService- spring user details
-
-
Method Details
-
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
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 usercreatedAt- 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
-