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.InventoryCatalogViewModel;
import com.ecep.contract.vo.InventoryCatalogVo;

@Service
public class InventoryCatalogService extends QueryService<InventoryCatalogVo, InventoryCatalogViewModel> {

    public InventoryCatalogVo findByName(String name) {
        Page<InventoryCatalogVo> page = findAll(ParamUtils.builder().equals("name", name).build(), Pageable.ofSize(1));
        if (page.isEmpty()) {
            return null;
        }
        return page.getContent().getFirst();
    }

}
