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

import com.fjhx.sale.entity.pack.po.PackDetailGoods;
import com.fjhx.sale.mapper.pack.PackDetailGoodsMapper;
import com.fjhx.sale.service.pack.PackDetailGoodsService;
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.PackDetailGoodsVo;
import com.fjhx.sale.entity.pack.dto.PackDetailGoodsSelectDto;
import com.ruoyi.common.utils.wrapper.IWrapper;
import com.fjhx.sale.entity.pack.dto.PackDetailGoodsDto;
import cn.hutool.core.bean.BeanUtil;


/**
 * <p>
 * 自定义装箱货物表 服务实现类
 * </p>
 *
 * @author 
 * @since 2023-04-18
 */
@Service
public class PackDetailGoodsServiceImpl extends ServiceImpl<PackDetailGoodsMapper, PackDetailGoods> implements PackDetailGoodsService {

    @Override
    public Page<PackDetailGoodsVo> getPage(PackDetailGoodsSelectDto dto) {
        IWrapper<PackDetailGoods> wrapper = getWrapper();
        wrapper.orderByDesc("pdg", PackDetailGoods::getId);
        Page<PackDetailGoodsVo> page = this.baseMapper.getPage(dto.getPage(), wrapper);
        return page;
    }

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

    @Override
    public void add(PackDetailGoodsDto packDetailGoodsDto) {
        this.save(packDetailGoodsDto);
    }

    @Override
    public void edit(PackDetailGoodsDto packDetailGoodsDto) {
        this.updateById(packDetailGoodsDto);
    }

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

}
