package com.ecep.contract.service;

import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;

import com.ecep.contract.util.ParamUtils;
import com.ecep.contract.vo.CompanyFileTypeLocalVo;
import org.springframework.cache.annotation.CacheConfig;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;

import com.ecep.contract.CompanyFileType;
import com.ecep.contract.model.CompanyFileTypeLocal;
import com.ecep.contract.vm.CompanyFileTypeLocalViewModel;

@Service
@CacheConfig(cacheNames = "company-file-type")
public class CompanyFileTypeService extends QueryService<CompanyFileTypeLocalVo, CompanyFileTypeLocalViewModel> {

    @Cacheable
    public Map<CompanyFileType, CompanyFileTypeLocalVo> findAll(Locale locale) {
        return findAll(ParamUtils.builder().equals("lang", locale.toLanguageTag()).build(), Pageable.unpaged()).stream()
                .collect(Collectors.toMap(CompanyFileTypeLocalVo::getType, Function.identity()));
    }
}
