package com.uas.platform.b2b.dao;

import com.uas.platform.b2b.model.SaleTender;
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 java.util.List;

/**
 * Created by dongbw on 17/03/07 14:10.
 */
@Repository
public interface SaleTenderDao extends JpaSpecificationExecutor<SaleTender>,JpaRepository<SaleTender, Long> {

    SaleTender findByEnUUAndVendUUAndCode(Long enUU, Long vendUU, String code);

    List<SaleTender> findByEnUUAndCode(Long enUU, String code);

    @Query(value = "select count(*) from sale$tender t where t.st_enuu = :enUU and t.st_code = :code and t.st_status <> :status", nativeQuery = true)
    Integer findNumOfBIdEn(@Param("enUU")Long enUU, @Param("code")String code, @Param("status")String status);
}
