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

import com.fjhx.sale.entity.contract.po.ContractProject;
import com.fjhx.sale.mapper.contract.ContractProjectMapper;
import com.fjhx.sale.service.contract.ContractProjectService;
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.ContractProjectVo;
import com.fjhx.sale.entity.contract.dto.ContractProjectSelectDto;
import com.ruoyi.common.utils.wrapper.IWrapper;
import com.fjhx.sale.entity.contract.dto.ContractProjectDto;
import cn.hutool.core.bean.BeanUtil;


/**
 * <p>
 * 外销合同-收费项目 服务实现类
 * </p>
 *
 * @author
 * @since 2023-04-17
 */
@Service
public class ContractProjectServiceImpl extends ServiceImpl<ContractProjectMapper, ContractProject> implements ContractProjectService {

    @Override
    public Page<ContractProjectVo> getPage(ContractProjectSelectDto dto) {
        IWrapper<ContractProject> wrapper = getWrapper();
        wrapper.orderByDesc("cp", ContractProject::getId);
        Page<ContractProjectVo> page = this.baseMapper.getPage(dto.getPage(), wrapper);
        return page;
    }

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

    @Override
    public void add(ContractProjectDto contractProjectDto) {
        this.save(contractProjectDto);
    }

    @Override
    public void edit(ContractProjectDto contractProjectDto) {
        this.updateById(contractProjectDto);
    }

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

}
