package com.ecep.contract.service;

import java.io.File;

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

import com.ecep.contract.MessageHolder;
import com.ecep.contract.SpringApp;
import com.ecep.contract.constant.CompanyCustomerConstant;
import com.ecep.contract.util.ParamUtils;
import com.ecep.contract.vm.CompanyCustomerViewModel;
import com.ecep.contract.vo.CompanyCustomerVo;
import com.ecep.contract.vo.CompanyVo;

@Service
public class CompanyCustomerService extends QueryService<CompanyCustomerVo, CompanyCustomerViewModel> {
    private File basePath;

    public CompanyCustomerVo findByCompany(CompanyVo company) {
        Page<CompanyCustomerVo> page = findAll(ParamUtils.equal("company", company.getId()), Pageable.ofSize(1));
        if (page.isEmpty()) {
            return null;
        }
        return page.getContent().getFirst();
    }

    public boolean reBuildingFiles(CompanyCustomerVo companyCustomer, MessageHolder holder) {
        throw new UnsupportedOperationException("Unimplemented method 'reBuildingFiles'");
    }

    public File getBasePath() {
        if (basePath == null) {
            basePath = new File(
                    SpringApp.getBean(SysConfService.class).getString(CompanyCustomerConstant.KEY_BASE_PATH));
        }
        return basePath;
    }

    public boolean makePathAbsent(CompanyCustomerVo companyCustomer) {
        // TODO Auto-generated method stub
        throw new UnsupportedOperationException("Unimplemented method 'makePathAbsent'");
    }
}
