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.supplier.BpmOASupplierProductPageReqVO;
import cn.iocoder.yudao.module.bpm.controller.admin.oa.vo.supplier.BpmOASupplierProductSaveReqVO;
import cn.iocoder.yudao.module.bpm.dal.dataobject.oa.BpmOASupplierProductDO;
import cn.iocoder.yudao.module.bpm.dal.mysql.oa.BpmOASupplierProductMapper;
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;

/**
 * OA供应商商品 Service 实现类
 *
 * @author 艾楷
 */
@Service
@Validated
public class BpmOaSupplierProductServiceImpl implements BpmOaSupplierProductService {

    @Resource
    private BpmOASupplierProductMapper oaSupplierProductMapper;

    @Override
    public Long createOaSupplierProduct(BpmOASupplierProductSaveReqVO createReqVO) {
        // 插入
        BpmOASupplierProductDO oaSupplierProduct = BeanUtils.toBean(createReqVO, BpmOASupplierProductDO.class);
        oaSupplierProductMapper.insert(oaSupplierProduct);
        // 返回
        return oaSupplierProduct.getId();
    }

    @Override
    public void updateOaSupplierProduct(BpmOASupplierProductSaveReqVO updateReqVO) {
        // 更新
        BpmOASupplierProductDO updateObj = BeanUtils.toBean(updateReqVO, BpmOASupplierProductDO.class);
        oaSupplierProductMapper.updateById(updateObj);
    }

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

    @Override
    public BpmOASupplierProductDO getOaSupplierProduct(Long id) {
        return oaSupplierProductMapper.selectById(id);
    }

    @Override
    public PageResult<BpmOASupplierProductDO> getOaSupplierProductPage(BpmOASupplierProductPageReqVO pageReqVO) {
        return oaSupplierProductMapper.selectPage(pageReqVO);
    }

    @Override
    public List<BpmOASupplierProductDO> getByOaSupplierId(Long oaSupplierId) {
        return oaSupplierProductMapper.getByOaSupplierId(oaSupplierId);
    }

}
