🎨 优化代码

This commit is contained in:
ronger 2022-01-13 20:51:47 +08:00
parent f3a823c773
commit 6c3f2d9844
2 changed files with 53 additions and 52 deletions

View File

@ -1,5 +1,6 @@
package com.rymcu.forest.config; package com.rymcu.forest.config;
import com.rymcu.forest.util.Utils;
import org.aspectj.lang.JoinPoint; import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.AfterReturning; import org.aspectj.lang.annotation.AfterReturning;
import org.aspectj.lang.annotation.Aspect; import org.aspectj.lang.annotation.Aspect;
@ -48,14 +49,12 @@ public class WebLogAspect {
// 接收到请求记录请求内容 // 接收到请求记录请求内容
logger.info("WebLogAspect.doBefore()"); logger.info("WebLogAspect.doBefore()");
ServletRequestAttributes attributes = ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
(ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
HttpServletRequest request = attributes.getRequest(); HttpServletRequest request = attributes.getRequest();
// 记录下请求内容 // 记录下请求内容
logger.info("URL : " + request.getRequestURL().toString()); logger.info("URL : " + request.getRequestURL().toString());
logger.info("HTTP_METHOD : " + request.getMethod()); logger.info("HTTP_METHOD : " + request.getMethod());
logger.info("IP : " + request.getRemoteAddr()); logger.info("IP : " + Utils.getIpAddress(request));
logger.info( logger.info(
"CLASS_METHOD : " "CLASS_METHOD : "
+ joinPoint.getSignature().getDeclaringTypeName() + joinPoint.getSignature().getDeclaringTypeName()

View File

@ -42,6 +42,7 @@ public class Utils {
/** /**
* 一般检查工具密码比对 add by xlf 2018-11-8 * 一般检查工具密码比对 add by xlf 2018-11-8
*
* @param pwd * @param pwd
* @param enpwd 加密的密码 * @param enpwd 加密的密码
* @return * @return
@ -80,9 +81,10 @@ public class Utils {
/** /**
* 获取配置文件内属性 * 获取配置文件内属性
*
* @param key 键值 * @param key 键值
* @return 属性值 * @return 属性值
* */ */
public static String getProperty(String key) { public static String getProperty(String key) {
return env.getProperty(key); return env.getProperty(key);
} }
@ -202,7 +204,7 @@ public class Utils {
ip = ip.substring(0, ip.indexOf(",")).trim(); ip = ip.substring(0, ip.indexOf(",")).trim();
} }
return ip; return "0:0:0:0:0:0:0:1".equals(ip) ? "127.0.0.1" : ip;
} }
public static Map getNotificationDTOsGlobalResult(PageInfo<NotificationDTO> pageInfo) { public static Map getNotificationDTOsGlobalResult(PageInfo<NotificationDTO> pageInfo) {