-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathUserRepository.java
More file actions
45 lines (39 loc) · 1.17 KB
/
UserRepository.java
File metadata and controls
45 lines (39 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package contactapp.security;
import java.util.Optional;
import java.util.UUID;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
/**
* Repository for User entity persistence.
*/
@Repository
public interface UserRepository extends JpaRepository<User, UUID> {
/**
* Finds a user by their username.
*
* @param username the username to search for
* @return an Optional containing the user if found
*/
Optional<User> findByUsername(String username);
/**
* Finds a user by their email address.
*
* @param email the email to search for
* @return an Optional containing the user if found
*/
Optional<User> findByEmail(String email);
/**
* Checks if a user with the given username exists.
*
* @param username the username to check
* @return true if a user with this username exists
*/
boolean existsByUsername(String username);
/**
* Checks if a user with the given email exists.
*
* @param email the email to check
* @return true if a user with this email exists
*/
boolean existsByEmail(String email);
}