注意:在第八章博客的基础上开发
一、查询接口开发
第八章已经写好了查询的接口,启动SpringBoot后,在PostMan中访问如下
若localhost:8080/get/book/novel?id=0 或 localhost:8080/get/book/novel
则返回
二、增加接口开发
//添加接口
@PostMapping("/add/book/novel")
public ResponseEntity add(
@RequestParam(name = "title") String title,
@RequestParam(name = "author") String author,
@RequestParam(name = "word_count") int wordCount,
@RequestParam(name = "publish_date") @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") Date publish_date){
try {
XContentBuilder content = XContentFactory.js