Browse Source

应用审核后续处理微服务 修正

LT32820A 1 week ago
parent
commit
3d818a1e94

+ 2 - 1
jeecg-boot/jeecg-boot-base-core/src/main/java/org/jeecg/config/shiro/ShiroConfig.java

@@ -84,7 +84,8 @@ public class ShiroConfig {
         }
 
         // 配置不会被拦截的链接 顺序判断
-        filterChainDefinitionMap.put("/sys/applicationInfo/afterAppCheckPass", "anon"); //应用审核后续处理(微服务提供端)
+        filterChainDefinitionMap.put("/test/**", "anon"); //应用审核后续处理(微服务提供端)
+        filterChainDefinitionMap.put("/sys/applicationInfo/test", "anon"); //应用审核后续处理(微服务提供端)
         filterChainDefinitionMap.put("/WF/API/test", "anon"); //cas验证登录
         filterChainDefinitionMap.put("/sys/cas/client/validateLogin", "anon"); //cas验证登录
         filterChainDefinitionMap.put("/sys/randomImage/**", "anon"); //登录验证码接口排除

+ 9 - 1
jeecg-boot/jflow-core/src/main/java/bp/sys/BuessUnitAfterAppCheckPass.java → jeecg-boot/jflow-core/src/main/java/bp/sys/CustomBuessUnit/BuessUnitAfterAppCheckPass.java

@@ -1,7 +1,10 @@
-package bp.sys;
+package bp.sys.CustomBuessUnit;
 
 import bp.difference.BeanUtils;
 import bp.difference.feign.SystemClient;
+import bp.sys.BuessUnitBase;
+import org.jeecg.common.config.mqtoken.UserTokenContext;
+
 /**
  * 功能描述 应用审核通过后续处理
  *
@@ -18,7 +21,12 @@ public class BuessUnitAfterAppCheckPass extends BuessUnitBase {
     @Override
     public String DoIt()  {
         SystemClient systemClient = BeanUtils.getBean(SystemClient.class);
+        //1.设置线程会话Token
+        UserTokenContext.setToken(Commonutils.getTemporaryToken());
         systemClient.afterAppCheckPass(this.WorkID);
+        //2.使用完删除Token,避免性能(这一步可以不做,但是为了性能建议执行)
+        UserTokenContext.remove();
         return null;
     }
+
 }

+ 30 - 0
jeecg-boot/jflow-core/src/main/java/bp/sys/CustomBuessUnit/Commonutils.java

@@ -0,0 +1,30 @@
+package bp.sys.CustomBuessUnit;
+
+import bp.da.DBAccess;
+import bp.web.WebUser;
+import org.jeecg.common.constant.CommonConstant;
+import org.jeecg.common.system.util.JwtUtil;
+import org.jeecg.common.util.RedisUtil;
+import org.jeecg.common.util.SpringContextUtils;
+
+/**
+ * 功能描述
+ *
+ * @author: scott
+ * @date: 2024年12月26日 AM 10:27
+ */
+public class Commonutils {
+    public static String getTemporaryToken() {
+        RedisUtil redisUtil = SpringContextUtils.getBean(RedisUtil.class);
+        //模拟登录生成临时Token
+        //参数说明:第一个参数是用户名、第二个参数是密码的加密串
+        String sql = "select password from sys_user where username='"+ WebUser.getUserID()+"'";
+        String psd = DBAccess.RunSQLReturnString(sql);
+        String token = JwtUtil.sign(WebUser.getUserID(), psd);
+        // 设置Token缓存有效时间为 5 分钟
+        redisUtil.set(CommonConstant.PREFIX_USER_TOKEN + token, token);
+        redisUtil.expire(CommonConstant.PREFIX_USER_TOKEN + token, 5 * 60 * 1000);
+        return token;
+    }
+
+}

+ 1 - 1
jeecg-boot/jflow-core/src/main/java/bp/sys/base/Glo.java

@@ -201,7 +201,7 @@ public class Glo
 				enName = "bp.demo.BuessUnitDemo";
 				break;
 			case "应用审核通过后续处理":
-				enName = "bp.sys.BuessUnitAfterAppCheckPass";
+				enName = "bp.sys.CustomBuessUnit.BuessUnitAfterAppCheckPass";
 				break;
 			default:
 		}