Skip to content

Commit

Permalink
Merge pull request #55 from swing-park/feature-order
Browse files Browse the repository at this point in the history
refactor : RequestBody 형태로 데이터를 전달받아라.
  • Loading branch information
malaheaven authored Apr 28, 2021
2 parents 920ec75 + c37a453 commit 7032c0c
Showing 1 changed file with 7 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,21 @@
import codsquad.team17.sidedish.service.OrderService;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;

@RestController
@RequestMapping("/order")
@RequestMapping("/dish")
public class OrderController {
private OrderService orderService;

public OrderController(OrderService orderService) {
this.orderService = orderService;
}

@PutMapping("/{itemId}/{itemAmount}")
public ResponseEntity orderItem(@PathVariable Long itemId, @PathVariable int itemAmount) {
return new ResponseEntity(orderService.orderItem(itemId, itemAmount), HttpStatus.OK);
@PutMapping("/{itemId}/order")
public ResponseEntity orderItem(@PathVariable Long itemId, @RequestBody HashMap<String, Integer> body) {
return new ResponseEntity(orderService.orderItem(itemId, body.get("order_amount")), HttpStatus.OK);
}
}

0 comments on commit 7032c0c

Please sign in to comment.