From e8095f403e6dbf209489746a49a306f4165ea0cd Mon Sep 17 00:00:00 2001
From: whycq <10027870+whycq@user.noreply.gitee.com>
Date: 星期一, 01 七月 2024 19:35:11 +0800
Subject: [PATCH] #pda权限

---
 src/main/java/com/zy/common/web/BaseController.java |   82 +++++++++++++++++++++++++---------------
 1 files changed, 51 insertions(+), 31 deletions(-)

diff --git a/src/main/java/com/zy/common/web/BaseController.java b/src/main/java/com/zy/common/web/BaseController.java
index 6d9033f..0309a4a 100644
--- a/src/main/java/com/zy/common/web/BaseController.java
+++ b/src/main/java/com/zy/common/web/BaseController.java
@@ -38,37 +38,14 @@
     private TagService tagService;
     @Autowired
     private NodeService nodeService;
+
     @Autowired
     private UserLoginService userLoginService;
 
-    protected Node getOriginNode(){
-        Node node = nodeService.getTop();
-        if (node == null) {
-            throw new CoolException("搴撳尯鏁版嵁閿欒");
-        }
-        return node;
-    }
-
-    protected Long getHostId(){
-        if (getUserId() == 9527) {
-            return null;
-        }
-        User user = getUser();
-        if (user.getRoleId() == 1) {
-            String hostId = String.valueOf(request.getAttribute("hostId"));
-            if (Cools.isEmpty(hostId)) {
-                UserLogin userLogin = userLoginService.selectOne(new EntityWrapper<UserLogin>().eq("user_id", user.getId()));
-                if (userLogin != null) {
-                    return userLogin.getHostId();
-                }
-            }
-            return Long.parseLong(hostId);
-        } else {
-            return user.getHostId();
-        }
-    }
-
     protected Long getUserId(){
+        if(Cools.isEmpty(request.getAttribute("userId"))){
+            return 000L;
+        }
         return Long.parseLong(String.valueOf(request.getAttribute("userId")));
     }
 
@@ -94,11 +71,12 @@
         return tagService.getTop();
     }
 
-    protected <T> void hostEq(EntityWrapper<T> wrapper){
-        Long hostId = getHostId();
-        if (hostId != null) {
-            wrapper.eq("host_id", hostId);
+    protected Node getOriginNode(){
+        Node node = nodeService.getTop();
+        if (node == null) {
+            throw new CoolException("搴撳尯鏁版嵁閿欒");
         }
+        return node;
     }
 
     /**
@@ -185,6 +163,48 @@
         }
     }
 
+    public static boolean isJSON(String str) {
+        if (Cools.isEmpty(str)) {
+            return false;
+        } else {
+            str = str.trim();
+            if (str.startsWith("{") && str.endsWith("}")) {
+                return true;
+            } else if (str.startsWith("[") && str.endsWith("]")) {
+                return true;
+            } else {
+                return false;
+            }
+        }
+    }
+
+    protected <T> void hostEq(EntityWrapper<T> wrapper){
+        Long hostId = getHostId();
+        if (hostId != null) {
+            wrapper.eq("host_id", hostId);
+        }
+    }
+
+    protected Long getHostId(){
+        if (getUserId() == 9527) {
+            return null;
+        }
+        User user = getUser();
+        if (user.getRoleId() == 1) {
+            String hostId = String.valueOf(request.getAttribute("hostId"));
+            if (Cools.isEmpty(hostId)) {
+                UserLogin userLogin = userLoginService.selectOne(new EntityWrapper<UserLogin>().eq("user_id", user.getId()));
+                if (userLogin != null) {
+                    //return userLogin.getHostId();
+                    return 1L;
+                }
+            }
+            return Long.parseLong(hostId);
+        } else {
+            return user.getHostId();
+        }
+    }
+
     public static boolean isNumber(String str){
         for (int i = str.length();--i>=0;){
             if (!Character.isDigit(str.charAt(i))){

--
Gitblit v1.9.1