package com.fjhx.controller.stock;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fjhx.base.Condition;
import com.fjhx.entity.stock.ManualVo;
import com.fjhx.params.stock.StockChangeVo;
import com.fjhx.service.stock.StockJournalService;
import com.fjhx.service.stock.StockService;
import org.springblade.core.tool.api.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * @author 手动出库
 */
@RestController
@RequestMapping("/manualOut")
public class ManualOutStockController {

    @Autowired
    private StockService stockService;

    @Autowired
    private StockJournalService stockJournalService;

    @PostMapping("/add")
    public R add(@RequestBody ManualVo manualVo) {
        StockChangeVo stockChangeVo = new StockChangeVo(manualVo);

        stockService.changeQuantity(stockChangeVo);
        return R.success();
    }

    @PostMapping("page")
    public R page(@RequestBody Condition condition) {
        Page<Map<String, Object>> page = stockJournalService.getManualOutPage(condition);
        return R.success(page);
    }

}
