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

import com.fjhx.sale.entity.quality.po.EhsdQualityProduct;
import com.fjhx.sale.mapper.quality.EhsdQualityProductMapper;
import com.fjhx.sale.service.quality.EhsdQualityProductService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fjhx.sale.entity.quality.vo.EhsdQualityProductVo;
import com.fjhx.sale.entity.quality.dto.EhsdQualityProductSelectDto;
import com.ruoyi.common.utils.wrapper.IWrapper;
import com.fjhx.sale.entity.quality.dto.EhsdQualityProductDto;
import cn.hutool.core.bean.BeanUtil;


/**
 * <p>
 * 质检--商品包装 服务实现类
 * </p>
 *
 * @author 
 * @since 2023-05-22
 */
@Service
public class EhsdQualityProductServiceImpl extends ServiceImpl<EhsdQualityProductMapper, EhsdQualityProduct> implements EhsdQualityProductService {

    @Override
    public Page<EhsdQualityProductVo> getPage(EhsdQualityProductSelectDto dto) {
        IWrapper<EhsdQualityProduct> wrapper = getWrapper();
        wrapper.orderByDesc("eqp", EhsdQualityProduct::getId);
        Page<EhsdQualityProductVo> page = this.baseMapper.getPage(dto.getPage(), wrapper);
        return page;
    }

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

    @Override
    public void add(EhsdQualityProductDto ehsdQualityProductDto) {
        this.save(ehsdQualityProductDto);
    }

    @Override
    public void edit(EhsdQualityProductDto ehsdQualityProductDto) {
        this.updateById(ehsdQualityProductDto);
    }

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

}
