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.EhsdPurchaseProjectDto;
import com.fjhx.sale.entity.purchase.dto.EhsdPurchaseProjectSelectDto;
import com.fjhx.sale.entity.purchase.po.EhsdPurchaseProject;
import com.fjhx.sale.entity.purchase.vo.EhsdPurchaseProjectVo;
import com.fjhx.sale.mapper.purchase.EhsdPurchaseProjectMapper;
import com.fjhx.sale.service.purchase.EhsdPurchaseProjectService;
import com.ruoyi.common.utils.wrapper.IWrapper;
import org.springframework.stereotype.Service;


/**
 * <p>
 * 采购合同-收费项目 服务实现类
 * </p>
 *
 * @author 
 * @since 2023-05-17
 */
@Service
public class EhsdPurchaseProjectServiceImpl extends ServiceImpl<EhsdPurchaseProjectMapper, EhsdPurchaseProject> implements EhsdPurchaseProjectService {

    @Override
    public Page<EhsdPurchaseProjectVo> getPage(EhsdPurchaseProjectSelectDto dto) {
        IWrapper<EhsdPurchaseProject> wrapper = getWrapper();
        wrapper.orderByDesc("epp", EhsdPurchaseProject::getId);
        Page<EhsdPurchaseProjectVo> page = this.baseMapper.getPage(dto.getPage(), wrapper);
        return page;
    }

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

    @Override
    public void add(EhsdPurchaseProjectDto ehsdPurchaseProjectDto) {
        this.save(ehsdPurchaseProjectDto);
    }

    @Override
    public void edit(EhsdPurchaseProjectDto ehsdPurchaseProjectDto) {
        this.updateById(ehsdPurchaseProjectDto);
    }

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

}
