package com.fjhx.controller.order;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fjhx.params.order.OrderInfoEx;
import com.fjhx.params.order.OrderInfoVo;
import com.fjhx.service.order.OrderInfoService;
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-12-02
 */
@RestController
@RequestMapping("/orderSales")
public class OrderSalesController {

    @Autowired
    private OrderInfoService orderInfoService;

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

    @PostMapping("/issuePage")
    public R issuePage(@RequestBody Map<String, Object> condition) {
        condition.put("deliverable", true);
        Page<OrderInfoEx> result = orderInfoService.getPage(condition);
        return R.success(result);
    }

    @PostMapping("/add")
    public R add(@RequestBody OrderInfoVo orderVo) {
        orderInfoService.add(orderVo);
        return R.success();
    }

    @PostMapping("/edit")
    public R edit(@RequestBody OrderInfoVo orderVo) {
        orderInfoService.edit(orderVo);
        return R.success();
    }

}

