当前位置:网站首页>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();
}边栏推荐
- Web service performance monitoring scheme
- 机器学习笔记 - 使用机器学习进行鸟类物种分类
- The JSON format of the international area code of the mobile phone number is obtained with PHP
- 2022年电工杯B 题 5G 网络环境下应急物资配送问题思路分析
- [hcie TAC] question 3
- [leetcode]Spiral Matrix II
- 2022中青杯数学建模B题开放三孩背景下的生育政策研究思路
- easyui出口excel无法下载框弹出的办法来解决
- The true face of function pointer in single chip microcomputer and the operation of callback function
- Hongmi K40S root gameplay notes
猜你喜欢

【系统管理】清理任务栏的已删除程序的图标缓存

Redis configuration and optimization of NoSQL

Adaptive non European advertising retrieval system amcad

Implementation of map and set

Quick completion guide of manipulator (10): accessible workspace

2022年上半年HIT行业TOP50

Free PHP online decryption tool source code v1.2

【mysql】mysql中行排序

Tflite model transformation and quantification

机器学习笔记 - 使用机器学习进行鸟类物种分类
随机推荐
PHP implements lottery according to probability
[hcie TAC] question 3
Tflite model transformation and quantification
Gpt-3 is a peer review online when it has been submitted for its own research
使用 BR 恢复 GCS 上的备份数据
一些常用软件相关
运算放大器应用汇总1
Probability formula
golang 压缩和解压zip文件
Redis源码学习(30),字典学习,dict.h
2022年上半年HIT行业TOP50
Construction of Hisilicon universal platform: color space conversion YUV2RGB
Quick completion guide of manipulator (10): accessible workspace
使用 Dumpling 备份 TiDB 集群数据到 GCS
机器学习笔记 - 使用机器学习进行鸟类物种分类
使用切面实现记录操作日志
Top 50 hit industry in the first half of 2022
How to detect whether the MySQL code runs deadlock +binlog view
Do you choose pandas or SQL for the top 1 of data analysis in your mind?
MySQL data loss, analyze binlog log file