在类上面书写注解
@RestController
@RequestMapping("/books")
public class BookController {
新增
@PostMapping
public String insert(@RequestBody Books books) {
int id = books.getId();
String price = books.getPrice();
System.out.println(id + price);
return "insert...";
}
删除
@DeleteMapping("/{id}")
public String delete(@PathVariable Integer id) {
System.out.println(id);
return "delete... + id";
}
修改
@PutMapping()
public String update(@RequestBody Books books) {
System.out.println(books.getId() + books.getPrice());
return "update。。。";
}
查询
@GetMapping
public String findAll() {
System.out.println("HELLO");
return "Find。。";
}
@GetMapping("/{id}")
public String findById(@PathVariable Integer id) {
System.out.println(id);
return "findById。。。";
}