@ApiImplicitParams({
@ApiImplicitParam(name = "type", value = "类型", required = true, dataType = "Integer"),
@ApiImplicitParam(name = "cardNo", value = "cardNo 卡号", required = true, dataType = "String"),
@ApiImplicitParam(name = "shortCardNo", value = "shortCardNo 短卡号", required = true, dataType = "String"),
@ApiImplicitParam(name = "remark", value = "remark", required = true, dataType = "boolean"),
})
@PostMapping("/add/single/{type}")
public Result addCard(@NotNull @PathVariable Integer type,
@NotNull String cardNo, @NotNull String shortCardNo,
String remark, Oauth2TokenDto oauth2TokenDto) {
return Result.success(cardNumberService.addCard(type, cardNo, shortCardNo, remark, oauth2TokenDto.getUnitId()));
}
1,从“restful风格”接口中取参,必须使用 @PathVariable 注解!!!
“restful风格”接口可以从从路径上获取数据(似乎这叫“restful风格”接口?), “restful风格”来获取数据在@PostMapping、@PutMapping、@GetMapping、@DeleteMapping都是可以使用的,都可以从路径中成功获取数据
2,从 Params 中获取数据,可以发现即使在 POST 请求中,仍然是可以从Params 中获取数据的。
3,想要获取 @PostMapping 中传过来的 JSON 数据,必须要加上 @RequestBody 注解!!!!