package com.crm.pay.dao.repository;

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

import javax.persistence.LockModeType;
import java.util.List;

/**
 * @author: houn
 */
@Repository
public interface FinanceWithdrawRepository extends BaseRepository<FinanceWithdrawTable> {
    List<FinanceWithdrawTable> getAllByCustomId(Long customId);

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

    @Lock(LockModeType.PESSIMISTIC_WRITE)
    FinanceWithdrawTable findFirstBySerial(String serial);

    @Lock(LockModeType.PESSIMISTIC_WRITE)
    List<FinanceWithdrawTable> findAllByIdIn(List<Long> ids);

    boolean existsByLoginAndCustomIdAndStatus(Long login, Long customId, Integer status);

    FinanceWithdrawTable getFirstByChannelSerial(String channelSerial);

    FinanceWithdrawTable getFirstBySerial(String serial);

    FinanceWithdrawTable getFirstById(Long id);
}
