当前位置:网站首页>Use facet to record operation log
Use facet to record operation log
2022-07-07 04:03:00 【Friendship years】
@Aspect
@Component
public class SysLogAspect {
@Autowired
private SysLogService sysLogService;
/**
* Tangent point
*/
@Pointcut("@annotation(com.platform.annotation.SysLog)")
public void logPointCut() {
}
/**
* Pre notice
*
* @param joinPoint Connection point
*/
@Before("logPointCut()")
public void saveSysLog(JoinPoint joinPoint) {
MethodSignature signature = (MethodSignature) joinPoint.getSignature();
Method method = signature.getMethod();
SysLogEntity sysLog = new SysLogEntity();
SysLog syslog = method.getAnnotation(SysLog.class);
if (syslog != null) {
// The description on the note
sysLog.setOperation(syslog.value());
}
// Requested method name
String className = joinPoint.getTarget().getClass().getName();
String methodName = signature.getName();
sysLog.setMethod(className + "." + methodName + "()");
// Requested parameters
Object[] args = joinPoint.getArgs();
String params = JSON.toJSONString(args[0]);
sysLog.setParams(params);
// obtain request
HttpServletRequest request = HttpContextUtils.getHttpServletRequest();
// Set up IP Address
sysLog.setIp(IPUtils.getIpAddr(request));
// user name
SysUserEntity sysUserEntity = ShiroUtils.getUserEntity();
String username = "";
if ("login".equals(methodName)) {
username = params;
}
if (null != sysUserEntity) {
username = ShiroUtils.getUserEntity().getUsername();
}
sysLog.setUsername(username);
sysLog.setCreateDate(new Date());
// Save system logs
sysLogService.save(sysLog);
}
}
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface SysLog {
String value() default " The operation log ";
}@SysLog(" Delete menu ")
@RequestMapping("/delete")
@RequiresPermissions("sys:menu:delete")
public R delete(@RequestBody Long[] menuIds) {
for (Long menuId : menuIds) {
if (menuId.longValue() <= 30) {
return R.error(" system menu , Can't delete ");
}
}
sysMenuService.deleteBatch(menuIds);
return R.ok();
}边栏推荐
- 【knife-4j 快速搭建swagger】
- UltraEdit-32 温馨提示:右协会,取消 bak文件[通俗易懂]
- 用头像模仿天狗食月
- Kotlin Android 环境搭建
- web服务性能监控方案
- Redis源码学习(31),字典学习,dict.c(一)
- Tencent cloud native database tdsql-c was selected into the cloud native product catalog of the Academy of communications and communications
- 预处理——插值
- 2022中青杯数学建模B题开放三孩背景下的生育政策研究思路
- 史上最全MongoDB之Mongo Shell使用
猜你喜欢

QT item table new column name setting requirement exercise (find the number and maximum value of the array disappear)

Antd Comment 递归循环评论

2022中青杯C题城市交通思路分析

Ggplot facet detail adjustment summary

Food Chem|深度学习根据成分声明准确预测食品类别和营养成分

Top 50 hit industry in the first half of 2022

Kbone与小程序跨端开发的一些思考

map和set的实现

【开发软件】 tilipa开发者软件

Arduino droplet detection
随机推荐
termux设置电脑连接手机。(敲打命令贼快),手机termux端口8022
用头像模仿天狗食月
QT thread and other 01 concepts
使用 TiDB Lightning 恢复 GCS 上的备份数据
Optimization cases of complex factor calculation: deep imbalance, buying and selling pressure index, volatility calculation
leetcode:面试题 17.24. 子矩阵最大累加和(待研究)
运算放大器应用汇总1
[development software] tilipa Developer Software
ggplot 分面的细节调整汇总
【mysql】mysql中行排序
Docker部署Mysql8的实现步骤
Triple half circle progress bar, you can use it directly
On file uploading of network security
What is Ba? How about Ba? What is the relationship between Ba and Bi?
How to detect whether the MySQL code runs deadlock +binlog view
【开发软件】 tilipa开发者软件
使用 BR 备份 TiDB 集群到 GCS
学习使用js把两个对象合并成一个对象的方法Object.assign()
Allow public connections to local Ruby on Rails Development Server
HW-小记(二)