package com.fjhx.sale.service.purchase.impl;

import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.fjhx.sale.entity.purchase.dto.EhsdPurchaseProductMountingsDto;
import com.fjhx.sale.entity.purchase.dto.EhsdPurchaseProductMountingsSelectDto;
import com.fjhx.sale.entity.purchase.po.EhsdPurchaseProductMountings;
import com.fjhx.sale.entity.purchase.vo.EhsdPurchaseProductMountingsVo;
import com.fjhx.sale.mapper.purchase.EhsdPurchaseProductMountingsMapper;
import com.fjhx.sale.service.purchase.EhsdPurchaseProductMountingsService;
import com.ruoyi.common.utils.wrapper.IWrapper;
import org.springframework.stereotype.Service;


/**
 * <p>
 * ehsd采购产品配件表 服务实现类
 * </p>
 *
 * @author 
 * @since 2023-05-17
 */
@Service
public class EhsdPurchaseProductMountingsServiceImpl extends ServiceImpl<EhsdPurchaseProductMountingsMapper, EhsdPurchaseProductMountings> implements EhsdPurchaseProductMountingsService {

    @Override
    public Page<EhsdPurchaseProductMountingsVo> getPage(EhsdPurchaseProductMountingsSelectDto dto) {
        IWrapper<EhsdPurchaseProductMountings> wrapper = getWrapper();
        wrapper.orderByDesc("eppm", EhsdPurchaseProductMountings::getId);
        Page<EhsdPurchaseProductMountingsVo> page = this.baseMapper.getPage(dto.getPage(), wrapper);
        return page;
    }

    @Override
    public EhsdPurchaseProductMountingsVo detail(Long id) {
        EhsdPurchaseProductMountings EhsdPurchaseProductMountings = this.getById(id);
        EhsdPurchaseProductMountingsVo result = BeanUtil.toBean(EhsdPurchaseProductMountings, EhsdPurchaseProductMountingsVo.class);
        return result;
    }

    @Override
    public void add(EhsdPurchaseProductMountingsDto ehsdPurchaseProductMountingsDto) {
        this.save(ehsdPurchaseProductMountingsDto);
    }

    @Override
    public void edit(EhsdPurchaseProductMountingsDto ehsdPurchaseProductMountingsDto) {
        this.updateById(ehsdPurchaseProductMountingsDto);
    }

    @Override
    public void delete(Long id) {
        this.removeById(id);
    }

}
