第九章、接口开发

注意:在第八章博客的基础上开发

一、查询接口开发

第八章已经写好了查询的接口,启动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
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章