From 08b4403ec8d6b69528d161cfcad80b5d64dea76c Mon Sep 17 00:00:00 2001
From: Administrator <876263681@qq.com>
Date: 星期三, 02 七月 2025 15:12:43 +0800
Subject: [PATCH] #优化库位检索

---
 src/main/java/com/zy/common/web/BaseController.java |   91 ++++++++++++++++++++++++++++++---------------
 1 files changed, 60 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 995c3d9..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;
     }
 
     /**
@@ -184,4 +162,55 @@
             wrapper.like(columns.get(i), condition);
         }
     }
+
+    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))){
+                return false;
+            }
+        }
+        return true;
+    }
 }

--
Gitblit v1.9.1