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

import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.fjhx.sale.entity.purchase.dto.EhsdPurchaseArrivalDto;
import com.fjhx.sale.entity.purchase.dto.EhsdPurchaseArrivalSelectDto;
import com.fjhx.sale.entity.purchase.po.EhsdPurchaseArrival;
import com.fjhx.sale.entity.purchase.vo.EhsdPurchaseArrivalVo;
import com.fjhx.sale.mapper.purchase.EhsdPurchaseArrivalMapper;
import com.fjhx.sale.service.purchase.EhsdPurchaseArrivalService;
import com.ruoyi.common.utils.wrapper.IWrapper;
import org.springframework.stereotype.Service;


/**
 * <p>
 * 采购合同-到货计划 服务实现类
 * </p>
 *
 * @author 
 * @since 2023-05-17
 */
@Service
public class EhsdPurchaseArrivalServiceImpl extends ServiceImpl<EhsdPurchaseArrivalMapper, EhsdPurchaseArrival> implements EhsdPurchaseArrivalService {

    @Override
    public Page<EhsdPurchaseArrivalVo> getPage(EhsdPurchaseArrivalSelectDto dto) {
        IWrapper<EhsdPurchaseArrival> wrapper = getWrapper();
        wrapper.orderByDesc("epa", EhsdPurchaseArrival::getId);
        Page<EhsdPurchaseArrivalVo> page = this.baseMapper.getPage(dto.getPage(), wrapper);
        return page;
    }

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

    @Override
    public void add(EhsdPurchaseArrivalDto ehsdPurchaseArrivalDto) {
        this.save(ehsdPurchaseArrivalDto);
    }

    @Override
    public void edit(EhsdPurchaseArrivalDto ehsdPurchaseArrivalDto) {
        this.updateById(ehsdPurchaseArrivalDto);
    }

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

}
