From 5944c9ea054165cc4adfa79254f9b724abc371db Mon Sep 17 00:00:00 2001
From: ZQN <364596817@qq.com>
Date: 星期二, 03 九月 2024 13:52:00 +0800
Subject: [PATCH] 执法记录条件

---
 project-framework/src/main/java/com/project/framework/aspectj/DataScopeAspect.java |   20 ++++++++++++--------
 1 files changed, 12 insertions(+), 8 deletions(-)

diff --git a/project-framework/src/main/java/com/project/framework/aspectj/DataScopeAspect.java b/project-framework/src/main/java/com/project/framework/aspectj/DataScopeAspect.java
index b533252..0305543 100644
--- a/project-framework/src/main/java/com/project/framework/aspectj/DataScopeAspect.java
+++ b/project-framework/src/main/java/com/project/framework/aspectj/DataScopeAspect.java
@@ -2,6 +2,7 @@
 
 import com.project.common.annotation.DataScope;
 import com.project.common.core.domain.BaseEntity;
+import com.project.common.core.domain.BaseQuery;
 import com.project.common.core.domain.entity.SysRole;
 import com.project.common.core.domain.entity.SysUser;
 import com.project.common.core.domain.model.LoginUser;
@@ -81,6 +82,8 @@
                 String permission = StringUtils.defaultIfEmpty(controllerDataScope.permission(), PermissionContextHolder.getContext());
                 dataScopeFilter(joinPoint, currentUser, controllerDataScope.deptAlias(),
                         controllerDataScope.userAlias(), permission);
+            } else {
+
             }
         }
     }
@@ -124,19 +127,13 @@
             }
             else if (DATA_SCOPE_DEPT.equals(dataScope))
             {
-                sqlString.append(StringUtils.format(" OR {}.dept_id = {} ", deptAlias, user.getDeptId()));
+                sqlString.append(StringUtils.format(" OR {} = {} ", deptAlias, user.getDeptId()));
             }
             else if (DATA_SCOPE_DEPT_AND_CHILD.equals(dataScope))
             {
                 sqlString.append(StringUtils.format(
                         " OR {} IN ( SELECT dept_id FROM sys_dept WHERE dept_id = {} or find_in_set( {} , ancestors ) )",
                         deptAlias, user.getDeptId(), user.getDeptId()));
-            }
-            else if (DATA_SCOPE_ORG.equals(dataScope))
-            {
-                sqlString.append(StringUtils.format(
-                        " OR {} IN ( SELECT dept_id FROM sys_dept WHERE dept_id = {} or find_in_set( {} , ancestors ) )",
-                        deptAlias, user.getRecommendUser(), user.getRecommendUser()));
             }
             else if (DATA_SCOPE_SELF.equals(dataScope))
             {
@@ -159,7 +156,10 @@
             if (StringUtils.isNotNull(params) && params instanceof BaseEntity)
             {
                 BaseEntity baseEntity = (BaseEntity) params;
-                baseEntity.getParams().put(DATA_SCOPE, " AND (" + sqlString.substring(4) + ")");
+                baseEntity.getParams().put(DATA_SCOPE, "  (" + sqlString.substring(4) + ")");
+            } else if (StringUtils.isNotNull(params) && params instanceof BaseQuery) {
+                BaseQuery baseQuery = (BaseQuery) params;
+                baseQuery.getParams().put(DATA_SCOPE, "  (" + sqlString.substring(4) + ")");
             }
         }
     }
@@ -175,5 +175,9 @@
             BaseEntity baseEntity = (BaseEntity) params;
             baseEntity.getParams().put(DATA_SCOPE, "");
         }
+        else if (StringUtils.isNotNull(params) && params instanceof BaseQuery) {
+            BaseQuery baseQuery = (BaseQuery) params;
+            baseQuery.getParams().put(DATA_SCOPE, "");
+        }
     }
 }

--
Gitblit v1.9.1