Class UserService
java.lang.Object
com.equipmentrental.equipment_rental_system.service.UserService
-
Constructor Summary
ConstructorsConstructorDescriptionUserService(UserRepository userRepository, BookingRepository bookingRepository) -
Method Summary
Modifier and TypeMethodDescriptionvoiddeleteById(Long userId) Deletes a user if they have no active (confirmed) bookings.findAll()Returns all registered users.Finds a user by their ID.findByUsername(String username) Finds a user by their unique username.Saves a new or updated user.
-
Constructor Details
-
UserService
-
-
Method Details
-
findAll
-
findById
Finds a user by their ID.- Parameters:
userId- the ID of the user to find- Returns:
- the user
- Throws:
ResourceNotFoundException- if no user exists with the given ID
-
findByUsername
Finds a user by their unique username.- Parameters:
username- the username to search for- Returns:
- the user
- Throws:
ResourceNotFoundException- if no user exists with the given username
-
save
-
deleteById
Deletes a user if they have no active (confirmed) bookings.- Parameters:
userId- the ID of the user to delete- Throws:
ResourceNotFoundException- if no user exists with the given IDDeletionBlockedException- if the user has active bookings
-