|
|
@@ -5,6 +5,8 @@ import cn.hutool.json.JSONUtil;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.fasterxml.jackson.databind.JsonNode;
|
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
+import com.google.gson.JsonObject;
|
|
|
+import com.google.gson.JsonParser;
|
|
|
import com.lc.ibps.base.web.context.ContextUtil;
|
|
|
import com.lc.ibps.cloud.util.AESUtil;
|
|
|
import com.lc.ibps.cloud.utils.RequestUtil;
|
|
|
@@ -19,10 +21,7 @@ import java.nio.ByteBuffer;
|
|
|
import java.nio.ByteOrder;
|
|
|
import java.time.Duration;
|
|
|
import java.time.Instant;
|
|
|
-import java.util.Base64;
|
|
|
-import java.util.HashMap;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
+import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
import java.util.stream.Stream;
|
|
|
|
|
|
@@ -64,9 +63,26 @@ public class LogAopUtil {
|
|
|
map.put("response_", JSONUtil.toJsonStr(result));
|
|
|
map.put("uri_", request.getRequestURI());
|
|
|
map.put("type_", "正常日志");
|
|
|
+ map.put("table_name", getTableName(map.get("params_")));
|
|
|
return map;
|
|
|
}
|
|
|
|
|
|
+ private static String getTableName(Object jsonParams) {
|
|
|
+ if(isNotEmpty(jsonParams)){
|
|
|
+ try {
|
|
|
+ JsonObject jsonObject = JsonParser.parseString((String) jsonParams).getAsJsonObject();
|
|
|
+ if (jsonObject.has("tableName") && !jsonObject.get("tableName").isJsonNull()) {
|
|
|
+ return jsonObject.get("tableName").getAsString();
|
|
|
+ }
|
|
|
+ return "";
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ return "";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return "";
|
|
|
+ }
|
|
|
+
|
|
|
public static Map<String,Object> logError(HttpServletRequest request, ProceedingJoinPoint point, Throwable throwable) {
|
|
|
// 记录操作日志
|
|
|
Map<String,Object> map = new HashMap<>();
|
|
|
@@ -81,6 +97,7 @@ public class LogAopUtil {
|
|
|
PrintWriter pw = new PrintWriter(sw);
|
|
|
throwable.printStackTrace(pw);
|
|
|
map.put("error_", sw.toString());
|
|
|
+ map.put("table_name", getTableName(map.get("params_")));
|
|
|
return map;
|
|
|
}
|
|
|
|
|
|
@@ -132,5 +149,29 @@ public class LogAopUtil {
|
|
|
return false;
|
|
|
}
|
|
|
}
|
|
|
+ public static boolean isNotEmpty(Object obj) {
|
|
|
+ if (obj == null) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (obj instanceof String) {
|
|
|
+ return !((String) obj).trim().isEmpty();
|
|
|
+ }
|
|
|
+
|
|
|
+ if (obj instanceof Collection) {
|
|
|
+ return !((Collection<?>) obj).isEmpty();
|
|
|
+ }
|
|
|
+
|
|
|
+ if (obj instanceof Map) {
|
|
|
+ return !((Map<?, ?>) obj).isEmpty();
|
|
|
+ }
|
|
|
+
|
|
|
+ if (obj instanceof Object[]) {
|
|
|
+ return ((Object[]) obj).length > 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 其他情况认为不为空
|
|
|
+ return true;
|
|
|
+ }
|
|
|
|
|
|
}
|