package com.xhpc.evcs.jpa;

import com.xhpc.evcs.domain.AuthSecretToken;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.query.QueryByExampleExecutor;
import org.springframework.stereotype.Repository;

import java.util.Date;
import java.util.List;
import java.util.Optional;

@Repository
public interface AuthSecretTokenRepository extends JpaRepository<AuthSecretToken, String>,
        QueryByExampleExecutor<AuthSecretToken>, JpaSpecificationExecutor<AuthSecretToken> {


    Optional<AuthSecretToken> findByOperatorIdAndSecretTokenType(String operatorId, String secretTokenType);

    Optional<AuthSecretToken> findByOperatorId3irdptyAndSecretTokenTypeAndTokenExpiryGreaterThan(String operatorId,
                                                                                                 String secretTokenType,
                                                                                                 Date time);

    Optional<AuthSecretToken> findByStatusAndOperatorId3irdptyAndSecretTokenTypeAndTokenExpiryGreaterThan(Integer status,
                                                                                                          String operatorId,
                                                                                                 String secretTokenType,
                                                                                                 Date time);


    Optional<AuthSecretToken> findByOperatorId3irdptyAndOperatorIdAndSecretTokenType(String operatorId3irdpty,
                                                                                     String operatorID,
                                                                                     String secretTokenTypeIn);


    Optional<AuthSecretToken> findByStatusAndOperatorId3irdptyAndOperatorIdAndSecretTokenType(
                                                                                     Integer status,
                                                                                     String operatorId3irdpty,
                                                                                     String operatorID,
                                                                                     String secretTokenTypeIn);

    Optional<AuthSecretToken> findByOperatorId3irdptyAndSecretTokenTypeAndOperatorSecret(String operatorID3irdpty,
                                                                                         String secretTokenType,
                                                                                         String operatorSecret);

    Optional<AuthSecretToken> findByStatusAndOperatorId3irdptyAndSecretTokenTypeAndOperatorSecret(
                                                                                        Integer status,
                                                                                        String operatorID3irdpty,
                                                                                         String secretTokenType,
                                                                                         String operatorSecret);

    Optional<AuthSecretToken> findByOperatorId3irdptyAndSecretTokenType(String operatorId, String secretTokenType);

    Optional<AuthSecretToken> findByStatusAndOperatorId3irdptyAndSecretTokenType(Integer status,String operatorId, String secretTokenType);
    List<AuthSecretToken> findBySecretTokenType(String secretTokenType);
    List<AuthSecretToken> findBySecretTokenTypeAndOperatorId3irdptyNot(String secretTokenType,String operatorId3irdpty);
}
