Package com.jangular.backend.controller
Class UserController
java.lang.Object
com.jangular.backend.controller.UserController
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionorg.springframework.http.ResponseEntity<UserDTO> addRoleToUser(Long id, Map<String, String> roleRequest) Add role to user (admin only)org.springframework.http.ResponseEntity<Void> changePassword(Long id, Map<String, String> passwordRequest) Change user passwordorg.springframework.http.ResponseEntity<Void> deleteUser(Long id) Soft delete a user (admin only)org.springframework.http.ResponseEntity<List<UserLoginHistory>> Get active sessionsGet all users (admin only)org.springframework.http.ResponseEntity<UserDTO> getCurrentUser(Long userId) Get current user informationorg.springframework.http.ResponseEntity<UserDTO> getUserById(Long id) Get user by ID (admin only)org.springframework.http.ResponseEntity<List<UserLoginHistory>> Get user login historyorg.springframework.http.ResponseEntity<List<UserLoginHistory>> getUserLoginHistoryRange(Long id, String startDate, String endDate) Get user login history for a specific date rangeorg.springframework.http.ResponseEntity<UserDTO> removeRoleFromUser(Long id, String roleName) Remove role from user (admin only)org.springframework.http.ResponseEntity<UserDTO> updateUser(Long id, @Valid UserDTO userDTO) Update user information
-
Constructor Details
-
UserController
public UserController()
-
-
Method Details
-
getCurrentUser
@GetMapping("/me") public org.springframework.http.ResponseEntity<UserDTO> getCurrentUser(@RequestAttribute("userId") Long userId) Get current user information -
getUserById
@GetMapping("/{id}") @PreAuthorize("hasRole(\'ROLE_ADMIN\')") public org.springframework.http.ResponseEntity<UserDTO> getUserById(@PathVariable Long id) Get user by ID (admin only) -
getAllUsers
@GetMapping @PreAuthorize("hasRole(\'ROLE_ADMIN\')") public org.springframework.http.ResponseEntity<List<UserDTO>> getAllUsers()Get all users (admin only) -
updateUser
@PutMapping("/{id}") @PreAuthorize("@securityUtils.isCurrentUser(#id) or hasRole(\'ROLE_ADMIN\')") public org.springframework.http.ResponseEntity<UserDTO> updateUser(@PathVariable Long id, @Valid @RequestBody @Valid UserDTO userDTO) Update user information -
changePassword
@PostMapping("/{id}/change-password") @PreAuthorize("@securityUtils.isCurrentUser(#id) or hasRole(\'ROLE_ADMIN\')") public org.springframework.http.ResponseEntity<Void> changePassword(@PathVariable Long id, @RequestBody Map<String, String> passwordRequest) Change user password -
deleteUser
@DeleteMapping("/{id}") @PreAuthorize("hasRole(\'ROLE_ADMIN\')") public org.springframework.http.ResponseEntity<Void> deleteUser(@PathVariable Long id) Soft delete a user (admin only) -
addRoleToUser
@PostMapping("/{id}/roles") @PreAuthorize("hasRole(\'ROLE_ADMIN\')") public org.springframework.http.ResponseEntity<UserDTO> addRoleToUser(@PathVariable Long id, @RequestBody Map<String, String> roleRequest) Add role to user (admin only) -
removeRoleFromUser
@DeleteMapping("/{id}/roles/{roleName}") @PreAuthorize("hasRole(\'ROLE_ADMIN\')") public org.springframework.http.ResponseEntity<UserDTO> removeRoleFromUser(@PathVariable Long id, @PathVariable String roleName) Remove role from user (admin only) -
getUserLoginHistory
@GetMapping("/{id}/login-history") @PreAuthorize("@securityUtils.isCurrentUser(#id) or hasRole(\'ROLE_ADMIN\')") public org.springframework.http.ResponseEntity<List<UserLoginHistory>> getUserLoginHistory(@PathVariable Long id) Get user login history -
getUserLoginHistoryRange
@GetMapping("/{id}/login-history/range") @PreAuthorize("@securityUtils.isCurrentUser(#id) or hasRole(\'ROLE_ADMIN\')") public org.springframework.http.ResponseEntity<List<UserLoginHistory>> getUserLoginHistoryRange(@PathVariable Long id, @RequestParam String startDate, @RequestParam(required=false) String endDate) Get user login history for a specific date range -
getActiveSessions
@GetMapping("/{id}/active-sessions") @PreAuthorize("@securityUtils.isCurrentUser(#id) or hasRole(\'ROLE_ADMIN\')") public org.springframework.http.ResponseEntity<List<UserLoginHistory>> getActiveSessions(@PathVariable Long id) Get active sessions
-