浏览代码

异常日志代理

chengyao 3 年之前
父节点
当前提交
b2e7a08b22

+ 0 - 30
common/src/main/java/com/lantone/common/annotation/Log.java

@@ -1,30 +0,0 @@
-package com.lantone.common.annotation;
-import com.lantone.common.enums.BusinessType;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * @Description:自定义操作日志记录注解
- * @Author: cy
- * @time: 2021/8/30 13:36
- */
-@Target({ ElementType.PARAMETER, ElementType.METHOD })
-@Retention(RetentionPolicy.RUNTIME)
-public @interface Log {
-    /**
-     * 模块
-     */
-    public String title() default "";
-
-    /**
-     * 功能
-     */
-    public BusinessType businessType() default BusinessType.OTHER;
-    /**
-     * 是否保存请求的参数
-     */
-    public boolean isSaveRequestData() default true;
-}

+ 1 - 1
common/src/main/java/com/lantone/common/dto/AbnormalLogDTO.java

@@ -55,7 +55,7 @@ public class AbnormalLogDTO implements Serializable {
     private String operationIp;
 
     /**
-     * 代理ip地址
+     * 代理信息
      */
     private String operationAgent;
 

+ 2 - 2
dblayer-mbg/src/main/java/com/lantone/dblayermbg/entity/AbnormalLog.java

@@ -68,10 +68,10 @@ public class AbnormalLog implements Serializable {
     private Integer operationIp;
 
     /**
-     * 代理ip地址
+     * 代理信息
      */
     @TableField("operation_agent")
-    private Integer operationAgent;
+    private String operationAgent;
 
     /**
      * 操作异常信息

+ 1 - 1
dblayer-mbg/src/main/resources/mapper/AbnormalLogMapper.xml

@@ -3,6 +3,6 @@
 <mapper namespace="com.lantone.dblayermbg.mapper.AbnormalLogMapper">
     <insert id="addOperErrorLog">
     insert into sys_abnormal_log(operation_id,operation_name,operation_ip,operation_agent,operation_error_info,operation_method,operation_way,operation_url,operation_param,gmt_create)
-    values (#{operationId},#{operationName},INET_ATON(#{operationIp}),INET_ATON(#{operationAgent}),#{operationErrorInfo},#{operationMethod},#{operationWay},#{operationUrl},#{operationParam},#{gmtCreate})
+    values (#{operationId},#{operationName},INET_ATON(#{operationIp}),#{operationAgent},#{operationErrorInfo},#{operationMethod},#{operationWay},#{operationUrl},#{operationParam},#{gmtCreate})
     </insert>
 </mapper>

+ 1 - 0
security-center/src/main/java/com/lantone/security/aop/LogAspect.java

@@ -96,6 +96,7 @@ public class LogAspect {
         AbnormalLogDTO abnormalLogDTO = new AbnormalLogDTO();
         OperationLogDTO operationLog = multiplexing(joinPoint);
         BeanUtils.copyProperties(operationLog,abnormalLogDTO);
+        abnormalLogDTO.setOperationAgent(HttpUtils.getHttpServletRequest().getHeader("User-Agent"));
         abnormalLogDTO.setOperationErrorInfo(StringUtils.substring(e.toString(), 0, 1000));
         messageSender.operErrorLogRecordMessage(abnormalLogDTO);
     }