| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- 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<Asset, Long>, JpaSpecificationExecutor<Asset> {
- @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<Asset> findByCollectionId(Long collectionId);
- List<Asset> findByCollectionIdAndStatusIn(Long collectionId, Iterable<AssetStatus> statuses);
- List<Asset> findByCreatedAtBefore(LocalDateTime localDateTime);
- List<Asset> findByConsignmentTrue();
- List<Asset> findByTokenIdIn(Iterable<String> tokenId);
- List<Asset> findByTokenIdOrderByCreatedAt(String tokenId);
- List<Asset> 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<Asset> 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<Asset> findNoAccount();
- List<Asset> findByUserId(Long userId);
- Asset findFirstByTokenIdAndCreatedAtAfterOrderByCreatedAt(String tokenId, LocalDateTime time);
- List<Asset> findByTxHashIsNullAndTokenIdNotNullAndCreatedAtBefore(LocalDateTime time);
- @Query("select id from Asset where status = ?1")
- List<Long> findAllByStatus(AssetStatus status);
- @Query(nativeQuery = true, value = "select asset.* from asset " +
- "join collection_info on asset.collection_id = collection_info.id " +
- "where asset.number > collection_info.total and status = 'NORMAL'")
- List<Asset> findOverNumber();
- @Query(nativeQuery = true, value = "select * from asset " +
- "where name = ?1 " +
- "and number <= ?2 and public_show = false and consignment = false " +
- "and modified_at < date_sub(now(), INTERVAL 7 DAY) " +
- "and number > 5 and status = 'NORMAL' " +
- "order by modified_at")
- List<Asset> findColdAsset(String name, int number);
- }
|