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

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

import org.springframework.stereotype.Repository;

import com.ecep.contract.ContractPayWay;
import com.ecep.contract.ds.MyRepository;
import com.ecep.contract.model.Contract;

@Repository
public interface ContractRepository extends MyRepository<Contract, Integer> {

    Optional<Contract> findByGuid(String guid);

    Optional<Contract> findByProjectIdAndPayWay(int projectId, ContractPayWay payWay);

    List<Contract> findAllByProjectIdAndPayWay(int projectId, ContractPayWay payWay);

    Optional<Contract> findByCode(String code);

    int deleteAllByCompanyId(int companyId);

    List<Contract> findByCodeStartsWith(String code);

    List<Contract> findByPayWayAndCodeStartsWith(ContractPayWay payWay, String code);

    List<Contract> findAllByParentCode(String parentCode);

    Optional<Contract> findFirstByName(String name);

    List<Contract> findAllByCompanyId(int companyId);

    List<Contract> findAllByProjectId(int projectId);

}
