package com.crm.custom.dao.repository;

import com.crm.rely.backend.dao.repository.BaseRepository;
import com.crm.rely.backend.model.pojo.table.CustomBankTable;
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 CustomBankRepository extends BaseRepository<CustomBankTable> {


    List<CustomBankTable> getAllByCustomId(Long customId);

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

    @Lock(LockModeType.PESSIMISTIC_WRITE)
    CustomBankTable getFirstByCustomId(Long customId);

    List<CustomBankTable> findAllByCustomIdAndDefaultBankAndType(Long customId, Integer defaultBank, Integer type);

    @Lock(LockModeType.PESSIMISTIC_WRITE)
    List<CustomBankTable> findAllByCustomIdAndIdIn(Long customId, List<Long> ids);
}
