package com.izouma.nineth.repo; import com.izouma.nineth.domain.Asset; import com.izouma.nineth.enums.AssetStatus; 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; import java.util.Optional; public interface AssetRepo extends JpaRepository, JpaSpecificationExecutor { @Query("update Asset t set t.del = true where t.id = ?1") @Modifying @Transactional void softDelete(Long id); long countByIpfsUrlAndStatusNot(String ipfsUrl, AssetStatus status); List findByCollectionId(Long collectionId); List findByCollectionIdAndStatusIn(Long collectionId, Iterable statuses); List findByCreatedAtBefore(LocalDateTime localDateTime); List findByConsignmentTrue(); List findByTokenIdIn(Iterable tokenId); List findByTokenIdInAndProjectId(Iterable tokenId, int projectId); List findByTokenIdOrderByCreatedAt(String tokenId); List findByOrderId(Long orderId); @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") Optional findChild(Long id); @Query("select a from Asset a join User u on a.userId = u.id where a.consignment = true and u.settleAccountId is null") List findNoAccount(); List findByUserId(Long userId); Asset findFirstByTokenIdAndCreatedAtAfterOrderByCreatedAt(String tokenId, LocalDateTime time); }