Prechádzať zdrojové kódy

feat(web): 新增角色查询参数支持租户过滤

- 新建 QueryRoleParam 类用于接收查询条件
- 修改 WebGateway 接口,增加参数传递- 更新 WebGatewayImpl 实现类,根据参数过滤租户
- 调整 WebRoleController 控制器,支持传入查询参数
-优化角色列表查询逻辑,增强租户数据隔离能力
chejianzheng 1 týždeň pred
rodič
commit
450411e6b8

+ 3 - 2
portal-service-application/src/main/java/com/hfln/portal/application/controller/web/WebRoleController.java

@@ -5,6 +5,7 @@ import cn.hfln.framework.catchlog.CatchAndLog;
 import cn.hfln.framework.dto.ApiResult;
 import com.hfln.portal.common.dto.data.role.RoleListDTO;
 import com.hfln.portal.common.request.web.AddRoleParam;
+import com.hfln.portal.common.request.web.QueryRoleParam;
 import com.hfln.portal.domain.gateway.WebGateway;
 import io.swagger.v3.oas.annotations.Operation;
 import io.swagger.v3.oas.annotations.tags.Tag;
@@ -42,8 +43,8 @@ public class WebRoleController {
 
     @GetMapping("/queryList")
     @Operation(summary = "获取角色列表")
-    public ApiResult<List<RoleListDTO>> roleList() {
-        List<RoleListDTO> roleList = webGateway.roleList();
+    public ApiResult<List<RoleListDTO>> roleList(@RequestBody @Valid QueryRoleParam param) {
+        List<RoleListDTO> roleList = webGateway.roleList(param);
         return ApiResult.success(roleList);
     }
 }

+ 13 - 0
portal-service-common/src/main/java/com/hfln/portal/common/request/web/QueryRoleParam.java

@@ -0,0 +1,13 @@
+package com.hfln.portal.common.request.web;
+
+import com.hfln.portal.common.vo.BaseVO;
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+
+
+@Data
+public class QueryRoleParam extends BaseVO {
+
+    @Schema(description = "所属租户")
+    private Long tenantId;
+}

+ 1 - 1
portal-service-domain/src/main/java/com/hfln/portal/domain/gateway/WebGateway.java

@@ -52,7 +52,7 @@ public interface WebGateway {
 
     void deleteRole(Long roleId);
 
-    List<RoleListDTO> roleList();
+    List<RoleListDTO> roleList(QueryRoleParam param);
 
 
 

+ 5 - 1
portal-service-infrastructure/src/main/java/com/hfln/portal/infrastructure/gateway/impl/WebGatewayImpl.java

@@ -484,7 +484,7 @@ public class WebGatewayImpl implements WebGateway {
     }
 
     @Override
-    public List<RoleListDTO> roleList() {
+    public List<RoleListDTO> roleList(QueryRoleParam param) {
 
         String userType = (String) StpUtil.getSession().get(UserConstants.SA_USER_TYPE);
         Long tenantId = (Long) StpUtil.getSession().get(UserConstants.SA_USER_TENANT_ID);
@@ -496,6 +496,10 @@ public class WebGatewayImpl implements WebGateway {
                 .eq(TblRole::getIsDeleted, BasePO.DeleteFlag.NOT_DELETED);
         if (tenantId != null) {
             queryWrapper.eq(TblRole::getTenantId, tenantId);
+        } else {
+            if (param.getTenantId() != null) {
+                queryWrapper.eq(TblRole::getTenantId, param.getTenantId());
+            }
         }
 
         // 2. 查询如果为空,则返回空集合