Commit cd230db2 authored by 李健华's avatar 李健华

添加禁止访问日志

parent f0372a18
package cn.quantgroup.xyqb.aspect.forbidden; package cn.quantgroup.xyqb.aspect.forbidden;
import cn.quantgroup.xyqb.exception.AccessForbiddenException; import cn.quantgroup.xyqb.exception.AccessForbiddenException;
import cn.quantgroup.xyqb.util.IpUtil;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.annotation.Aspect; import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before; import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut; import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import javax.servlet.http.HttpServletRequest;
@Aspect @Aspect
@Component @Component
...@@ -17,6 +22,8 @@ public class AccessForbiddenAspect { ...@@ -17,6 +22,8 @@ public class AccessForbiddenAspect {
@Before("pointCutAt()") @Before("pointCutAt()")
private void before() throws Throwable { private void before() throws Throwable {
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
log.info("访问已下线接口, url={}, clientIp={}", request.getRequestURI(), IpUtil.getRemoteIP(request));
throw new AccessForbiddenException("禁止访问,接口已下线"); throw new AccessForbiddenException("禁止访问,接口已下线");
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment