1.@ApiParam ,是註解api的參數,用於swagger提供開發者文檔,文檔中生成的註釋內容。
@ApiOperation(value = "根據id查詢")
@GetMapping(value = {"/findById/{id}"})
public ItooResult findById(@ApiParam(value = "主鍵id", required = true) @PathVariable String id) {
PhoneticEntity phoneticEntity = phoneticService.getById(id);
return ItooResult.build(ItooResult.SUCCESS, "查詢成功", phoneticEntity);
}
2.@RequestParam,是獲取前端傳遞給後端的參數,可以是get方式,也可以是post方式。其中如果前端傳遞的參數和後端你接受的參數起的名字字段是一致的可以省略不寫,也可以直接寫@RequestParam String title,如果不一致一定要完整寫,不然獲取不到
@ApiOperation(value = "查詢-我的")
@GetMapping(value = {"/findById"})
public ItooResult queryMineByUserId(@RequestParam String userCode){
MineModel mineModel = rankService.Mine(userCode);
mineModel.setUserId(null);
return ItooResult.build(ItooResult.SUCCESS,"查詢成功",mineModel);
}
3.@PathVariable,是獲取get方式,url後面參數,進行參數綁定
@ApiOperation(value = "根據id查詢")
@GetMapping(value = {"/findById/{id}"})
public ItooResult findById(@ApiParam(value = "主鍵id", required = true) @PathVariable String id) {
PhoneticEntity phoneticEntity = phoneticService.getById(id);
return ItooResult.build(ItooResult.SUCCESS, "查詢成功", phoneticEntity);
}