StudentLoanManagement
com.student_loan.controller.UserController Class Reference

Public Member Functions

 UserController (UserService userService, ItemService itemService)
 
ResponseEntity< List< User > > getAllUsers (@RequestParam("token") String token)
 
ResponseEntity<?> login (@RequestBody CredentialsDTO credentials)
 
ResponseEntity< String > logout (@RequestParam("token") String token)
 
ResponseEntity< UserDTO > getUserById (@PathVariable Long id)
 
ResponseEntity< UserRecord > getUserRecordById (@PathVariable Long id)
 
ResponseEntity< List< LoanAndItemDto > > getItemsLentByUser (@PathVariable Long userId)
 
ResponseEntity< List< LoanAndItemDto > > getItemsBorrowedByUser (@PathVariable Long userId)
 
ResponseEntity< User > updateUser (@PathVariable Long id, @RequestBody UserRecord userData, @RequestParam("token") String token)
 
ResponseEntity< String > register (@RequestBody RegistrationRecord userDTO)
 
ResponseEntity< String > deleteUser (@PathVariable Long id, @RequestParam("token") String token)
 
User registerRecordToUser (RegistrationRecord data)
 
User userRecordToUser (UserRecord userDTO)
 
UserRecord userToUserRecord (User user)
 

Detailed Description

Controller class for managing users in the system. Handles HTTP requests related to user operations such as creating, updating, deleting, and retrieving users.

Definition at line 30 of file UserController.java.

Constructor & Destructor Documentation

◆ UserController()

com.student_loan.controller.UserController.UserController ( UserService  userService,
ItemService  itemService 
)

Constructor for UserController.

Parameters
userServiceService for user operations.

Definition at line 41 of file UserController.java.

Member Function Documentation

◆ deleteUser()

ResponseEntity< String > com.student_loan.controller.UserController.deleteUser ( @PathVariable Long  id,
@RequestParam("token") String  token 
)

Deletes a user by their ID.

Parameters
idThe ID of the user.
tokenThe authentication token.
Returns
ResponseEntity indicating the result of the operation.

Definition at line 194 of file UserController.java.

◆ getAllUsers()

ResponseEntity< List< User > > com.student_loan.controller.UserController.getAllUsers ( @RequestParam("token") String  token)

Retrieves all users in the system.

Parameters
tokenThe authentication token.
Returns
ResponseEntity containing a list of all users.

Definition at line 52 of file UserController.java.

◆ getItemsBorrowedByUser()

ResponseEntity< List< LoanAndItemDto > > com.student_loan.controller.UserController.getItemsBorrowedByUser ( @PathVariable Long  userId)

Definition at line 142 of file UserController.java.

◆ getItemsLentByUser()

ResponseEntity< List< LoanAndItemDto > > com.student_loan.controller.UserController.getItemsLentByUser ( @PathVariable Long  userId)

Definition at line 135 of file UserController.java.

◆ getUserById()

ResponseEntity< UserDTO > com.student_loan.controller.UserController.getUserById ( @PathVariable Long  id)

Retrieves a user by their ID.

Parameters
idThe ID of the user.
Returns
ResponseEntity containing the user data.

Definition at line 95 of file UserController.java.

◆ getUserRecordById()

ResponseEntity< UserRecord > com.student_loan.controller.UserController.getUserRecordById ( @PathVariable Long  id)

Retrieves a user by their ID (versión completa usando UserRecord).

GET /users/{id}/record

Parameters
idThe ID of the user.
Returns
ResponseEntity containing el UserRecord con todos los campos.

Definition at line 118 of file UserController.java.

◆ login()

ResponseEntity<?> com.student_loan.controller.UserController.login ( @RequestBody CredentialsDTO  credentials)

Authenticates a user and generates a token.

Parameters
credentialsThe user's credentials.
Returns
ResponseEntity containing the authentication token or an error message.

Definition at line 66 of file UserController.java.

◆ logout()

ResponseEntity< String > com.student_loan.controller.UserController.logout ( @RequestParam("token") String  token)

Logs out a user by invalidating their token.

Parameters
tokenThe authentication token.
Returns
ResponseEntity indicating the result of the operation.

Definition at line 81 of file UserController.java.

◆ register()

ResponseEntity< String > com.student_loan.controller.UserController.register ( @RequestBody RegistrationRecord  userDTO)

Registers a new user.

Parameters
userDTOThe registration data.
Returns
ResponseEntity indicating the result of the operation.

Definition at line 178 of file UserController.java.

◆ registerRecordToUser()

User com.student_loan.controller.UserController.registerRecordToUser ( RegistrationRecord  data)

Converts a RegistrationRecord to a User entity.

Parameters
dataThe registration record.
Returns
The converted User entity.

Definition at line 212 of file UserController.java.

◆ updateUser()

ResponseEntity< User > com.student_loan.controller.UserController.updateUser ( @PathVariable Long  id,
@RequestBody UserRecord  userData,
@RequestParam("token") String  token 
)

Updates a user by their ID.

Parameters
idThe ID of the user.
userDataThe updated user data.
tokenThe authentication token.
Returns
ResponseEntity containing the updated user or an error status.

Definition at line 156 of file UserController.java.

◆ userRecordToUser()

User com.student_loan.controller.UserController.userRecordToUser ( UserRecord  userDTO)

Converts a UserRecord to a User entity.

Parameters
userDTOThe user record.
Returns
The converted User entity.

Definition at line 233 of file UserController.java.

◆ userToUserRecord()

UserRecord com.student_loan.controller.UserController.userToUserRecord ( User  user)

Definition at line 249 of file UserController.java.


The documentation for this class was generated from the following file: