package com.ecep.contract.ds.vendor.repository;

import java.util.List;
import java.util.Optional;

import org.springframework.data.jpa.repository.Modifying;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import com.ecep.contract.ds.MyRepository;
import com.ecep.contract.model.Company;
import com.ecep.contract.model.CompanyVendor;
import com.ecep.contract.model.VendorCatalog;

/**
 * 供应商 Repository
 */
@Repository
public interface CompanyVendorRepository extends MyRepository<CompanyVendor, Integer> {

    List<CompanyVendor> findAllByCatalog(VendorCatalog catalog);

    List<CompanyVendor> findAllByCatalogId(Integer catalogId);

    Optional<CompanyVendor> findByCompany(Company company);

    @Modifying
    @Transactional
    int deleteAllByCompany(Company company);
}
