From 2c2dad24d59b37df254d1c003d6c3e1119b51d6c Mon Sep 17 00:00:00 2001 From: 疯狂的狮子li <15040126243@163.com> Date: 星期三, 11 八月 2021 14:28:05 +0800 Subject: [PATCH] update 更新 阿里云 maven源 新地址 --- ruoyi-framework/src/main/java/com/ruoyi/framework/aspectj/LogAspect.java | 54 +++++++++++++++++++++++------------------------------- 1 files changed, 23 insertions(+), 31 deletions(-) diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/aspectj/LogAspect.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/aspectj/LogAspect.java index 57dc582..c902511 100644 --- a/ruoyi-framework/src/main/java/com/ruoyi/framework/aspectj/LogAspect.java +++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/aspectj/LogAspect.java @@ -1,16 +1,14 @@ package com.ruoyi.framework.aspectj; -import cn.hutool.core.util.StrUtil; -import com.alibaba.fastjson.JSON; import com.ruoyi.common.annotation.Log; import com.ruoyi.common.core.domain.model.LoginUser; import com.ruoyi.common.enums.BusinessStatus; import com.ruoyi.common.enums.HttpMethod; +import com.ruoyi.common.utils.JsonUtils; import com.ruoyi.common.utils.ServletUtils; -import com.ruoyi.common.utils.ip.IpUtils; +import com.ruoyi.common.utils.StringUtils; import com.ruoyi.common.utils.spring.SpringUtils; -import com.ruoyi.framework.manager.AsyncManager; -import com.ruoyi.framework.manager.factory.AsyncFactory; +import com.ruoyi.framework.web.service.AsyncService; import com.ruoyi.framework.web.service.TokenService; import com.ruoyi.system.domain.SysOperLog; import org.aspectj.lang.JoinPoint; @@ -31,7 +29,6 @@ import javax.servlet.http.HttpServletResponse; import java.lang.reflect.Method; import java.util.Collection; -import java.util.Iterator; import java.util.Map; /** @@ -92,10 +89,10 @@ SysOperLog operLog = new SysOperLog(); operLog.setStatus(BusinessStatus.SUCCESS.ordinal()); // 璇锋眰鐨勫湴鍧� - String ip = IpUtils.getIpAddr(ServletUtils.getRequest()); + String ip = ServletUtils.getClientIP(); operLog.setOperIp(ip); // 杩斿洖鍙傛暟 - operLog.setJsonResult(JSON.toJSONString(jsonResult)); + operLog.setJsonResult(JsonUtils.toJsonString(jsonResult)); operLog.setOperUrl(ServletUtils.getRequest().getRequestURI()); if (loginUser != null) @@ -106,7 +103,7 @@ if (e != null) { operLog.setStatus(BusinessStatus.FAIL.ordinal()); - operLog.setErrorMsg(StrUtil.sub(e.getMessage(), 0, 2000)); + operLog.setErrorMsg(StringUtils.substring(e.getMessage(), 0, 2000)); } // 璁剧疆鏂规硶鍚嶇О String className = joinPoint.getTarget().getClass().getName(); @@ -117,7 +114,7 @@ // 澶勭悊璁剧疆娉ㄨВ涓婄殑鍙傛暟 getControllerMethodDescription(joinPoint, controllerLog, operLog); // 淇濆瓨鏁版嵁搴� - AsyncManager.me().execute(AsyncFactory.recordOper(operLog)); + SpringUtils.getBean(AsyncService.class).recordOper(operLog); } catch (Exception exp) { @@ -163,12 +160,12 @@ if (HttpMethod.PUT.name().equals(requestMethod) || HttpMethod.POST.name().equals(requestMethod)) { String params = argsArrayToString(joinPoint.getArgs()); - operLog.setOperParam(StrUtil.sub(params, 0, 2000)); + operLog.setOperParam(StringUtils.substring(params, 0, 2000)); } else { Map<?, ?> paramsMap = (Map<?, ?>) ServletUtils.getRequest().getAttribute(HandlerMapping.URI_TEMPLATE_VARIABLES_ATTRIBUTE); - operLog.setOperParam(StrUtil.sub(paramsMap.toString(), 0, 2000)); + operLog.setOperParam(StringUtils.substring(paramsMap.toString(), 0, 2000)); } } @@ -193,19 +190,16 @@ */ private String argsArrayToString(Object[] paramsArray) { - String params = ""; + StringBuilder params = new StringBuilder(); if (paramsArray != null && paramsArray.length > 0) { - for (int i = 0; i < paramsArray.length; i++) - { - if (StrUtil.isNotNull(paramsArray[i]) && !isFilterObject(paramsArray[i])) - { - Object jsonObj = JSON.toJSON(paramsArray[i]); - params += jsonObj.toString() + " "; - } - } + for (Object o : paramsArray) { + if (StringUtils.isNotNull(o) && !isFilterObject(o)) { + params.append(JsonUtils.toJsonString(o)).append(" "); + } + } } - return params.trim(); + return params.toString().trim(); } /** @@ -225,19 +219,17 @@ else if (Collection.class.isAssignableFrom(clazz)) { Collection collection = (Collection) o; - for (Iterator iter = collection.iterator(); iter.hasNext();) - { - return iter.next() instanceof MultipartFile; - } + for (Object value : collection) { + return value instanceof MultipartFile; + } } else if (Map.class.isAssignableFrom(clazz)) { Map map = (Map) o; - for (Iterator iter = map.entrySet().iterator(); iter.hasNext();) - { - Map.Entry entry = (Map.Entry) iter.next(); - return entry.getValue() instanceof MultipartFile; - } + for (Object value : map.entrySet()) { + Map.Entry entry = (Map.Entry) value; + return entry.getValue() instanceof MultipartFile; + } } return o instanceof MultipartFile || o instanceof HttpServletRequest || o instanceof HttpServletResponse || o instanceof BindingResult; -- Gitblit v1.9.3