package com.xhpc.evcs.jpa;

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

import java.time.Instant;
import java.util.List;

@Repository
public interface XhpcInternetUserRepository extends JpaRepository<XhpcInternetUser, Long>,
        QueryByExampleExecutor<XhpcInternetUser>, JpaSpecificationExecutor<XhpcInternetUser> {

    XhpcInternetUser findByOperatorIdEvcsLikeAndCooperationStartTimeBeforeAndCooperationEndTimeAfter(String operatorId3rdpty,
                                                                                                     Instant now, Instant now2);

    List<XhpcInternetUser> findByCooperationStartTimeBeforeAndCooperationEndTimeAfter(Instant now, Instant now1);

    @Query("select t.internetUserId from XhpcInternetUser as t where t.operatorIdEvcs like %?1%")
    Long queryDbId(String operatorId3rdpty);

}
