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

import com.fjhx.sale.entity.quality.po.EhsdQualityAql;
import com.fjhx.sale.mapper.quality.EhsdQualityAqlMapper;
import com.fjhx.sale.service.quality.EhsdQualityAqlService;
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.EhsdQualityAqlVo;
import com.fjhx.sale.entity.quality.dto.EhsdQualityAqlSelectDto;
import com.ruoyi.common.utils.wrapper.IWrapper;
import com.fjhx.sale.entity.quality.dto.EhsdQualityAqlDto;
import cn.hutool.core.bean.BeanUtil;


/**
 * <p>
 * 质检AQL表 服务实现类
 * </p>
 *
 * @author 
 * @since 2023-05-22
 */
@Service
public class EhsdQualityAqlServiceImpl extends ServiceImpl<EhsdQualityAqlMapper, EhsdQualityAql> implements EhsdQualityAqlService {

    @Override
    public Page<EhsdQualityAqlVo> getPage(EhsdQualityAqlSelectDto dto) {
        IWrapper<EhsdQualityAql> wrapper = getWrapper();
        wrapper.orderByDesc("eqa", EhsdQualityAql::getId);
        Page<EhsdQualityAqlVo> page = this.baseMapper.getPage(dto.getPage(), wrapper);
        return page;
    }

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

    @Override
    public void add(EhsdQualityAqlDto ehsdQualityAqlDto) {
        this.save(ehsdQualityAqlDto);
    }

    @Override
    public void edit(EhsdQualityAqlDto ehsdQualityAqlDto) {
        this.updateById(ehsdQualityAqlDto);
    }

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

}
