package com.fjhx.controller.stock;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fjhx.entity.stock.StockHouse;
import com.fjhx.params.stock.StockHouseVo;
import com.fjhx.service.stock.StockHouseService;
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.List;
import java.util.Map;

/**
 * <p>
 * 仓库 前端控制器
 * </p>
 *
 * @author ${author}
 * @since 2022-08-05
 */
@RestController
@RequestMapping("/stockHouse")
public class StockHouseController {

    @Autowired
    private StockHouseService stockHouseService;

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

    @PostMapping("/add")
    public R add(@RequestBody StockHouseVo stockHouseVo) {
        stockHouseService.add(stockHouseVo);
        return R.success();
    }

    @PostMapping("/edit")
    public R edit(@RequestBody StockHouseVo stockHouseVo) {
        stockHouseService.edit(stockHouseVo);
        return R.success();
    }

    @PostMapping("/delete")
    public R delete(@RequestBody StockHouseVo stockHouseVo) {
        stockHouseService.delete(stockHouseVo);
        return R.success();
    }

    @PostMapping("/list")
    public R list(@RequestBody StockHouse stockHouse) {
        List<StockHouse> result = stockHouseService.getList(stockHouse);
        return R.success(result);
    }

}

