package com.fjhx.service.stock.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.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.fjhx.entity.stock.StockArea;
import com.fjhx.mapper.stock.StockAreaMapper;
import com.fjhx.params.stock.StockAreaVo;
import com.fjhx.service.stock.StockAreaService;
import com.fjhx.utils.WrapperUtil;
import org.springframework.stereotype.Service;

import java.util.Map;

/**
 * <p>
 * 仓库分区 服务实现类
 * </p>
 *
 * @author ${author}
 * @since 2022-08-05
 */
@Service
public class StockAreaServiceImpl extends ServiceImpl<StockAreaMapper, StockArea> implements StockAreaService {

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

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

        WrapperUtil.init(condition, wrapper)
                .eq("stock_house_id", "stockHouseId", "仓库id不能为空")
                .like("name", "keyword");

        Page<StockArea> page = page(condition, wrapper);

        return page;
    }

    @Override
    public void add(StockAreaVo stockAreaVo) {
        save(stockAreaVo);
    }

    @Override
    public void edit(StockAreaVo stockAreaVo) {
        updateById(stockAreaVo);
    }

    @Override
    public void delete(StockAreaVo stockAreaVo) {
        removeById(stockAreaVo.getId());
    }

}
