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

import com.ecep.contract.ds.MyRepository;
import com.ecep.contract.ds.company.model.Company;
import com.ecep.contract.ds.customer.model.CompanyCustomer;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import java.util.Optional;

@Repository
public interface CompanyCustomerRepository extends MyRepository<CompanyCustomer, Integer> {

    Optional<CompanyCustomer> findByCompany(Company company);

    Optional<CompanyCustomer> findByCompanyId(Integer companyId);

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