package cn.iocoder.yudao.module.wms.service.productionline;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.module.wms.controller.admin.productionline.vo.ProductionLinePageReqVO;
import cn.iocoder.yudao.module.wms.controller.admin.productionline.vo.ProductionLineSaveReqVO;
import cn.iocoder.yudao.module.wms.dal.dataobject.productionline.ProductionLineDO;
import cn.iocoder.yudao.module.wms.dal.mysql.productionline.ProductionLineMapper;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;

import javax.annotation.Resource;

/**
 * 产线管理 Service 实现类
 *
 * @author 艾楷
 */
@Service
@Validated
public class ProductionLineServiceImpl implements ProductionLineService {

    @Resource
    private ProductionLineMapper productionLineMapper;

    @Override
    public Long createProductionLine(ProductionLineSaveReqVO createReqVO) {
        // 插入
        ProductionLineDO productionLine = BeanUtils.toBean(createReqVO, ProductionLineDO.class);
        productionLineMapper.insert(productionLine);
        // 返回
        return productionLine.getId();
    }

    @Override
    public void updateProductionLine(ProductionLineSaveReqVO updateReqVO) {
        // 更新
        ProductionLineDO updateObj = BeanUtils.toBean(updateReqVO, ProductionLineDO.class);
        productionLineMapper.updateById(updateObj);
    }

    @Override
    public void deleteProductionLine(Long id) {
        // 删除
        productionLineMapper.deleteById(id);
    }

    @Override
    public ProductionLineDO getProductionLine(Long id) {
        return productionLineMapper.selectById(id);
    }

    @Override
    public PageResult<ProductionLineDO> getProductionLinePage(ProductionLinePageReqVO pageReqVO) {
        return productionLineMapper.selectPage(pageReqVO);
    }

}
