package com.crm.ucard.dao.repository;

import com.crm.rely.backend.core.pojo.table.ucard.CardWalletAddressTable;
import com.crm.rely.backend.dao.repository.BaseRepository;
import org.springframework.data.jpa.repository.Lock;
import org.springframework.stereotype.Repository;

import javax.persistence.LockModeType;

@Repository
public interface CardWalletAddressRepository extends BaseRepository<CardWalletAddressTable> {

    @Lock(value = LockModeType.PESSIMISTIC_WRITE)
    CardWalletAddressTable findFirstByUniqueIdAndBlockchainAndIsReset(String uniqueId, String blockchain, Boolean isReset);

    CardWalletAddressTable getFirstByAddressAndBlockchain(String address, String blockchain);

    @Lock(value = LockModeType.PESSIMISTIC_WRITE)
    CardWalletAddressTable findFirstById(Long id);

    @Lock(value = LockModeType.PESSIMISTIC_WRITE)
    CardWalletAddressTable findFirstByAddressAndBlockchain(String address, String blockchain);


}
