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.procurepay.BpmOAProcurePayItemPageReqVO;
import cn.iocoder.yudao.module.bpm.controller.admin.oa.vo.procurepay.BpmOAProcurePayItemSaveReqVO;
import cn.iocoder.yudao.module.bpm.dal.dataobject.oa.BpmOAProcurePayItemDO;
import cn.iocoder.yudao.module.bpm.dal.mysql.oa.BpmOAProcurePayItemMapper;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;

import javax.annotation.Resource;

/**
 * 采购收款明细 Service 实现类
 *
 * @author 艾楷
 */
@Service
@Validated
public class BpmOAProcurePayItemServiceImpl implements BpmOAProcurePayItemService {

    @Resource
    private BpmOAProcurePayItemMapper oAProcurePayItemMapper;

    @Override
    public Long createOAProcurePayItem(BpmOAProcurePayItemSaveReqVO createReqVO) {
        // 插入
        BpmOAProcurePayItemDO oAProcurePayItem = BeanUtils.toBean(createReqVO, BpmOAProcurePayItemDO.class);
        oAProcurePayItemMapper.insert(oAProcurePayItem);
        // 返回
        return oAProcurePayItem.getId();
    }

    @Override
    public void updateOAProcurePayItem(BpmOAProcurePayItemSaveReqVO updateReqVO) {
        // 更新
        BpmOAProcurePayItemDO updateObj = BeanUtils.toBean(updateReqVO, BpmOAProcurePayItemDO.class);
        oAProcurePayItemMapper.updateById(updateObj);
    }

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

    @Override
    public BpmOAProcurePayItemDO getOAProcurePayItem(Long id) {
        return oAProcurePayItemMapper.selectById(id);
    }

    @Override
    public PageResult<BpmOAProcurePayItemDO> getOAProcurePayItemPage(BpmOAProcurePayItemPageReqVO pageReqVO) {
        return oAProcurePayItemMapper.selectPage(pageReqVO);
    }

}