package com.izouma.nineth.repo; import com.izouma.nineth.TokenHistory; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.JpaSpecificationExecutor; import org.springframework.data.jpa.repository.Modifying; import org.springframework.data.jpa.repository.Query; import javax.transaction.Transactional; import java.time.LocalDateTime; import java.util.List; public interface TokenHistoryRepo extends JpaRepository, JpaSpecificationExecutor { List findByTokenIdOrderByCreatedAtDesc(String tokenId); @Query("select t from TokenHistory t where t.toUserId = ?1 or t.fromUserId = ?1 order by t.createdAt desc") Page userHistory(Long userId, Pageable pageable); @Query("select t from TokenHistory t where t.projectId = ?2 and (t.toUserId = ?1 or t.fromUserId = ?1) order by t.createdAt desc") Page userHistoryAndProjectId(Long userId, int projectId, Pageable pageable); List findAllByPriceIsNotNullAndOperationLikeAndCreatedAtBetween(String operation, LocalDateTime start, LocalDateTime end); @Transactional @Modifying int deleteByTokenId(String tokenId); @Query("select t from TokenHistory t where t.fromUserId = t.toUserId") List findError(); }