审计日志相关代码提交

This commit is contained in:
2022-07-13 15:44:05 +08:00
parent 1129172b3d
commit 783e75e341
21 changed files with 195 additions and 54 deletions

View File

@@ -64,10 +64,10 @@
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
</dependency>
<!-- <dependency>-->
<!-- <groupId>com.alibaba</groupId>-->
<!-- <artifactId>easyexcel</artifactId>-->
<!-- </dependency>-->
<!-- <dependency>-->
<!-- <groupId>com.alibaba</groupId>-->
<!-- <artifactId>easyexcel</artifactId>-->
<!-- </dependency>-->
<!--API接口文档-->
<dependency>
<groupId>com.github.xiaoymin</groupId>
@@ -91,6 +91,11 @@
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
</dependency>
<!--mqtt相关依赖-->
<dependency>
<groupId>com.github.tocrhz</groupId>
<artifactId>mqtt-spring-boot-starter</artifactId>
</dependency>
</dependencies>
</project>

View File

@@ -29,12 +29,26 @@ public class LogInfoDTO implements Serializable {
private String operateType;
private String result;
/**
* 操作结果 0.失败 1.成功
*/
private Integer result;
private String level;
/**
* 严重度 0.普通 1.中等 2.严重
*/
private Integer level;
private String type;
/**
* 事件类型 0.业务事件 1.系统事件
*/
private Integer type;
private String serviceName;
/**
* 0 未登录; 1 已登录
*/
private Integer isLogin;
}

View File

@@ -2,6 +2,7 @@ package com.njcn.common.utils;
import cn.hutool.core.util.RandomUtil;
import cn.hutool.core.util.StrUtil;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.JavaType;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
@@ -120,6 +121,21 @@ public class PubUtils {
}
}
/**
* 将实体对象转为JSON
*
* @param object 实体对象
*/
public static String obj2json(Object object) {
try {
MAPPER.configure(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY, true);
return MAPPER.writeValueAsString(object);
} catch (IOException e) {
throw new IllegalArgumentException("将将实体对象转为JSON时发生错误:" + object, e);
}
}
/**
* 判断一个数字是否在区间内
*