mirror of
				https://github.com/continew-org/continew-admin.git
				synced 2025-10-31 10:57:13 +08:00 
			
		
		
		
	refactor: 适配 ContiNew Starter 日志调整
This commit is contained in:
		| @@ -16,7 +16,6 @@ | ||||
|  | ||||
| package top.charles7c.continew.admin.monitor.config; | ||||
|  | ||||
| import java.net.URI; | ||||
| import java.time.LocalDateTime; | ||||
| import java.time.ZoneId; | ||||
| import java.util.List; | ||||
| @@ -74,12 +73,8 @@ public class LogDaoLocalImpl implements LogDao { | ||||
|         // 请求信息 | ||||
|         LogRequest logRequest = logRecord.getRequest(); | ||||
|         logDO.setRequestMethod(logRequest.getMethod()); | ||||
|         // 仅记录:/xxx?xx=xx&xx=xx | ||||
|         URI requestUri = logRequest.getUri(); | ||||
|         String requestQuery = requestUri.getQuery(); | ||||
|         String requestUrl = StrUtil.isNotBlank(requestQuery) | ||||
|             ? requestUri.getPath() + StringConstants.QUESTION_MARK + requestQuery : requestUri.getPath(); | ||||
|         logDO.setRequestUrl(requestUrl); | ||||
|         String requestUri = logRequest.getUri().toString(); | ||||
|         logDO.setRequestUri(requestUri); | ||||
|         Map<String, List<String>> requestHeaders = logRequest.getHeaders(); | ||||
|         logDO.setRequestHeaders(JSONUtil.toJsonStr(requestHeaders)); | ||||
|         String requestBody = logRequest.getBody(); | ||||
| @@ -104,17 +99,17 @@ public class LogDaoLocalImpl implements LogDao { | ||||
|                 logDO.setErrorMsg(result.getMsg()); | ||||
|             } | ||||
|             // 操作人 | ||||
|             if (requestUrl.startsWith(SysConstants.LOGOUT_URI)) { | ||||
|             if (requestUri.startsWith(SysConstants.LOGOUT_URI)) { | ||||
|                 Long loginId = Convert.toLong(result.getData(), -1L); | ||||
|                 logDO.setCreateUser(-1 != loginId ? loginId : null); | ||||
|             } else if (result.isSuccess() && requestUrl.startsWith(SysConstants.LOGIN_URI)) { | ||||
|             } else if (result.isSuccess() && requestUri.startsWith(SysConstants.LOGIN_URI)) { | ||||
|                 AccountLoginReq loginReq = JSONUtil.toBean(requestBody, AccountLoginReq.class); | ||||
|                 logDO.setCreateUser( | ||||
|                     ExceptionUtils.exToNull(() -> userService.getByUsername(loginReq.getUsername()).getId())); | ||||
|             } | ||||
|         } | ||||
|         // 操作人 | ||||
|         if (!requestUrl.startsWith(SysConstants.LOGOUT_URI) && MapUtil.isNotEmpty(requestHeaders) | ||||
|         if (!requestUri.startsWith(SysConstants.LOGOUT_URI) && MapUtil.isNotEmpty(requestHeaders) | ||||
|             && requestHeaders.containsKey(HttpHeaders.AUTHORIZATION)) { | ||||
|             String authorization = requestHeaders.get(HttpHeaders.AUTHORIZATION).get(0); | ||||
|             String token = authorization.replace(SaManager.getConfig().getTokenPrefix() + StringConstants.SPACE, | ||||
|   | ||||
| @@ -57,9 +57,9 @@ public class LogDO implements Serializable { | ||||
|     private String module; | ||||
|  | ||||
|     /** | ||||
|      * 请求URL | ||||
|      * 请求 URI | ||||
|      */ | ||||
|     private String requestUrl; | ||||
|     private String requestUri; | ||||
|  | ||||
|     /** | ||||
|      * 请求方式 | ||||
|   | ||||
| @@ -48,10 +48,10 @@ public class SystemLogDetailResp extends LogResp { | ||||
|     private String requestMethod; | ||||
|  | ||||
|     /** | ||||
|      * 请求 URL | ||||
|      * 请求 URI | ||||
|      */ | ||||
|     @Schema(description = "请求 URL", example = "/system/dept") | ||||
|     private String requestUrl; | ||||
|     @Schema(description = "请求 URI", example = "/system/dept") | ||||
|     private String requestUri; | ||||
|  | ||||
|     /** | ||||
|      * 请求头 | ||||
|   | ||||
| @@ -48,10 +48,10 @@ public class SystemLogResp extends LogResp { | ||||
|     private String requestMethod; | ||||
|  | ||||
|     /** | ||||
|      * 请求 URL | ||||
|      * 请求 URI | ||||
|      */ | ||||
|     @Schema(description = "请求 URL", example = "/system/dept") | ||||
|     private String requestUrl; | ||||
|     @Schema(description = "请求 URI", example = "/system/dept") | ||||
|     private String requestUri; | ||||
|  | ||||
|     /** | ||||
|      * IP | ||||
|   | ||||
		Reference in New Issue
	
	Block a user