package com.ecep.contract.service;

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

import com.ecep.contract.util.ParamUtils;
import com.ecep.contract.vm.CompanyExtendInfoViewModel;
import com.ecep.contract.vo.CompanyExtendInfoVo;
import com.ecep.contract.vo.CompanyVo;

@Service
public class CompanyExtendInfoService extends QueryService<CompanyExtendInfoVo, CompanyExtendInfoViewModel> {
    public CompanyExtendInfoVo findByCompany(CompanyVo company) {
        Page<CompanyExtendInfoVo> page = findAll(ParamUtils.equal("company", company.getId()), Pageable.ofSize(1));
        if (page.isEmpty()) {
            return null;
        }
        return page.getContent().getFirst();
    }
}
