* To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
package ro.msg.learning.shop.rest;

import java.time.Instant;
import java.util.Date;
import java.util.HashMap;
import java.util.Set;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import ro.msg.learning.shop.model.OrderObject;
import ro.msg.learning.shop.service.OrderService;

 * @author vagrant

public class OrderController {
    private final OrderService orderService;
    public OrderController(OrderService orderService){
        this.orderService = orderService;
    @RequestMapping(value = "rest", consumes = "application/json", produces = "text/html", method = RequestMethod.POST)
    public String doPost(@RequestBody OrderObject orderObject){
       Set<Long> result =  orderService.processOrder(orderObject);
       StringBuilder st = new StringBuilder();
       for(Long id : result){
       return st.toString();
    @RequestMapping(value = "get", produces = "application/json", method = RequestMethod.GET)
    public OrderObject doGet(){
         return new OrderObject(new HashMap<Long, Long>(), Date.from(Instant.now()), "ceva");