package vip.xiaonuo.purchase.controller;


import com.alibaba.fastjson.JSONArray;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.github.xiaoymin.knife4j.annotations.ApiSupport;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
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 vip.xiaonuo.common.pojo.CommonResult;
import vip.xiaonuo.money.entity.MoneyBorrowWarning;
import vip.xiaonuo.money.param.MoneyInOutParam;
import vip.xiaonuo.purchase.entity.PurchaseOrder;
import vip.xiaonuo.purchase.entity.vo.*;
import vip.xiaonuo.purchase.param.PurchaseOrderParam;
import vip.xiaonuo.purchase.param.PurchaseParam;
import vip.xiaonuo.purchase.service.IPurchaseOrderService;

import java.util.List;

/**
 * <p>
 * 采购订单表 前端控制器
 * </p>
 *
 * @author author
 * @since 2024-11-25
 */

@Api(tags = "采购订单表控制器")
@ApiSupport(author = "wang", order = 1)
@RestController
@Validated
public class PurchaseOrderController {

    @Autowired
    private IPurchaseOrderService purchaseOrderService;

    @ApiOperationSupport(order = 1)
    @ApiOperation("指标")
    @PostMapping("/purchase-order/getOrder")
    public CommonResult<PurchaseOrderVo> getOrder(@RequestBody PurchaseParam purchaseParam) {
        return CommonResult.data(purchaseOrderService.getOrder(purchaseParam));
    }

    @ApiOperationSupport(order = 2)
    @ApiOperation("采购订单数量 金额")
    @PostMapping("/purchase-order/listOrderMoney")
    public CommonResult<List<PurchaseOrderMoneyVo>> listOrderMoney(@RequestBody PurchaseOrderParam orderParam) {
        return CommonResult.data(purchaseOrderService.listOrderMoney(orderParam));
    }

    @ApiOperationSupport(order = 3)
    @ApiOperation("二级页面横栏")
    @PostMapping("/purchase-order/orderType")
    public CommonResult<List<PurchaseOrderTypeVo>> orderType(@RequestBody PurchaseParam param) {
        return CommonResult.data(purchaseOrderService.orderType(param));
    }

    @ApiOperationSupport(order = 4)
    @ApiOperation("采购金额趋势")
    @PostMapping("/purchase-order/listMoney")
    public CommonResult<List<PurchaseMoneyVo>> listMoney(@RequestBody PurchaseParam param) {
        return CommonResult.data(purchaseOrderService.listMoney(param));
    }

    @ApiOperationSupport(order = 5)
    @ApiOperation("供应商占比分析")
    @PostMapping("/purchase-order/materialType")
    public CommonResult<JSONArray> materialType(@RequestBody PurchaseParam param) {
        return CommonResult.data(purchaseOrderService.materialType(param));
    }
}
