package com.uas.finance.dao;

import com.uas.finance.model.SellerQuota;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * 买方用户额度数据操作层
 * created by shicr on 2018/1/16
 **/
@Repository
public interface SellerQuotaDao extends JpaRepository<SellerQuota, Long> {

    /**
     * 根据申请单id和买方名查找买方额度
     *
     * @param faid
     * @param custname
     * @return
     */
    @Query(value = "from SellerQuota where faid=:faid and cq_custname=:custname and cq_status = null")
    SellerQuota findByFaidAndCq_custname(@Param("faid") Long faid, @Param("custname") String custname);

    /**
     * 找到某客户下面的所有买方
     *
     * @param uu
     * @return
     */
    @Query(value = " from SellerQuota where cq_uu = :uu and cq_status = null")
    List<SellerQuota> findByCq_uu(@Param("uu") Long uu);

    /**
     * 找到申请单下的所有买方额度
     *
     * @param faid
     * @return
     */
    List<SellerQuota> findByFaid(Long faid);
}
