Browse Source

所有系统-对system_type的针对不同系统查询方式做调整

LHB 3 months ago
parent
commit
f5359cfdcf

+ 3 - 3
src/main/java/org/springblade/modules/system/controller/RoleController.java

@@ -117,8 +117,8 @@ public class RoleController extends BladeController {
     @GetMapping("/tree")
     @ApiOperationSupport(order = 3)
     @Operation(summary = "树形结构", description = "树形结构")
-    public R<List<RoleVO>> tree(String tenantId, BladeUser bladeUser) {
-        List<RoleVO> tree = roleService.tree(Func.toStrWithEmpty(tenantId, bladeUser.getTenantId()));
+    public R<List<RoleVO>> tree(Integer systemType,String tenantId, BladeUser bladeUser) {
+        List<RoleVO> tree = roleService.tree(systemType,Func.toStrWithEmpty(tenantId, bladeUser.getTenantId()));
         return R.data(tree);
     }
 
@@ -130,7 +130,7 @@ public class RoleController extends BladeController {
     @Operation(summary = "树形结构", description = "树形结构")
     public R<List<RoleVO>> treeById(Long roleId, BladeUser bladeUser) {
         Role role = SysCache.getRole(roleId);
-        List<RoleVO> tree = roleService.tree(Func.notNull(role) ? role.getTenantId() : bladeUser.getTenantId());
+        List<RoleVO> tree = roleService.tree(null,Func.notNull(role) ? role.getTenantId() : bladeUser.getTenantId());
         return R.data(tree);
     }
 

+ 18 - 8
src/main/java/org/springblade/modules/system/mapper/MenuMapper.xml

@@ -110,9 +110,14 @@
         <if test="param2.alias!=null and param2.alias!=''">
             and menu.alias like concat(concat('%', #{param2.alias}),'%')
         </if>
-        <if test="param2.systemType!=null">
-            and menu.system_type = #{param2.systemType}
-        </if>
+        <choose>
+            <when test="param2.systemType!=null and param2.systemType!='' and param2.systemType == 2">
+                AND system_type = #{param2.systemType}
+            </when>
+            <otherwise>
+                AND (system_type is null or system_type = 1)
+            </otherwise>
+        </choose>
         ORDER BY menu.sort
     </select>
 
@@ -122,11 +127,11 @@
            and sys_type = #{param1}
         </if>
         <choose>
-            <when test="param2!=null and param2!=''">
+            <when test="param2!=null and param2!='' and param2 == 2">
                 AND system_type = #{param2}
             </when>
             <otherwise>
-                AND (system_type = null or system_type = 1)
+                AND (system_type is null or system_type = 1)
             </otherwise>
         </choose>
     </select>
@@ -160,9 +165,14 @@
         <if test="param2!=null">
             and sys_type = #{param2}
         </if>
-        <if test="param3!=null">
-            and system_type = #{param3}
-        </if>
+        <choose>
+            <when test="param3!=null and param3!='' and param3 == 2">
+                AND system_type = #{param3}
+            </when>
+            <otherwise>
+                AND (system_type is null or system_type = 1)
+            </otherwise>
+        </choose>
 
     </select>
 

+ 1 - 1
src/main/java/org/springblade/modules/system/mapper/RoleMapper.java

@@ -55,7 +55,7 @@ public interface RoleMapper extends BaseMapper<Role> {
 	 * @param excludeRole
 	 * @return
 	 */
-	List<RoleVO> tree(String tenantId, String excludeRole);
+	List<RoleVO> tree(String tenantId, String excludeRole,Integer systemType);
 
 	/**
 	 * 获取角色名

+ 8 - 0
src/main/java/org/springblade/modules/system/mapper/RoleMapper.xml

@@ -32,6 +32,14 @@
         <if test="param2!=null">
             and role_alias &lt;&gt; #{param2}
         </if>
+        <choose>
+            <when test="param3!=null and param3!='' and param3 == 2">
+                AND system_type = #{param3}
+            </when>
+            <otherwise>
+                AND (system_type is null or system_type = 1)
+            </otherwise>
+        </choose>
     </select>
 
     <select id="getRoleNames" resultType="java.lang.String">

+ 1 - 1
src/main/java/org/springblade/modules/system/service/IRoleService.java

@@ -55,7 +55,7 @@ public interface IRoleService extends IService<Role> {
 	 * @param tenantId
 	 * @return
 	 */
-	List<RoleVO> tree(String tenantId);
+	List<RoleVO> tree(Integer systemType,String tenantId);
 
 	/**
 	 * 权限配置

+ 2 - 2
src/main/java/org/springblade/modules/system/service/impl/RoleServiceImpl.java

@@ -78,13 +78,13 @@ public class RoleServiceImpl extends ServiceImpl<RoleMapper, Role> implements IR
 	}
 
 	@Override
-	public List<RoleVO> tree(String tenantId) {
+	public List<RoleVO> tree(Integer systemType,String tenantId) {
 		String userRole = AuthUtil.getUserRole();
 		String excludeRole = null;
 		if (!CollectionUtil.contains(Func.toStrArray(userRole), RoleConstant.ADMIN) && !CollectionUtil.contains(Func.toStrArray(userRole), RoleConstant.ADMINISTRATOR)) {
 			excludeRole = RoleConstant.ADMIN;
 		}
-		return ForestNodeMerger.merge(baseMapper.tree(tenantId, excludeRole));
+		return ForestNodeMerger.merge(baseMapper.tree(tenantId, excludeRole,systemType));
 	}
 
 	@Override