package com.fjhx.controller.stock;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fjhx.base.Condition;
import com.fjhx.entity.logistics.LogisticsInfo;
import com.fjhx.entity.stock.StockJournal;
import com.fjhx.enums.stock.InTypeEnum;
import com.fjhx.params.stock.ManualInStockVo;
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;

/**
 * @author 手动入库
 */
@RestController
@RequestMapping("/manual/in/stock")
public class ManualInStockController {

    @Autowired
    private StockJournalService stockJournalService;

    @Autowired
    private StockService stockService;

    /**
     * 列表
     *
     * @param condition 查询条件
     * @return
     */
    @PostMapping("/page")
    public R page(@RequestBody Condition condition) {
        Page<StockJournal> result = stockJournalService.getManualInStockPage(condition);
        return R.success(result);
    }

    @PostMapping("/add")
    public R add(@RequestBody ManualInStockVo entity) {
        StockChangeVo vo = new StockChangeVo(entity);
        stockService.changeQuantity(vo);
        return R.success();
    }

}
