Package com.wilfredmorgan.api.services
Class UserServiceImpl
- java.lang.Object
-
- com.wilfredmorgan.api.services.UserServiceImpl
-
- All Implemented Interfaces:
UserService
@Transactional @Service("userService") public class UserServiceImpl extends java.lang.Object implements UserServiceImplements UserService interface
-
-
Constructor Summary
Constructors Constructor Description UserServiceImpl()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voiddelete(long id)Deletes the user record based off the provided primary keyvoiddeleteAll()Deletes all records and their associated records from the databasejava.util.List<User>findAll()Returns a list of all the usersjava.util.List<User>findAllByLastName(java.lang.String lastname)A list of users whose last name contains the given substringUserfindByEmail(java.lang.String email)Returns the user with the given email addressUserfindById(long id)Returns the user with the given primary keyUserfindByUsername(java.lang.String username)Returns the user with the given usernamejava.util.List<User>findUsernamesContaining(java.lang.String username)A list of users whose username contains the given substringUsersave(User user)Given a complete user object, saves that user object in the database If a primary key is provided, the record is completely replaced If no primary key is provided, one is automatically generated and the record is added to the databaseUserupdate(User user, long id)Updates the provided fields in the user record referenced by the primary key
-
-
-
Method Detail
-
findAll
public java.util.List<User> findAll()
Description copied from interface:UserServiceReturns a list of all the users- Specified by:
findAllin interfaceUserService- Returns:
- List of users
-
findById
public User findById(long id)
Description copied from interface:UserServiceReturns the user with the given primary key- Specified by:
findByIdin interfaceUserService- Parameters:
id- The primary key (long) of the user you seek- Returns:
- User object with the given primary key or throws an exception if not found
-
findByUsername
public User findByUsername(java.lang.String username)
Description copied from interface:UserServiceReturns the user with the given username- Specified by:
findByUsernamein interfaceUserService- Parameters:
username- The username (String) of the user you seek- Returns:
- User object with given username or throws an exception if not found
-
findByEmail
public User findByEmail(java.lang.String email)
Description copied from interface:UserServiceReturns the user with the given email address- Specified by:
findByEmailin interfaceUserService- Parameters:
email- The email (String) of the user you seek- Returns:
- User object with the given email or throws an exception if not found
-
findUsernamesContaining
public java.util.List<User> findUsernamesContaining(java.lang.String username)
Description copied from interface:UserServiceA list of users whose username contains the given substring- Specified by:
findUsernamesContainingin interfaceUserService- Parameters:
username- The substring (String) containing the username- Returns:
- List of users whose username contains the given substring
-
findAllByLastName
public java.util.List<User> findAllByLastName(java.lang.String lastname)
Description copied from interface:UserServiceA list of users whose last name contains the given substring- Specified by:
findAllByLastNamein interfaceUserService- Parameters:
lastname- The substring (String) containing the last name- Returns:
- List of users whose last name contains the given substring
-
save
public User save(User user)
Description copied from interface:UserServiceGiven a complete user object, saves that user object in the database If a primary key is provided, the record is completely replaced If no primary key is provided, one is automatically generated and the record is added to the database- Specified by:
savein interfaceUserService- Parameters:
user- The user object (User) to be saved- Returns:
- The saved user object including any automatically generated fields
-
update
public User update(User user, long id)
Description copied from interface:UserServiceUpdates the provided fields in the user record referenced by the primary key- Specified by:
updatein interfaceUserService- Parameters:
user- Only the user fields to be updatedid- The primary key (long) of the user to be updated- Returns:
- Update user object
-
delete
public void delete(long id)
Description copied from interface:UserServiceDeletes the user record based off the provided primary key- Specified by:
deletein interfaceUserService- Parameters:
id- The primary key (long) of the user to be deleted
-
deleteAll
public void deleteAll()
Description copied from interface:UserServiceDeletes all records and their associated records from the database- Specified by:
deleteAllin interfaceUserService
-
-