package com.crm.pay.dao.repository;

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

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

    SysRemittanceChannelTable getFirstById(Long id);

    boolean existsByCode(String code);

    /**
     * 根据是否启用获取所有通道信息
     *
     * @param valid
     * @return
     */
    List<SysRemittanceChannelTable> getAllByValidOrderBySubIndex(Integer valid);

    /**
     * 根据code获取通道信息
     *
     * @param code
     * @param valid
     * @return
     */
    SysRemittanceChannelTable getFirstByCodeAndValid(String code, Integer valid);


    SysRemittanceChannelTable getFirstByCode(String code);

}
