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

import com.fjhx.sale.entity.quality.po.EhsdQualityProblem;
import com.fjhx.sale.mapper.quality.EhsdQualityProblemMapper;
import com.fjhx.sale.service.quality.EhsdQualityProblemService;
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.quality.vo.EhsdQualityProblemVo;
import com.fjhx.sale.entity.quality.dto.EhsdQualityProblemSelectDto;
import com.ruoyi.common.utils.wrapper.IWrapper;
import com.fjhx.sale.entity.quality.dto.EhsdQualityProblemDto;
import cn.hutool.core.bean.BeanUtil;


/**
 * <p>
 * 质检问题表 服务实现类
 * </p>
 *
 * @author 
 * @since 2023-05-22
 */
@Service
public class EhsdQualityProblemServiceImpl extends ServiceImpl<EhsdQualityProblemMapper, EhsdQualityProblem> implements EhsdQualityProblemService {

    @Override
    public Page<EhsdQualityProblemVo> getPage(EhsdQualityProblemSelectDto dto) {
        IWrapper<EhsdQualityProblem> wrapper = getWrapper();
        wrapper.orderByDesc("eqp", EhsdQualityProblem::getId);
        Page<EhsdQualityProblemVo> page = this.baseMapper.getPage(dto.getPage(), wrapper);
        return page;
    }

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

    @Override
    public void add(EhsdQualityProblemDto ehsdQualityProblemDto) {
        this.save(ehsdQualityProblemDto);
    }

    @Override
    public void edit(EhsdQualityProblemDto ehsdQualityProblemDto) {
        this.updateById(ehsdQualityProblemDto);
    }

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

}
