package com.crm.globex.dao.repository;

import com.crm.rely.backend.dao.repository.BaseRepository;
import com.crm.rely.backend.model.pojo.table.FinanceTransferTable;
import org.springframework.data.jpa.repository.Lock;
import org.springframework.stereotype.Repository;

import javax.persistence.LockModeType;

/**
 * @author: houn
 */
@Repository
public interface FinanceTransferRepository extends BaseRepository<FinanceTransferTable> {

    @Lock(LockModeType.PESSIMISTIC_WRITE)
    FinanceTransferTable findFirstByStatus(Integer status);

    @Lock(LockModeType.PESSIMISTIC_WRITE)
    FinanceTransferTable findFirstByDepositStatusAndWithdrawStatusAndStatus(Integer depositStatus, Integer withdrawStatus, Integer status);

    @Lock(LockModeType.PESSIMISTIC_WRITE)
    FinanceTransferTable findFirstBySerial(String serial);
}
