package com.ecep.contract.controller.table.cell;

import static com.ecep.contract.SpringApp.getBean;

import com.ecep.contract.service.InventoryCatalogService;
import com.ecep.contract.vo.InventoryCatalogVo;

import lombok.Setter;

@Setter
public class InventoryCatalogTableCell<V> extends AsyncUpdateTableCell<V, Integer, InventoryCatalogVo> {

    public InventoryCatalogTableCell() {
    }

    public InventoryCatalogTableCell(InventoryCatalogService inventoryCatalogService) {
        setService(inventoryCatalogService);
    }

    @Override
    protected InventoryCatalogService getServiceBean() {
        return getBean(InventoryCatalogService.class);
    }

    @Override
    public String format(InventoryCatalogVo entity) {
        if (entity.getCode() == null) {
            return entity.getName();
        }
        return entity.getCode() + " " + entity.getName();
    }

}
