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

import com.baomidou.dynamic.datasource.annotation.DS;
import com.fjhx.common.constant.SourceConstant;
import com.fjhx.sale.entity.sample.dto.SampleShipmentDto;
import com.fjhx.sale.entity.sample.dto.SampleShipmentSelectDto;
import com.fjhx.sale.entity.sample.po.SampleShipment;
import com.fjhx.sale.entity.sample.vo.SampleShipmentVo;
import com.fjhx.sale.mapper.sample.SampleShipmentMapper;
import com.fjhx.sale.service.sample.SampleShipmentService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruoyi.common.utils.wrapper.IWrapper;
import cn.hutool.core.bean.BeanUtil;


/**
 * <p>
 * 样品单-出货计划 服务实现类
 * </p>
 *
 * @author 
 * @since 2023-05-05
 */
@Service
public class SampleShipmentServiceImpl extends ServiceImpl<SampleShipmentMapper, SampleShipment> implements SampleShipmentService {

    @Override
    public Page<SampleShipmentVo> getPage(SampleShipmentSelectDto dto) {
        IWrapper<SampleShipment> wrapper = getWrapper();
        wrapper.orderByDesc("ss", SampleShipment::getId);
        Page<SampleShipmentVo> page = this.baseMapper.getPage(dto.getPage(), wrapper);
        return page;
    }

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

    @Override
    public void add(SampleShipmentDto sampleShipmentDto) {
        this.save(sampleShipmentDto);
    }

    @Override
    public void edit(SampleShipmentDto sampleShipmentDto) {
        this.updateById(sampleShipmentDto);
    }

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

}
