package com.fjhx.stock.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fjhx.base.Condition;
import com.fjhx.entity.stock.StockTransfer;
import com.fjhx.params.stock.StockTransferVo;
import com.fjhx.stock.service.StockTransferService;
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-09-13
 */
@RestController
@RequestMapping("/stockTransfer")
public class StockTransferController {

    @Autowired
    private StockTransferService stockTransferService;

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

    @PostMapping("/add")
    public R add(@RequestBody List<StockTransferVo> stockTransferVoList) {
        stockTransferService.add(stockTransferVoList);
        return R.success();
    }

    @PostMapping("/details")
    public R details(@RequestBody StockTransfer stockTransfer) {
        StockTransferVo stockTransferVo = stockTransferService.details(stockTransfer.getId());
        return R.success(stockTransferVo);
    }

    @PostMapping("/check")
    public R check(@RequestBody StockTransferVo stockTransferVo) {
        stockTransferService.check(stockTransferVo);
        return R.success();
    }

    @PostMapping("/delete")
    public R delete(@RequestBody StockTransfer stockTransfer) {
        stockTransferService.removeById(stockTransfer.getId());
        return R.success();
    }

    @PostMapping("/webStatistics")
    public R webStatistics(@RequestBody Condition condition) {
        Map<String, Object> result = stockTransferService.webStatistics(condition);
        return R.success(result);
    }

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


}

