package com.example.kafka.controller;

import com.example.kafka.entity.Order;
import com.example.kafka.service.OrderServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.*;
import reactor.core.publisher.Mono;

/**
 * Order controller for order related apis
 */
@RestController
@RequestMapping("/v1/order")
public class OrderController {

    @Autowired
    private OrderServiceImpl orderService;

    /**
     * Save order api for creating new order
     * @param order The order
     * @return The mono object of Order
     */
    @PostMapping("/save")
    @ResponseStatus(HttpStatus.ACCEPTED)
    public Mono<Order> saveOrderDetails(@RequestBody Order order){
        return orderService.saveOrderIntoDB(order);
    }

}
