1、创立用户操作标识枚举
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
public @interface UserOperateLog {
String value();
String valueEn();
}
2、创立枚举拦截器,用来记录用户操作行为
@Component
@Aspect
public class UserOperateLogAspect {
@Around("@annotation(UserOperateLog)")
@SneakyThrows
public Object aroundAspect(ProceedingJoinPoint joinPoint){
//拼接用户操作日志模型
//理论申请
Object o =joinPoint.proceed();
//填充模型
//异步写入数据库
return o;
}
}
3、测试案例
public class TestModel {
@UserOperateLog(value = "测试操作",valueEn="test")
public void test1() {
}
public String test2() {
return "";
}
}
4、数据库字段
1、id
2、用户操作形容(UserOperateLog.value)
3、申请url
4、申请参数
5、返回后果
6、耗时
7、用户id
8、用户名
9、创立工夫
10、申请后果是否失败
11、异样信息
12、英文形容(UserOperateLog.valueEn)
发表回复