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

import com.fjhx.sale.entity.quality.po.EhsdQualityPack;
import com.fjhx.sale.mapper.quality.EhsdQualityPackMapper;
import com.fjhx.sale.service.quality.EhsdQualityPackService;
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.EhsdQualityPackVo;
import com.fjhx.sale.entity.quality.dto.EhsdQualityPackSelectDto;
import com.ruoyi.common.utils.wrapper.IWrapper;
import com.fjhx.sale.entity.quality.dto.EhsdQualityPackDto;
import cn.hutool.core.bean.BeanUtil;


/**
 * <p>
 * 质检---产品包装明细表 服务实现类
 * </p>
 *
 * @author 
 * @since 2023-05-22
 */
@Service
public class EhsdQualityPackServiceImpl extends ServiceImpl<EhsdQualityPackMapper, EhsdQualityPack> implements EhsdQualityPackService {

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

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

    @Override
    public void add(EhsdQualityPackDto ehsdQualityPackDto) {
        this.save(ehsdQualityPackDto);
    }

    @Override
    public void edit(EhsdQualityPackDto ehsdQualityPackDto) {
        this.updateById(ehsdQualityPackDto);
    }

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

}
