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.StockTransferDetails;
import com.fjhx.params.stock.StockTransferDetailsVo;
import com.fjhx.stock.mapper.StockTransferDetailsMapper;
import com.fjhx.stock.service.StockTransferDetailsService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.Map;

/**
 * <p>
 * 转仓 服务实现类
 * </p>
 *
 * @author ${author}
 * @since 2022-09-13
 */
@Service
public class StockTransferDetailsServiceImpl extends ServiceImpl<StockTransferDetailsMapper, StockTransferDetails> implements StockTransferDetailsService {

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

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

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

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

    @Override
    public void add(StockTransferDetailsVo stockTransferDetailsVo) {
        save(stockTransferDetailsVo);
    }

    @Override
    public void edit(StockTransferDetailsVo stockTransferDetailsVo) {
        updateById(stockTransferDetailsVo);
    }

    @Override
    public void delete(StockTransferDetailsVo stockTransferDetailsVo) {
        removeById(stockTransferDetailsVo.getId());
    }

}
