package cn.iocoder.yudao.module.bpm.service.oa;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.module.bpm.controller.admin.oa.vo.supplierprocurementplan.BpmOASupplierProcurementPlanItemPageReqVO;
import cn.iocoder.yudao.module.bpm.controller.admin.oa.vo.supplierprocurementplan.BpmOASupplierProcurementPlanItemSaveReqVO;
import cn.iocoder.yudao.module.bpm.dal.dataobject.oa.BpmOASupplierProcurementPlanItemDO;
import cn.iocoder.yudao.module.bpm.dal.mysql.oa.BpmOASupplierProcurementPlanItemMapper;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;

import javax.annotation.Resource;
import java.util.List;

/**
 * 供应商采购计划子 Service 实现类
 *
 * @author 艾楷
 */
@Service
@Validated
public class BpmOASupplierProcurementPlanItemServiceImpl implements BpmOASupplierProcurementPlanItemService {

    @Resource
    private BpmOASupplierProcurementPlanItemMapper oaSupplierProcurementPlanItemMapper;

    @Override
    public Long createOaSupplierProcurementPlanItem(BpmOASupplierProcurementPlanItemSaveReqVO createReqVO) {
        // 插入
        BpmOASupplierProcurementPlanItemDO oaSupplierProcurementPlanItem = BeanUtils.toBean(createReqVO, BpmOASupplierProcurementPlanItemDO.class);
        oaSupplierProcurementPlanItemMapper.insert(oaSupplierProcurementPlanItem);
        // 返回
        return oaSupplierProcurementPlanItem.getId();
    }

    @Override
    public void updateOaSupplierProcurementPlanItem(BpmOASupplierProcurementPlanItemSaveReqVO updateReqVO) {
        // 更新
        BpmOASupplierProcurementPlanItemDO updateObj = BeanUtils.toBean(updateReqVO, BpmOASupplierProcurementPlanItemDO.class);
        oaSupplierProcurementPlanItemMapper.updateById(updateObj);
    }

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

    @Override
    public BpmOASupplierProcurementPlanItemDO getOaSupplierProcurementPlanItem(Long id) {
        return oaSupplierProcurementPlanItemMapper.selectById(id);
    }

    @Override
    public PageResult<BpmOASupplierProcurementPlanItemDO> getOaSupplierProcurementPlanItemPage(BpmOASupplierProcurementPlanItemPageReqVO pageReqVO) {
        return oaSupplierProcurementPlanItemMapper.selectPage(pageReqVO);
    }

    @Override
    public List<BpmOASupplierProcurementPlanItemDO> getByProcurementPlanId(Long procurementPlanId) {
        return oaSupplierProcurementPlanItemMapper.getByProcurementPlanId(procurementPlanId);
    }

}
