package com.fjhx.material.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fjhx.utils.WrapperUtil;
import com.fjhx.entity.material.MaterialReceivingDetails;
import com.fjhx.params.material.MaterialReceivingDetailsVo;
import com.fjhx.material.mapper.MaterialReceivingDetailsMapper;
import com.fjhx.material.service.MaterialReceivingDetailsService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.Map;

/**
 * <p>
 * 物料接收明细 服务实现类
 * </p>
 *
 * @author ${author}
 * @since 2022-10-11
 */
@Service
public class MaterialReceivingDetailsServiceImpl extends ServiceImpl<MaterialReceivingDetailsMapper, MaterialReceivingDetails> implements MaterialReceivingDetailsService {

    @Override
    public Page<MaterialReceivingDetails> getPage(Map<String, String> condition) {

        QueryWrapper<MaterialReceivingDetails> wrapper = Wrappers.query();

        WrapperUtil.init(condition, wrapper)
                .createTimeDesc();

        Page<MaterialReceivingDetails> page = page(condition, wrapper);
        return page;
    }

    @Override
    public void add(MaterialReceivingDetailsVo materialReceivingDetailsVo) {
        save(materialReceivingDetailsVo);
    }

    @Override
    public void edit(MaterialReceivingDetailsVo materialReceivingDetailsVo) {
        updateById(materialReceivingDetailsVo);
    }

    @Override
    public void delete(MaterialReceivingDetailsVo materialReceivingDetailsVo) {
        removeById(materialReceivingDetailsVo.getId());
    }

}
