保誠-保戶業務員媒合平台
wayne
2021-11-25 e28415e8f6d76ddcf0c936027669c22ed2b2e05d
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
package com.pollex.pam.repository;
 
import com.pollex.pam.domain.User;
import java.time.Instant;
import java.util.List;
import java.util.Optional;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.EntityGraph;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
 
/**
 * Spring Data JPA repository for the {@link User} entity.
 */
@Repository
public interface UserRepository extends JpaRepository<User, Long> {
    String USERS_BY_LOGIN_CACHE = "usersByLogin";
 
    String USERS_BY_EMAIL_CACHE = "usersByEmail";
 
    Optional<User> findOneByActivationKey(String activationKey);
 
    List<User> findAllByActivatedIsFalseAndActivationKeyIsNotNullAndCreatedDateBefore(Instant dateTime);
 
    Optional<User> findOneByResetKey(String resetKey);
 
    Optional<User> findOneByEmailIgnoreCase(String email);
 
    Optional<User> findOneByLogin(String login);
 
    @EntityGraph(attributePaths = "authorities")
    @Cacheable(cacheNames = USERS_BY_LOGIN_CACHE)
    Optional<User> findOneWithAuthoritiesByLogin(String login);
 
    @EntityGraph(attributePaths = "authorities")
    @Cacheable(cacheNames = USERS_BY_EMAIL_CACHE)
    Optional<User> findOneWithAuthoritiesByEmailIgnoreCase(String email);
 
    Page<User> findAllByIdNotNullAndActivatedIsTrue(Pageable pageable);
}