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

import com.fjhx.mes.entity.production.po.ProductionReportingDetail;
import com.fjhx.mes.mapper.production.ProductionReportingDetailMapper;
import com.fjhx.mes.service.production.ProductionReportingDetailService;
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.production.vo.ProductionReportingDetailVo;
import com.fjhx.mes.entity.production.dto.ProductionReportingDetailSelectDto;
import com.ruoyi.common.utils.wrapper.IWrapper;
import com.fjhx.mes.entity.production.dto.ProductionReportingDetailDto;
import cn.hutool.core.bean.BeanUtil;


/**
 * <p>
 * 生产报工明细 服务实现类
 * </p>
 *
 * @author 
 * @since 2023-03-30
 */
@Service
public class ProductionReportingDetailServiceImpl extends ServiceImpl<ProductionReportingDetailMapper, ProductionReportingDetail> implements ProductionReportingDetailService {

    @Override
    public Page<ProductionReportingDetailVo> getPage(ProductionReportingDetailSelectDto dto) {
        IWrapper<ProductionReportingDetail> wrapper = getWrapper();
        wrapper.orderByDesc("prd", ProductionReportingDetail::getId);
        Page<ProductionReportingDetailVo> page = this.baseMapper.getPage(dto.getPage(), wrapper);
        return page;
    }

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

    @Override
    public void add(ProductionReportingDetailDto productionReportingDetailDto) {
        this.save(productionReportingDetailDto);
    }

    @Override
    public void edit(ProductionReportingDetailDto productionReportingDetailDto) {
        this.updateById(productionReportingDetailDto);
    }

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

}
