Class UserController
java.lang.Object
com.ntu.fdae.group1.bto.controllers.user.UserController
Controller class for handling user-related operations in the BTO Management
System.
This controller acts as an intermediary between the user interface and the business logic layer, providing methods for: - Retrieving user information - Formatting user data for display - Managing user-related requests
The controller delegates complex business logic to the IUserService, focusing on request handling and response formatting.
-
Constructor Summary
ConstructorsConstructorDescriptionUserController
(IUserService userService) Constructs a UserController with the specified user service. -
Method Summary
Modifier and TypeMethodDescriptionRetrieves a user by their NRIC.getUserName
(String nric) Retrieves the name of a user identified by their NRIC.getUserNamesForList
(Collection<String> nrics) Retrieves names for a collection of users identified by their NRICs.
-
Constructor Details
-
UserController
Constructs a UserController with the specified user service.- Parameters:
userService
- The service that provides user-related functionality- Throws:
NullPointerException
- if userService is null
-
-
Method Details
-
getUser
Retrieves a user by their NRIC.This method provides a simple wrapper around the service method, with additional null checking to prevent null pointer exceptions.
- Parameters:
nric
- The NRIC of the user to find- Returns:
- The User object, or null if not found
-
getUserName
Retrieves the name of a user identified by their NRIC.This method provides a simple wrapper around the service method, with additional null checking to prevent null pointer exceptions.
- Parameters:
nric
- The NRIC of the user to find- Returns:
- The user's name, or "N/A" if the user or their name is not found
-
getUserNamesForList
Retrieves names for a collection of users identified by their NRICs.This method is specifically designed for UI list displays that need to show user names for multiple users efficiently.
- Parameters:
nrics
- A collection of NRICs for which to retrieve names- Returns:
- A map of NRICs to user names
-