hexiao hace 2 años
padre
commit
0298b3a44d

+ 0 - 23
purchase-admin/src/main/java/com/ozs/web/filter/LogFilter.java

@@ -1,23 +0,0 @@
-package com.ozs.web.filter;
-
-import ch.qos.logback.classic.spi.ILoggingEvent;
-import ch.qos.logback.core.filter.Filter;
-import ch.qos.logback.core.spi.FilterReply;
-import com.ozs.common.utils.SecurityUtils;
-import org.springframework.util.ObjectUtils;
-
-public class LogFilter extends Filter<ILoggingEvent> {
-
-
-    @Override
-    public FilterReply decide(ILoggingEvent event) {
-        Long userId = SecurityUtils.getUserId();
-        System.out.println("****");
-        System.out.println("****:" + userId);
-//        if (!ObjectUtils.isEmpty(userId) && userId.equals(Long.parseLong("1"))) {
-//            return FilterReply.DENY;
-//        }
-        return FilterReply.ACCEPT;
-    }
-
-}

+ 25 - 0
purchase-admin/src/main/java/com/ozs/web/filter/LogOutFilter.java

@@ -0,0 +1,25 @@
+package com.ozs.web.filter;
+
+import ch.qos.logback.classic.spi.ILoggingEvent;
+import ch.qos.logback.core.filter.Filter;
+import ch.qos.logback.core.spi.FilterReply;
+import com.ozs.common.constant.Constants;
+import com.ozs.common.utils.SecurityUtils;
+import lombok.extern.slf4j.Slf4j;
+
+@Slf4j
+public class LogOutFilter extends Filter<ILoggingEvent> {
+
+
+    @Override
+    public FilterReply decide(ILoggingEvent event) {
+        if (Constants.FLAY) {
+            Long userId = SecurityUtils.getUserId();
+            if (userId.equals(Long.parseLong("1"))) {
+                return FilterReply.DENY;
+            }
+        }
+        return FilterReply.ACCEPT;
+    }
+
+}

+ 1 - 1
purchase-admin/src/main/resources/logback.xml

@@ -8,7 +8,7 @@
 
     <!-- 控制台输出 -->
     <appender name="console" class="ch.qos.logback.core.ConsoleAppender">
-        <filter class="com.ozs.web.filter.LogFilter"/>
+        <filter class="com.ozs.web.filter.LogOutFilter"/>
         <encoder>
             <pattern>${log.pattern}</pattern>
         </encoder>

+ 2 - 0
purchase-common/src/main/java/com/ozs/common/constant/Constants.java

@@ -162,4 +162,6 @@ public class Constants {
     public static final String PROJECT_WARN_STATUS = "project_warn_status";
     // 单位性质
     public static final String SYS_COMPANY_NATURE = "sys_company_nature";
+
+    public static boolean FLAY = false;
 }

+ 4 - 0
purchase-framework/src/main/java/com/ozs/framework/web/service/SysLoginService.java

@@ -3,6 +3,7 @@ package com.ozs.framework.web.service;
 import javax.annotation.Resource;
 
 import com.ozs.framework.manager.factory.AsyncFactory;
+import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.security.authentication.AuthenticationManager;
 import org.springframework.security.authentication.BadCredentialsException;
@@ -34,6 +35,7 @@ import com.ozs.system.service.ISysUserService;
  * @author ruoyi
  */
 @Component
+@Slf4j
 public class SysLoginService {
     @Autowired
     private TokenService tokenService;
@@ -91,6 +93,8 @@ public class SysLoginService {
         //记录登录信息
         recordLoginInfo(loginUser.getUserId());
         // 生成token
+        Constants.FLAY = true;
+        log.info("******【" + Constants.FLAY + "】*******");
         return tokenService.createToken(loginUser);
     }