当前位置:网站首页>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();
}边栏推荐
- HW-小记(二)
- Quick completion guide of manipulator (10): accessible workspace
- Web service performance monitoring scheme
- Some common software related
- Binary, octal, hexadecimal
- Mobile measurement and depth link platform - Branch
- Class constant pool and runtime constant pool
- 如何编写一个程序猿另一个面试官眼前一亮的简历[通俗易懂]
- QT item table new column name setting requirement exercise (find the number and maximum value of the array disappear)
- Create commonly used shortcut icons at the top of the ad interface (menu bar)
猜你喜欢

未来发展路线确认!数字经济、数字化转型、数据...这次会议很重要

Force buckle ----- path sum III

Top 50 hit industry in the first half of 2022

【OA】Excel 文档生成器: Openpyxl 模块

机械臂速成小指南(十):可达工作空间

链表面试常见题

List interview common questions

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

MySQL data loss, analyze binlog log file

Calculation of time and space complexity (notes of runners)
随机推荐
List interview common questions
[development software] tilipa Developer Software
Do you choose pandas or SQL for the top 1 of data analysis in your mind?
Binary, octal, hexadecimal
2022年电工杯B 题 5G 网络环境下应急物资配送问题思路分析
复杂因子计算优化案例:深度不平衡、买卖压力指标、波动率计算
Preprocessing - interpolation
The most complete learning rate adjustment strategy in history LR_ scheduler
vim —- 自己主动的按钮indent该命令「建议收藏」
使用Thread类和Runnable接口实现多线程的区别
用头像模仿天狗食月
Mobile measurement and depth link platform - Branch
[MySQL] row sorting in MySQL
Operational amplifier application summary 1
Quick completion guide of manipulator (10): accessible workspace
史上最全MongoDB之初识篇
Leetcode: interview question 17.24 Maximum cumulative sum of submatrix (to be studied)
运算放大器应用汇总1
【安全攻防】序列化与反序列,你了解多少?
中青杯2022A题高校数学建模竞赛与课程教育思路分析