@RestController
@RequestMapping("/v1/coffees")
public class CoffeeController {
@PostMapping
public ResponseEntity postCoffee(@RequestParam("korName") String korName,
@RequestParam("engName") String engName,
@RequestParam("price") int price) {
Map<String, Object> map = new HashMap<>();
map.put("korName", korName);
map.put("engName", engName);
map.put("price", price);
return new ResponseEntity<>(map, HttpStatus.CREATED);
}
@GetMapping("/{coffee-id}")
public ResponseEntity getCoffee(@PathVariable("coffee-id") long coffeeId) {
System.out.println("# coffeeId: " + coffeeId);
// not implementation
return new ResponseEntity<>(HttpStatus.OK);
}
@GetMapping
public ResponseEntity getCoffees() {
System.out.println("# get Coffees");
// not implementation
return new ResponseEntity<>(HttpStatus.OK);
}
@PatchMapping("/{coffee-id}")
public ResponseEntity patchCoffee(@RequestBody CoffeePatchDto coffeePatchDto,
@PathVariable("coffee-id") long coffeeId) {
coffeePatchDto.setCoffeeId(coffeeId);
return new ResponseEntity<>(coffeePatchDto, HttpStatus.OK);
}
@DeleteMapping("/{coffee-id}")
public ResponseEntity deleteCoffees(@PathVariable("coffee-id") long coffeeId){
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
}
}
@Controller
@RestController
@RequestMapping
@RequestMapping(value = "/v1/coffees", produces = {MediaType.APPLICATION_JSON_VALUE})
@XXXXMaping
전송 기본값
ResponseEntity