Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor : RequestBody 형태로 데이터를 전달받아라. #55

Merged
merged 1 commit into from
Apr 28, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
}
}