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.StockBackDetails;
import com.fjhx.params.stock.StockBackDetailsVo;
import com.fjhx.stock.mapper.StockBackDetailsMapper;
import com.fjhx.stock.service.StockBackDetailsService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.Map;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author ${author}
 * @since 2022-08-31
 */
@Service
public class StockBackDetailsServiceImpl extends ServiceImpl<StockBackDetailsMapper, StockBackDetails> implements StockBackDetailsService {

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

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

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

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

    @Override
    public void add(StockBackDetailsVo stockBackDetailsVo) {
        save(stockBackDetailsVo);
    }

    @Override
    public void edit(StockBackDetailsVo stockBackDetailsVo) {
        updateById(stockBackDetailsVo);
    }

    @Override
    public void delete(StockBackDetailsVo stockBackDetailsVo) {
        removeById(stockBackDetailsVo.getId());
    }

}
