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

import com.fjhx.sale.entity.quality.po.EhsdQualityProductColor;
import com.fjhx.sale.mapper.quality.EhsdQualityProductColorMapper;
import com.fjhx.sale.service.quality.EhsdQualityProductColorService;
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.EhsdQualityProductColorVo;
import com.fjhx.sale.entity.quality.dto.EhsdQualityProductColorSelectDto;
import com.ruoyi.common.utils.wrapper.IWrapper;
import com.fjhx.sale.entity.quality.dto.EhsdQualityProductColorDto;
import cn.hutool.core.bean.BeanUtil;


/**
 * <p>
 * 质检--产品规格 服务实现类
 * </p>
 *
 * @author 
 * @since 2023-05-22
 */
@Service
public class EhsdQualityProductColorServiceImpl extends ServiceImpl<EhsdQualityProductColorMapper, EhsdQualityProductColor> implements EhsdQualityProductColorService {

    @Override
    public Page<EhsdQualityProductColorVo> getPage(EhsdQualityProductColorSelectDto dto) {
        IWrapper<EhsdQualityProductColor> wrapper = getWrapper();
        wrapper.orderByDesc("eqpc", EhsdQualityProductColor::getId);
        Page<EhsdQualityProductColorVo> page = this.baseMapper.getPage(dto.getPage(), wrapper);
        return page;
    }

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

    @Override
    public void add(EhsdQualityProductColorDto ehsdQualityProductColorDto) {
        this.save(ehsdQualityProductColorDto);
    }

    @Override
    public void edit(EhsdQualityProductColorDto ehsdQualityProductColorDto) {
        this.updateById(ehsdQualityProductColorDto);
    }

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

}
