package com.ecep.contract.service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

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

import com.ecep.contract.ContractFileType;
import com.ecep.contract.model.Contract;
import com.ecep.contract.model.ContractFile;
import com.ecep.contract.vm.ContractFileViewModel;

@Service
public class ContractFileService extends QueryService<ContractFile, ContractFileViewModel> {
    public List<ContractFile> findAllByContract(Contract contract) {
        Map<String, Object> params = new HashMap<>();
        params.put("contract", contract.getId());
        return findAll(params, Pageable.unpaged()).getContent();
    }

    public List<ContractFile> findAllByContractAndFileType(Contract contract, ContractFileType type) {
        Map<String, Object> params = new HashMap<>();
        params.put("contract", contract.getId());
        params.put("type", type.name());
        return findAll(params, Pageable.unpaged()).getContent();
    }

}
