spring-boot-route 使用aop记录操作日志( 二 )


@RestController@RequestMApping("person")public class PersonController {@GetMapping("/{name}")@Log(title = "system",businessType = BusinessType.OTHER)public Person getPerson(@PathVariable("name") String name, @RequestParam int age){return new Person(name,age);}@PostMapping("add")@Log(title = "system",businessType = BusinessType.INSERT)public int addPerson(@RequestBody Person person){if(StringUtils.isEmpty(person)){return -1;}return 1;}@PutMapping("update")@Log(title = "system",businessType = BusinessType.UPDATE)public int updatePerson(@RequestBody Person person){if(StringUtils.isEmpty(person)){return -1;}return 1;}@DeleteMapping("/{name}")@Log(title = "system",businessType = BusinessType.DELETE)public int deletePerson(@PathVariable(name = "name") String name){if(StringUtils.isEmpty(name)){return -1;}return 1;}}当然 , 还可以在数据库中将请求参数和响应结果也进行存储 , 这样就能看出具体接口的操作记录了 。

来源:https://www.tuicool.com/articles/bAZFR33

【spring-boot-route 使用aop记录操作日志】


推荐阅读