当前位置:网站首页>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();
}边栏推荐
- PHP implements lottery according to probability
- Probability formula
- 二叉搜索树的实现
- 【mysql】mysql中行排序
- 什么是 CGI,什么是 IIS,什么是VPS「建议收藏」
- Quick completion guide of manipulator (10): accessible workspace
- 【编码字体系列】OpenDyslexic字体
- Baidu map JS development, open a blank, bmapgl is not defined, err_ FILE_ NOT_ FOUND
- cuda编程
- easyui出口excel无法下载框弹出的办法来解决
猜你喜欢
![[security attack and Defense] how much do you know about serialization and deserialization?](/img/1c/e5ae74e65bacf688d7f61cc1b71d3e.png)
[security attack and Defense] how much do you know about serialization and deserialization?

Kotlin Android environment construction

Web service performance monitoring scheme

【刷题记录】2. 两数相加

tflite模型转换和量化

Create commonly used shortcut icons at the top of the ad interface (menu bar)

2022年上半年HIT行业TOP50

MySQL data loss, analyze binlog log file

Hisilicon 3559 universal platform construction: RTSP real-time playback support

What is Ba? How about Ba? What is the relationship between Ba and Bi?
随机推荐
codeforces每日5题(均1700)-第七天
easyui出口excel无法下载框弹出的办法来解决
AVL树插入操作与验证操作的简单实现
ABAP 動態內錶分組循環
Do you choose pandas or SQL for the top 1 of data analysis in your mind?
Unity3D在一建筑GL材料可以改变颜色和显示样本
【OA】Excel 文档生成器: Openpyxl 模块
Implementation steps of docker deploying mysql8
2022年电工杯B 题 5G 网络环境下应急物资配送问题思路分析
cuda编程
Some common software related
Kotlin Android environment construction
[hcie TAC] question 3
【开发软件】 tilipa开发者软件
二叉搜索树的实现
未来发展路线确认!数字经济、数字化转型、数据...这次会议很重要
SSL certificate deployment
HW notes (II)
机械臂速成小指南(十):可达工作空间
NoSQL之Redis配置与优化