使用AOP设置公共字段自动填充
1.实现思路
在插入或更新时,为指定的字段赋予指定的值
| 序号 | 字段名 | 含义 | 数据类型 | 操作类型 |
|---|---|---|---|---|
| 1 | create_time | 创建时间 | datetime | insert |
| 2 | create_user | 创建人id | bigint | insert |
| 3 | update_time | 更新时间 | datetime | insert、update |
| 4 | update_user | 更新人id | bigint | insert、update |
2.操作步骤
-
自定义注解AutoFill,用于标识需要进行公共字段自动填充的方法
-
自定义切面类AutoFillAspect,统一拦截加入了AutoFill注解的方法,通过反射为公共字段赋值
-
在Mapper的方法上加入AutoFill注解
浙公网安备 33010602011771号