当前位置:网站首页>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(); }
边栏推荐
- List interview common questions
- 运算放大器应用汇总1
- UltraEdit-32 温馨提示:右协会,取消 bak文件[通俗易懂]
- Preprocessing - interpolation
- 【系统管理】清理任务栏的已删除程序的图标缓存
- OSCP工具之一: dirsearch用法大全
- Clock in during winter vacation
- 链表面试常见题
- Baidu map JS development, open a blank, bmapgl is not defined, err_ FILE_ NOT_ FOUND
- Antd comment recursive loop comment
猜你喜欢
史上最全MongoDB之Mongo Shell使用
Implementation steps of docker deploying mysql8
MySQL data loss, analyze binlog log file
2022夏每日一题(一)
如何检测mysql代码运行是否出现死锁+binlog查看
Some common software related
Ggplot facet detail adjustment summary
PHP lightweight Movie Video Search Player source code
【knife-4j 快速搭建swagger】
Simple implementation of AVL tree insertion and verification operations
随机推荐
Implementation steps of docker deploying mysql8
Hisilicon 3559 universal platform construction: RTSP real-time playback support
The true face of function pointer in single chip microcomputer and the operation of callback function
使用 TiDB Lightning 恢复 GCS 上的备份数据
Quick completion guide of manipulator (10): accessible workspace
2022中青杯C题城市交通思路分析
cuda编程
Force buckle ----- path sum III
ERROR: Could not build wheels for pycocotools which use PEP 517 and cannot be installed directly
浅谈网络安全之文件上传
map和set的实现
数据的存储
QT opens a file and uses QFileDialog to obtain the file name, content, etc
golang 根据生日计算星座和属相
Kotlin Android 环境搭建
Free PHP online decryption tool source code v1.2
[leetcode] 450 and 98 (deletion and verification of binary search tree)
It's too convenient. You can complete the code release and approval by nailing it!
QT 使用QToolTip 鼠标放上去显示文字时会把按钮的图片也显示了、修改提示文字样式
UltraEdit-32 温馨提示:右协会,取消 bak文件[通俗易懂]