AssetRepo.java 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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> findByTokenIdInAndProjectId(Iterable<String> tokenId, int projectId);
  24. List<Asset> findByTokenIdOrderByCreatedAt(String tokenId);
  25. List<Asset> findByOrderId(Long orderId);
  26. @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")
  27. Optional<Asset> findChild(Long id);
  28. @Query("select a from Asset a join User u on a.userId = u.id where a.consignment = true and u.settleAccountId is null")
  29. List<Asset> findNoAccount();
  30. List<Asset> findByUserId(Long userId);
  31. Asset findFirstByTokenIdAndCreatedAtAfterOrderByCreatedAt(String tokenId, LocalDateTime time);
  32. }