当前位置:网站首页>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(); }
边栏推荐
- 【OA】Excel 文档生成器: Openpyxl 模块
- 太方便了,钉钉上就可完成代码发布审批啦!
- Ggplot facet detail adjustment summary
- 史上最全MongoDB之Mongo Shell使用
- Baidu map JS development, open a blank, bmapgl is not defined, err_ FILE_ NOT_ FOUND
- 运算放大器应用汇总1
- One of oscp tools: dirsearch usage Encyclopedia
- Simple implementation of AVL tree insertion and verification operations
- Redis source code learning (31), dictionary learning, dict.c (1)
- It's too convenient. You can complete the code release and approval by nailing it!
猜你喜欢
Machine learning notes - bird species classification using machine learning
web服务性能监控方案
List interview common questions
How to detect whether the MySQL code runs deadlock +binlog view
【开发软件】 tilipa开发者软件
MySQL data loss, analyze binlog log file
【OA】Excel 文档生成器: Openpyxl 模块
SQL injection -day15
自适应非欧表征广告检索系统AMCAD
浅谈网络安全之文件上传
随机推荐
ABAP 动态内表分组循环
2022年上半年HIT行业TOP50
Arduino droplet detection
什么是 CGI,什么是 IIS,什么是VPS「建议收藏」
List interview common questions
QT 项目 表格新建列名称设置 需求练习(找数组消失的数字、最大值)
ABAP dynamic inner table grouping cycle
你心目中的数据分析 Top 1 选 Pandas 还是选 SQL?
史上最全学习率调整策略lr_scheduler
Hongmi K40S root gameplay notes
史上最全MongoDB之部署篇
[development software] tilipa Developer Software
When QT uses qtooltip mouse to display text, the picture of the button will also be displayed and the prompt text style will be modified
Antd comment recursive loop comment
Ggplot facet detail adjustment summary
Introduction to opensea platform developed by NFT trading platform (I)
维护万星开源向量数据库是什么体验
Hisilicon 3559 universal platform construction: RTSP real-time playback support
二进制、八进制、十六进制
easyui出口excel无法下载框弹出的办法来解决