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

import com.fjhx.sale.entity.quality.po.EhsdQualityCartons;
import com.fjhx.sale.mapper.quality.EhsdQualityCartonsMapper;
import com.fjhx.sale.service.quality.EhsdQualityCartonsService;
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.EhsdQualityCartonsVo;
import com.fjhx.sale.entity.quality.dto.EhsdQualityCartonsSelectDto;
import com.ruoyi.common.utils.wrapper.IWrapper;
import com.fjhx.sale.entity.quality.dto.EhsdQualityCartonsDto;
import cn.hutool.core.bean.BeanUtil;


/**
 * <p>
 * 质检纸箱表 服务实现类
 * </p>
 *
 * @author 
 * @since 2023-05-22
 */
@Service
public class EhsdQualityCartonsServiceImpl extends ServiceImpl<EhsdQualityCartonsMapper, EhsdQualityCartons> implements EhsdQualityCartonsService {

    @Override
    public Page<EhsdQualityCartonsVo> getPage(EhsdQualityCartonsSelectDto dto) {
        IWrapper<EhsdQualityCartons> wrapper = getWrapper();
        wrapper.orderByDesc("eqc", EhsdQualityCartons::getId);
        Page<EhsdQualityCartonsVo> page = this.baseMapper.getPage(dto.getPage(), wrapper);
        return page;
    }

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

    @Override
    public void add(EhsdQualityCartonsDto ehsdQualityCartonsDto) {
        this.save(ehsdQualityCartonsDto);
    }

    @Override
    public void edit(EhsdQualityCartonsDto ehsdQualityCartonsDto) {
        this.updateById(ehsdQualityCartonsDto);
    }

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

}
