package com.crm.ucard.dao.repository;

import com.crm.rely.backend.core.pojo.table.ucard.CardKycStatusTable;
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 CardKycStatusRepository extends BaseRepository<CardKycStatusTable> {

    @Lock(LockModeType.PESSIMISTIC_WRITE)
    CardKycStatusTable findByUniqueIdAndCardTypeId(String uniqueId, Integer cardTypeId);

    @Lock(LockModeType.PESSIMISTIC_WRITE)
    CardKycStatusTable findFirstByUniqueIdAndStatus(String uniqueId, Integer status);

    @Lock(LockModeType.PESSIMISTIC_WRITE)
    CardKycStatusTable findFirstByUniqueId(String uniqueId);

    @Lock(LockModeType.PESSIMISTIC_WRITE)
    CardKycStatusTable findFirstById(Long id);

    CardKycStatusTable getFirstByUniqueIdAndStatus(String uniqueId, Integer status);

}
