From 08609348883df8986e039566551046e0a1bf61d7 Mon Sep 17 00:00:00 2001
From: 疯狂的狮子li <15040126243@163.com>
Date: 星期六, 29 五月 2021 21:52:15 +0800
Subject: [PATCH] update 优化数据权限sql 解决MP apply注入附带 AND 语法问题

---
 ruoyi-system/src/main/resources/mapper/system/SysRoleMapper.xml |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/ruoyi-system/src/main/resources/mapper/system/SysRoleMapper.xml b/ruoyi-system/src/main/resources/mapper/system/SysRoleMapper.xml
index 5440f4f..1a542f8 100644
--- a/ruoyi-system/src/main/resources/mapper/system/SysRoleMapper.xml
+++ b/ruoyi-system/src/main/resources/mapper/system/SysRoleMapper.xml
@@ -58,7 +58,9 @@
             and date_format(r.create_time,'%y%m%d') &lt;= date_format(#{role.params.endTime},'%y%m%d')
         </if>
         <!-- 鏁版嵁鑼冨洿杩囨护 -->
-        ${role.params.dataScope}
+        <if test="role.params.dataScope != null and role.params.dataScope != ''">
+            AND ( ${role.params.dataScope} )
+        </if>
         order by r.role_sort
     </select>
 
@@ -81,7 +83,9 @@
             and date_format(r.create_time,'%y%m%d') &lt;= date_format(#{params.endTime},'%y%m%d')
         </if>
         <!-- 鏁版嵁鑼冨洿杩囨护 -->
-        ${params.dataScope}
+        <if test="params.dataScope != null and params.dataScope != ''">
+            AND ( ${params.dataScope} )
+        </if>
         order by r.role_sort
     </select>
 

--
Gitblit v1.9.3