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

import com.fjhx.sale.entity.quality.po.EhsdQualityWorkship;
import com.fjhx.sale.mapper.quality.EhsdQualityWorkshipMapper;
import com.fjhx.sale.service.quality.EhsdQualityWorkshipService;
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.EhsdQualityWorkshipVo;
import com.fjhx.sale.entity.quality.dto.EhsdQualityWorkshipSelectDto;
import com.ruoyi.common.utils.wrapper.IWrapper;
import com.fjhx.sale.entity.quality.dto.EhsdQualityWorkshipDto;
import cn.hutool.core.bean.BeanUtil;


/**
 * <p>
 * 质检问题表 服务实现类
 * </p>
 *
 * @author 
 * @since 2023-05-22
 */
@Service
public class EhsdQualityWorkshipServiceImpl extends ServiceImpl<EhsdQualityWorkshipMapper, EhsdQualityWorkship> implements EhsdQualityWorkshipService {

    @Override
    public Page<EhsdQualityWorkshipVo> getPage(EhsdQualityWorkshipSelectDto dto) {
        IWrapper<EhsdQualityWorkship> wrapper = getWrapper();
        wrapper.orderByDesc("eqw", EhsdQualityWorkship::getId);
        Page<EhsdQualityWorkshipVo> page = this.baseMapper.getPage(dto.getPage(), wrapper);
        return page;
    }

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

    @Override
    public void add(EhsdQualityWorkshipDto ehsdQualityWorkshipDto) {
        this.save(ehsdQualityWorkshipDto);
    }

    @Override
    public void edit(EhsdQualityWorkshipDto ehsdQualityWorkshipDto) {
        this.updateById(ehsdQualityWorkshipDto);
    }

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

}
