package com.ecep.contract.service;

import java.util.List;

import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;

import com.ecep.contract.ContractFileType;
import com.ecep.contract.util.ParamUtils;
import com.ecep.contract.vm.ContractFileViewModel;
import com.ecep.contract.vo.ContractFileVo;
import com.ecep.contract.vo.ContractVo;

@Service
public class ContractFileService extends QueryService<ContractFileVo, ContractFileViewModel> {
    public List<ContractFileVo> findAllByContract(ContractVo contract) {
        return findAll(ParamUtils.equal("contract", contract.getId()), Pageable.unpaged()).getContent();
    }

    public List<ContractFileVo> findAllByContractAndFileType(ContractVo contract, ContractFileType type) {
        return findAll(ParamUtils.builder()
                .equals("contract", contract.getId())
                .equals("type", type.name()).build(), Pageable.unpaged()).getContent();
    }

}
