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

import com.fjhx.sale.entity.pack.po.PackDetailProduct;
import com.fjhx.sale.mapper.pack.PackDetailProductMapper;
import com.fjhx.sale.service.pack.PackDetailProductService;
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.pack.vo.PackDetailProductVo;
import com.fjhx.sale.entity.pack.dto.PackDetailProductSelectDto;
import com.ruoyi.common.utils.wrapper.IWrapper;
import com.fjhx.sale.entity.pack.dto.PackDetailProductDto;
import cn.hutool.core.bean.BeanUtil;


/**
 * <p>
 * 装箱出货产品明细表 服务实现类
 * </p>
 *
 * @author 
 * @since 2023-04-18
 */
@Service
public class PackDetailProductServiceImpl extends ServiceImpl<PackDetailProductMapper, PackDetailProduct> implements PackDetailProductService {

    @Override
    public Page<PackDetailProductVo> getPage(PackDetailProductSelectDto dto) {
        IWrapper<PackDetailProduct> wrapper = getWrapper();
        wrapper.orderByDesc("pdp", PackDetailProduct::getId);
        Page<PackDetailProductVo> page = this.baseMapper.getPage(dto.getPage(), wrapper);
        return page;
    }

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

    @Override
    public void add(PackDetailProductDto packDetailProductDto) {
        this.save(packDetailProductDto);
    }

    @Override
    public void edit(PackDetailProductDto packDetailProductDto) {
        this.updateById(packDetailProductDto);
    }

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

}
