TokenHistoryRepo.java 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  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.util.Collection;
  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.toUserId = ?2 or t.fromUserId = ?1 order by t.createdAt desc")
  17. Page<TokenHistory> userHistoryTo(Long userId, Long toUserId, Pageable pageable);
  18. @Query("select t from TokenHistory t where t.toUserId = ?1 or t.fromUserId = ?2 order by t.createdAt desc")
  19. Page<TokenHistory> userHistoryFrom(Long userId, Long fromUserId, Pageable pageable);
  20. @Query("select t from TokenHistory t where t.toUserId = ?1 or t.fromUserId = ?1 order by t.createdAt desc")
  21. List<TokenHistory> userHistory(Long userId);
  22. @Query("select t from TokenHistory t where t.toUserId in ?1")
  23. List<TokenHistory> userBuy(Collection<Long> userId);
  24. @Transactional
  25. @Modifying
  26. int deleteByTokenId(String tokenId);
  27. @Query("select t from TokenHistory t where t.fromUserId = t.toUserId")
  28. List<TokenHistory> findError();
  29. List<TokenHistory> findByOperationAndPriceNull(String oper);
  30. }