user nules
This commit is contained in:
@ -12,29 +12,25 @@ import org.springframework.data.repository.query.Param;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
/**
|
||||
* UserRepository.getByAuthority:
|
||||
* Return list of:
|
||||
* SELECT * FROM User WHERE email = i.
|
||||
* UserRepository.getByAuthority: Return list of: SELECT * FROM User WHERE email
|
||||
* = i.
|
||||
*
|
||||
* Where i, ?1 are equale to variables.
|
||||
* Where i, ?1 are equale to variables.
|
||||
*
|
||||
* UserRepository.getByToken:
|
||||
* Return list of:
|
||||
* SELECT * FROM User WHERE token = i.
|
||||
* UserRepository.getByToken: Return list of: SELECT * FROM User WHERE token =
|
||||
* i.
|
||||
*
|
||||
* Where i, ?1 are equale to variables.
|
||||
* Where i, ?1 are equale to variables.
|
||||
*
|
||||
* UserRepository.searchForUsers:
|
||||
* Return list of:
|
||||
* SELECT * FROM User WHERE (name LIKE %?1% OR surname LIKE %?1%).
|
||||
* UserRepository.searchForUsers: Return list of: SELECT * FROM User WHERE (name
|
||||
* LIKE %?1% OR surname LIKE %?1%).
|
||||
*
|
||||
* Where i, ?1 are equale to variables.
|
||||
* Where i, ?1 are equale to variables.
|
||||
*
|
||||
* UserRepository.searchForUsers with role:
|
||||
* Return list of:
|
||||
* SELECT * FROM User WHERE (name LIKE %?1% OR surname LIKE %?1%) AND role=?2").
|
||||
* UserRepository.searchForUsers with role: Return list of: SELECT * FROM User
|
||||
* WHERE (name LIKE %?1% OR surname LIKE %?1%) AND role=?2").
|
||||
*
|
||||
* Where i, ?1 are equale to variables.
|
||||
* Where i, ?1 are equale to variables.
|
||||
*/
|
||||
|
||||
@Repository
|
||||
@ -51,6 +47,9 @@ public interface UserRepository extends JpaRepository<User, Long> {
|
||||
@Query("FROM User WHERE (name LIKE %?1% OR surname LIKE %?1%) AND role=?2")
|
||||
List<User> searchForUsers(@Param("query") String query, @Param("role") UserRoles role);
|
||||
|
||||
@Query("FROM User WHERE role=?1")
|
||||
List<User> getAllByRole(@Param("role") UserRoles role);
|
||||
|
||||
@Query("FROM User WHERE usosId = ?1")
|
||||
Optional<User> getByUsosId(@Param("usosId") String usosId);
|
||||
}
|
@ -77,4 +77,8 @@ public class UserService {
|
||||
return this.repo.findById(userId);
|
||||
}
|
||||
|
||||
public List<User> getAllStudents() {
|
||||
return this.repo.getAllByRole(UserRoles.STUDENT);
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user