1 package com.example.demo.controller.user.controller;
2
3 import com.example.demo.controller.user.entity.Order;
4 import org.springframework.web.bind.annotation.*;
5
6 @RestController
7 public class OrderController {
8
9
16 @GetMapping("/orders/{id}")
17 public String getOrder(@PathVariable(value="id")Integer id,
18 @RequestParam(value="name")String name,
19 @RequestParam(value="price",required=false,defaultValue="0") Integer price){
20 String result="id:"+id+",name:"+name+",price:"+price;
21 return result;
22 }
23
24
29 @PostMapping("/order/check")
30 public String checkOrder(@RequestBody Order order){
31 String result="id:"+order.getId()+",name:"+order.getName()+",price:"+order.getPrice();
32 return result;
33 }
34
35
41 @PostMapping("/order/checkmore")
42 public String checkMore(@RequestParam(value="amount")Integer amount, @RequestParam(value="discount")float discount){
43 String result="amount:"+amount+",discount:"+discount;
44 return result;
45 }
46
47
52 @PostMapping("/order/add")
53 public String addOrder(Order order){
54 String result="id:"+order.getId()+",name:"+order.getName()+",price:"+order.getPrice();
55 return result;
56 }
57
58
64 @PutMapping("/order/{id}/update")
65 public String updateOrder(@PathVariable(value="id")Integer id,Order order){
66 String result="pathid:"+id+"===Order(id:"+order.getId()+",name:"+order.getName()+",price:"+order.getPrice()+")";
67 return result;
68 }
69
70
71 }