package com.yxw.zuoye.controller;

import com.yxw.zuoye.service.OrderService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import com.yxw.zuoye.entity.Order;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;

@Slf4j
@RestController
@RequestMapping(value = "/order")
@Api("订单管理功能")
public class OrderController {

    @Autowired
    OrderService orderService;

    @ApiOperation("添加订单")
    @PostMapping(value = "/addOrder")
    public boolean addOrder(Order order){
        int n = orderService.insertOrder(order);
        if(n>0)
            return true;
        else
            return false;
    }

    @ApiOperation("查询订单")
    @GetMapping(value = "/getOrders")
    public List<Order> getOrders(){

        log.info("查询订单");
        return  orderService.getOrders();
    }


}
