package com.fjhx.stock.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.stock.StockBackPlanDetails;
import com.fjhx.params.stock.StockBackPlanDetailsVo;
import com.fjhx.stock.mapper.StockBackPlanDetailsMapper;
import com.fjhx.stock.service.StockBackPlanDetailsService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.Map;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author ${author}
 * @since 2022-09-02
 */
@Service
public class StockBackPlanDetailsServiceImpl extends ServiceImpl<StockBackPlanDetailsMapper, StockBackPlanDetails> implements StockBackPlanDetailsService {

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

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

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

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

    @Override
    public void add(StockBackPlanDetailsVo stockBackPlanDetailsVo) {
        save(stockBackPlanDetailsVo);
    }

    @Override
    public void edit(StockBackPlanDetailsVo stockBackPlanDetailsVo) {
        updateById(stockBackPlanDetailsVo);
    }

    @Override
    public void delete(StockBackPlanDetailsVo stockBackPlanDetailsVo) {
        removeById(stockBackPlanDetailsVo.getId());
    }

}
