TokenHistoryRepo.java 1.4 KB

1234567891011121314151617181920212223242526272829303132
  1. package com.izouma.nineth.repo;
  2. import com.izouma.nineth.TokenHistory;
  3. import org.springframework.data.domain.Page;
  4. import org.springframework.data.domain.Pageable;
  5. import org.springframework.data.jpa.repository.JpaRepository;
  6. import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
  7. import org.springframework.data.jpa.repository.Modifying;
  8. import org.springframework.data.jpa.repository.Query;
  9. import javax.transaction.Transactional;
  10. import java.time.LocalDateTime;
  11. import java.util.List;
  12. public interface TokenHistoryRepo extends JpaRepository<TokenHistory, Long>, JpaSpecificationExecutor<TokenHistory> {
  13. List<TokenHistory> findByTokenIdOrderByCreatedAtDesc(String tokenId);
  14. @Query("select t from TokenHistory t where t.toUserId = ?1 or t.fromUserId = ?1 order by t.createdAt desc")
  15. Page<TokenHistory> userHistory(Long userId, Pageable pageable);
  16. @Query("select t from TokenHistory t where t.projectId = ?2 and (t.toUserId = ?1 or t.fromUserId = ?1) order by t.createdAt desc")
  17. Page<TokenHistory> userHistoryAndProjectId(Long userId, int projectId, Pageable pageable);
  18. List<TokenHistory> findAllByPriceIsNotNullAndOperationLikeAndCreatedAtBetween(String operation, LocalDateTime start, LocalDateTime end);
  19. @Transactional
  20. @Modifying
  21. int deleteByTokenId(String tokenId);
  22. @Query("select t from TokenHistory t where t.fromUserId = t.toUserId")
  23. List<TokenHistory> findError();
  24. }