AssetRepo.java 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. package com.izouma.nineth.repo;
  2. import com.izouma.nineth.domain.Asset;
  3. import com.izouma.nineth.enums.AssetStatus;
  4. import org.springframework.data.jpa.repository.JpaRepository;
  5. import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
  6. import org.springframework.data.jpa.repository.Modifying;
  7. import org.springframework.data.jpa.repository.Query;
  8. import javax.transaction.Transactional;
  9. import java.time.LocalDateTime;
  10. import java.util.List;
  11. import java.util.Optional;
  12. public interface AssetRepo extends JpaRepository<Asset, Long>, JpaSpecificationExecutor<Asset> {
  13. @Query("update Asset t set t.del = true where t.id = ?1")
  14. @Modifying
  15. @Transactional
  16. void softDelete(Long id);
  17. long countByIpfsUrlAndStatusNot(String ipfsUrl, AssetStatus status);
  18. List<Asset> findByCollectionId(Long collectionId);
  19. List<Asset> findByCollectionIdAndStatusIn(Long collectionId, Iterable<AssetStatus> statuses);
  20. List<Asset> findByCreatedAtBefore(LocalDateTime localDateTime);
  21. List<Asset> findByConsignmentTrue();
  22. List<Asset> findByTokenIdIn(Iterable<String> tokenId);
  23. List<Asset> findByTokenIdOrderByCreatedAt(String tokenId);
  24. List<Asset> findByOrderId(Long orderId);
  25. @Query("select a from Asset a join Order o on o.assetId = a.id join Asset aa on aa.orderId = o.id where a.id = ?1")
  26. Optional<Asset> findChild(Long id);
  27. @Query("select a from Asset a join User u on a.userId = u.id where a.consignment = true and u.settleAccountId is null")
  28. List<Asset> findNoAccount();
  29. List<Asset> findByTxHash(String hash);
  30. List<Asset> findByIdIn(Iterable<Long> ids);
  31. @Query("select a from Asset a left join TokenHistory t on a.tokenId = t.tokenId where t.id is null")
  32. List<Asset> findByNoHistory();
  33. List<Asset> findByTokenIdAndCreatedAtBetween(String tokenId, LocalDateTime start, LocalDateTime end);
  34. Asset findFirstByTokenId(String tokenId);
  35. Asset findFirstByTxHashIsNullAndTokenIdNotNullAndStatusOrderByCreatedAt(AssetStatus status);
  36. List<Asset> findByTxHashIsNullAndTokenIdNotNullAndCreatedAtBefore(LocalDateTime time);
  37. }