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.ds.company.model.Company;
import com.ecep.contract.ds.vendor.model.Vendor;
import com.ecep.contract.model.VendorCatalog;

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

    List<Vendor> findAllByCatalog(VendorCatalog catalog);

    List<Vendor> findAllByCatalogId(Integer catalogId);

    Optional<Vendor> findByCompany(Company company);

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