package com.fjhx.wms.service.stock.impl;

import com.fjhx.wms.entity.stock.po.StockCheckDetails;
import com.fjhx.wms.mapper.stock.StockCheckDetailsMapper;
import com.fjhx.wms.service.stock.StockCheckDetailsService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fjhx.wms.entity.stock.vo.StockCheckDetailsVo;
import com.fjhx.wms.entity.stock.dto.StockCheckDetailsSelectDto;
import com.ruoyi.common.utils.wrapper.IWrapper;
import com.fjhx.wms.entity.stock.dto.StockCheckDetailsDto;
import cn.hutool.core.bean.BeanUtil;


/**
 * <p>
 * 库存盘点明细 服务实现类
 * </p>
 *
 * @author 
 * @since 2023-03-22
 */
@Service
public class StockCheckDetailsServiceImpl extends ServiceImpl<StockCheckDetailsMapper, StockCheckDetails> implements StockCheckDetailsService {

    @Override
    public Page<StockCheckDetailsVo> getPage(StockCheckDetailsSelectDto dto) {
        IWrapper<StockCheckDetails> wrapper = getWrapper();
        wrapper.orderByDesc("scd", StockCheckDetails::getId);
        Page<StockCheckDetailsVo> page = this.baseMapper.getPage(dto.getPage(), wrapper);
        return page;
    }

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

    @Override
    public void add(StockCheckDetailsDto stockCheckDetailsDto) {
        this.save(stockCheckDetailsDto);
    }

    @Override
    public void edit(StockCheckDetailsDto stockCheckDetailsDto) {
        this.updateById(stockCheckDetailsDto);
    }

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

}
