我使用Spring AOP实现了用户操作日志功能
今天答辩完了,复盘了一下系统,发现还是有一些东西值得拿出来和大家分享一下。
需求分析
系统需要对用户的操作进行记录,方便未来溯源
第一个想法是在每种方法中实现记录的逻辑,但这样做肯定是不现实的。首先,工作量很大,其次,它违反了软件工程设计原则(开放和封闭原则)
[En]
The first thought is to realize the recorded logic in each method, but it is certainly unrealistic to do so. First, the workload is heavy, and secondly, it violates the software engineering design principles (open and close principles)
这种需求显然是对代码进行增强,首先想到的是使用 SpringBoot 提供的 AOP 结合注解的方式来实现