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

import com.fjhx.sale.entity.contract.po.ContractShipment;
import com.fjhx.sale.mapper.contract.ContractShipmentMapper;
import com.fjhx.sale.service.contract.ContractShipmentService;
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.contract.vo.ContractShipmentVo;
import com.fjhx.sale.entity.contract.dto.ContractShipmentSelectDto;
import com.ruoyi.common.utils.wrapper.IWrapper;
import com.fjhx.sale.entity.contract.dto.ContractShipmentDto;
import cn.hutool.core.bean.BeanUtil;


/**
 * <p>
 * 外销合同-出货计划 服务实现类
 * </p>
 *
 * @author
 * @since 2023-04-17
 */
@Service
public class ContractShipmentServiceImpl extends ServiceImpl<ContractShipmentMapper, ContractShipment> implements ContractShipmentService {

    @Override
    public Page<ContractShipmentVo> getPage(ContractShipmentSelectDto dto) {
        IWrapper<ContractShipment> wrapper = getWrapper();
        wrapper.orderByDesc("cs", ContractShipment::getId);
        Page<ContractShipmentVo> page = this.baseMapper.getPage(dto.getPage(), wrapper);
        return page;
    }

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

    @Override
    public void add(ContractShipmentDto contractShipmentDto) {
        this.save(contractShipmentDto);
    }

    @Override
    public void edit(ContractShipmentDto contractShipmentDto) {
        this.updateById(contractShipmentDto);
    }

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

}
