package com.uas.platform.b2b.dao;

import java.util.List;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import com.uas.platform.b2b.model.PurchaseOrder;

@Repository
public interface PurchaseOrderDao extends JpaSpecificationExecutor<PurchaseOrder>, JpaRepository<PurchaseOrder, Long> {

	/**
	 * @param enUU
	 *            买方企业ID
	 * @param code
	 *            订单号
	 * @return
	 */
	public List<PurchaseOrder> findByEnUUAndCode(long enUU, String code);

	/**
	 * 按采购单的供应商企业ID和采购单状态来统计条数
	 * 
	 * @param vendUU
	 * @param status
	 * @return
	 */
	@Query("select count(o) from PurchaseOrder o where o.vendUU = :vendUU and o.status = :status")
	public int getCountByVendUUAndStatus(@Param("vendUU") long vendUU, @Param("status") short status);
}
