package com.fjhx.mes.service.applicable.impl;

import com.fjhx.mes.entity.applicable.po.ApplicableProducts;
import com.fjhx.mes.mapper.applicable.ApplicableProductsMapper;
import com.fjhx.mes.service.applicable.ApplicableProductsService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fjhx.mes.entity.applicable.vo.ApplicableProductsVo;
import com.fjhx.mes.entity.applicable.dto.ApplicableProductsSelectDto;
import com.ruoyi.common.utils.wrapper.IWrapper;
import com.fjhx.mes.entity.applicable.dto.ApplicableProductsDto;
import cn.hutool.core.bean.BeanUtil;


/**
 * <p>
 * 工艺适用产品明细 服务实现类
 * </p>
 *
 * @author 
 * @since 2023-03-28
 */
@Service
public class ApplicableProductsServiceImpl extends ServiceImpl<ApplicableProductsMapper, ApplicableProducts> implements ApplicableProductsService {

    @Override
    public Page<ApplicableProductsVo> getPage(ApplicableProductsSelectDto dto) {
        IWrapper<ApplicableProducts> wrapper = getWrapper();
        wrapper.orderByDesc("ap", ApplicableProducts::getId);
        Page<ApplicableProductsVo> page = this.baseMapper.getPage(dto.getPage(), wrapper);
        return page;
    }

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

    @Override
    public void add(ApplicableProductsDto applicableProductsDto) {
        this.save(applicableProductsDto);
    }

    @Override
    public void edit(ApplicableProductsDto applicableProductsDto) {
        this.updateById(applicableProductsDto);
    }

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

}
