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

import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.fjhx.mes.entity.mold.dto.MoldInfoDto;
import com.fjhx.mes.entity.mold.dto.MoldInfoSelectDto;
import com.fjhx.mes.entity.mold.po.MoldInfo;
import com.fjhx.mes.entity.mold.vo.MoldInfoVo;
import com.fjhx.mes.mapper.mold.MoldInfoMapper;
import com.fjhx.mes.service.mold.MoldInfoService;
import com.ruoyi.common.utils.wrapper.IWrapper;
import org.springframework.stereotype.Service;


/**
 * <p>
 * 模具信息 服务实现类
 * </p>
 *
 * @author
 * @since 2024-02-01
 */
@Service
public class MoldInfoServiceImpl extends ServiceImpl<MoldInfoMapper, MoldInfo> implements MoldInfoService {

    @Override
    public Page<MoldInfoVo> getPage(MoldInfoSelectDto dto) {
        IWrapper<MoldInfo> wrapper = getWrapper();
        wrapper.orderByDesc("mi", MoldInfo::getId);
        Page<MoldInfoVo> page = this.baseMapper.getPage(dto.getPage(), wrapper);
        return page;
    }

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

    @Override
    public void add(MoldInfoDto moldInfoDto) {
        this.save(moldInfoDto);
    }

    @Override
    public void edit(MoldInfoDto moldInfoDto) {
        this.updateById(moldInfoDto);
    }

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

}
