注意:在第八章博客的基礎上開發
一、查詢接口開發
第八章已經寫好了查詢的接口,啓動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