116 lines
4.7 KiB
Java
116 lines
4.7 KiB
Java
|
package com.zcloud.logs;//package com.zcloud.logs;
|
||
|
//
|
||
|
//import com.alibaba.fastjson.JSONObject;
|
||
|
//import com.zcloud.entity.PageData;
|
||
|
//import com.zcloud.service.corp.CorpInfoService;
|
||
|
//import com.zcloud.service.system.UsersService;
|
||
|
//import com.zcloud.util.Const;
|
||
|
//import com.zcloud.util.Jurisdiction;
|
||
|
//import lombok.extern.slf4j.Slf4j;
|
||
|
//import org.aspectj.lang.ProceedingJoinPoint;
|
||
|
//import org.aspectj.lang.annotation.Around;
|
||
|
//import org.aspectj.lang.annotation.Aspect;
|
||
|
//import org.aspectj.lang.reflect.MethodSignature;
|
||
|
//import org.springframework.beans.factory.annotation.Autowired;
|
||
|
//import org.springframework.stereotype.Component;
|
||
|
//import org.springframework.web.context.request.RequestContextHolder;
|
||
|
//import org.springframework.web.context.request.ServletRequestAttributes;
|
||
|
//
|
||
|
//import javax.servlet.http.HttpServletRequest;
|
||
|
//import java.lang.reflect.Method;
|
||
|
//import java.text.SimpleDateFormat;
|
||
|
//import java.util.Date;
|
||
|
//import java.util.Map;
|
||
|
//
|
||
|
///**
|
||
|
// * @author fangjiakai
|
||
|
// * @date 2022/07/25 11:39
|
||
|
// */
|
||
|
//@Component
|
||
|
//@Aspect
|
||
|
//@Slf4j
|
||
|
//public class LogAopAspect {
|
||
|
//
|
||
|
// @Autowired
|
||
|
// private CorpInfoService corpInfoService;
|
||
|
// @Autowired
|
||
|
// private UsersService usersService;
|
||
|
//
|
||
|
// @Around("@annotation(com.zcloud.logs.LogAnno)")
|
||
|
// public Object aroundAdvice(ProceedingJoinPoint pjp) throws Throwable {
|
||
|
// // 1.方法执行前的处理,相当于前置通知
|
||
|
// // 获取方法签名
|
||
|
// MethodSignature methodSignature = (MethodSignature) pjp.getSignature();
|
||
|
// // 获取方法
|
||
|
// Method method = methodSignature.getMethod();
|
||
|
// // 获取方法上面的注解
|
||
|
// LogAnno logAnno = method.getAnnotation(LogAnno.class);
|
||
|
// String userId=null;
|
||
|
// String corpId=null;
|
||
|
// String ip=null;
|
||
|
// if(Jurisdiction.getSession() != null && Jurisdiction.getSession().getAttribute(Const.USER_ID)!=null){
|
||
|
// userId = Jurisdiction.getUSER_ID();
|
||
|
// corpId = Jurisdiction.getCORPINFO_ID();
|
||
|
// }else {
|
||
|
// try {
|
||
|
// HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes())
|
||
|
// .getRequest();
|
||
|
// Map properties = request.getParameterMap();
|
||
|
// userId = ((String[]) properties.get("USER_ID"))[0];
|
||
|
// corpId = ((String[]) properties.get("CORPINFO_ID"))[0];
|
||
|
// }catch (Exception e){
|
||
|
// return pjp.proceed();
|
||
|
// }
|
||
|
// }
|
||
|
//
|
||
|
// PageData corp = new PageData();
|
||
|
// corp.put("CORPINFO_ID",corpId);
|
||
|
// corp = corpInfoService.findById(corp);
|
||
|
//
|
||
|
// PageData user = new PageData();
|
||
|
// user.put("USER_ID",userId);
|
||
|
// user = usersService.findById(user);
|
||
|
//
|
||
|
// // 获取操作描述的属性值
|
||
|
// String menuType = logAnno.menuType();
|
||
|
// //获取操作模块的属性值
|
||
|
// String menuServer = logAnno.menuServer();
|
||
|
// //获取操作类型
|
||
|
// String instructionsType = logAnno.instructionsType();
|
||
|
// //获取操作指令
|
||
|
// String instructionsOperate = logAnno.instructionsOperate();
|
||
|
// JSONObject message = new JSONObject();
|
||
|
// message.put("menuType",menuType);
|
||
|
// message.put("menuServer",menuServer);
|
||
|
// message.put("instructionsOperate",instructionsOperate);
|
||
|
// message.put("instructionsType",instructionsType);
|
||
|
// message.put("CORPINFO_ID",corpId);
|
||
|
// message.put("CORPINFO_NAME",corp.getString("CORP_NAME"));
|
||
|
// message.put("USER_ID",userId);
|
||
|
// message.put("operateor",user.getString("NAME"));
|
||
|
// Object result = null;
|
||
|
// try {
|
||
|
// // 让代理方法执行
|
||
|
// result = pjp.proceed();
|
||
|
// // 2.相当于后置通知(方法成功执行之后走这里)
|
||
|
// message.put("operateResult","正常");
|
||
|
// Date now = new Date();
|
||
|
// SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//可以方便地修改日期格格式
|
||
|
// String format = dateFormat.format(now);
|
||
|
// message.put("operateDate",format);
|
||
|
// log.info(message.toJSONString());
|
||
|
// } catch (Exception e) {
|
||
|
// // 3.相当于异常通知部分
|
||
|
// message.put("operateResult","失败");
|
||
|
// Date now = new Date();
|
||
|
// SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//可以方便地修改日期格格式
|
||
|
// String format = dateFormat.format(now);
|
||
|
// message.put("operateDate",format);
|
||
|
// message.put("error",e.getMessage());
|
||
|
// e.printStackTrace();
|
||
|
// log.info(message.toJSONString());
|
||
|
// }
|
||
|
// return result;
|
||
|
// }
|
||
|
//}
|