package com.cf.imes.module.manage.api.plate;

import com.cf.imes.framework.common.pojo.CommonResult;
import com.cf.imes.module.manage.dal.dataobject.plate.PlateDO;
import com.cf.imes.module.manage.service.plate.PlateService;

import javax.annotation.Resource;

import static com.cf.imes.framework.common.pojo.CommonResult.success;

public class PlateServiceImpl implements PlateApi{

    @Resource
    private PlateService plateService;

    @Override
    public CommonResult<Boolean> getPlate(Long id) {
        PlateDO plateDO = plateService.getPlate(id);
        if (plateDO == null) {
            return success(false);
        }
        return success(true);
    }

    @Override
    public CommonResult<Long> getPlateGoods(Long goodsId) {
        if (goodsId == null) {
            return success(0L);
        }
        PlateDO plateDO = plateService.getPlateGoods(goodsId);
        if (plateDO == null) {
            return success(0L);
        }
        return success(plateDO.getId());
    }
}
