package com.fjhx.controller.stock;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fjhx.base.Condition;
import com.fjhx.entity.stock.StockJournal;
import com.fjhx.params.stock.StockJournalVo;
import com.fjhx.service.stock.StockJournalService;
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;

/**
 * <p>
 * 出入库流水记录 前端控制器
 * </p>
 *
 * @author ${author}
 * @since 2022-11-24
 */
@RestController
@RequestMapping("/stockJournal")
public class StockJournalController {

    @Autowired
    private StockJournalService stockJournalService;

    @PostMapping("/page")
    public R page(@RequestBody Map<String, String> condition){
        Page<StockJournal> result = stockJournalService.getPage(condition);
        return R.success(result);
    }

    @PostMapping("/add")
    public R add(@RequestBody StockJournalVo stockJournalVo){
        stockJournalService.add(stockJournalVo);
        return R.success();
    }

    @PostMapping("/edit")
    public R edit(@RequestBody StockJournalVo stockJournalVo) {
        stockJournalService.edit(stockJournalVo);
        return R.success();
    }

    @PostMapping("/delete")
    public R delete(@RequestBody StockJournalVo stockJournalVo) {
        stockJournalService.delete(stockJournalVo);
        return R.success();
    }

    /**
     * 出入库单据查看
     */
    @PostMapping("inOutDocument")
    public R inOutDocument(@RequestBody Condition condition) {
        Page<Map<String, Object>> page = stockJournalService.inOutDocument(condition);
        return R.success(page);
    }

}

