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.SampleProjectDto;
import com.fjhx.sale.entity.sample.dto.SampleProjectSelectDto;
import com.fjhx.sale.entity.sample.po.SampleProject;
import com.fjhx.sale.entity.sample.vo.SampleProjectVo;
import com.fjhx.sale.mapper.sample.SampleProjectMapper;
import com.fjhx.sale.service.sample.SampleProjectService;
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 SampleProjectServiceImpl extends ServiceImpl<SampleProjectMapper, SampleProject> implements SampleProjectService {

    @Override
    public Page<SampleProjectVo> getPage(SampleProjectSelectDto dto) {
        IWrapper<SampleProject> wrapper = getWrapper();
        wrapper.orderByDesc("sp", SampleProject::getId);
        Page<SampleProjectVo> page = this.baseMapper.getPage(dto.getPage(), wrapper);
        return page;
    }

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

    @Override
    public void add(SampleProjectDto sampleProjectDto) {
        this.save(sampleProjectDto);
    }

    @Override
    public void edit(SampleProjectDto sampleProjectDto) {
        this.updateById(sampleProjectDto);
    }

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

}
