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.StockCorrect;
import com.fjhx.params.stock.StockCorrectVo;
import com.fjhx.stock.mapper.StockCorrectMapper;
import com.fjhx.stock.service.StockCorrectService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.Map;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author ${author}
 * @since 2022-11-09
 */
@Service
public class StockCorrectServiceImpl extends ServiceImpl<StockCorrectMapper, StockCorrect> implements StockCorrectService {

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

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

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

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

    @Override
    public void add(StockCorrectVo stockCorrectVo) {
        save(stockCorrectVo);
    }

    @Override
    public void edit(StockCorrectVo stockCorrectVo) {
        updateById(stockCorrectVo);
    }

    @Override
    public void delete(StockCorrectVo stockCorrectVo) {
        removeById(stockCorrectVo.getId());
    }

}
