Commit 54a328bade4ab075af0a497f37a85c600abedec6
1 parent
fb5fc720
feat(app-module): 添加角色权限控制功能模块显示逻辑
Showing
1 changed file
with
29 additions
and
0 deletions
urbanops-module-system/src/main/java/com/zteits/urbanops/module/system/controller/app/appmodule/AppAppModuleController.java
| @@ -7,9 +7,11 @@ import com.zteits.urbanops.module.system.controller.app.appmodule.vo.AppModuleVO | @@ -7,9 +7,11 @@ import com.zteits.urbanops.module.system.controller.app.appmodule.vo.AppModuleVO | ||
| 7 | import com.zteits.urbanops.module.system.convert.appmodule.AppModuleConvert; | 7 | import com.zteits.urbanops.module.system.convert.appmodule.AppModuleConvert; |
| 8 | import com.zteits.urbanops.module.system.dal.dataobject.appmodule.AppModuleDO; | 8 | import com.zteits.urbanops.module.system.dal.dataobject.appmodule.AppModuleDO; |
| 9 | import com.zteits.urbanops.module.system.service.appmodule.AppModuleService; | 9 | import com.zteits.urbanops.module.system.service.appmodule.AppModuleService; |
| 10 | +import com.zteits.urbanops.module.system.service.permission.PermissionService; | ||
| 10 | import io.swagger.v3.oas.annotations.Operation; | 11 | import io.swagger.v3.oas.annotations.Operation; |
| 11 | import io.swagger.v3.oas.annotations.tags.Tag; | 12 | import io.swagger.v3.oas.annotations.tags.Tag; |
| 12 | import jakarta.annotation.Resource; | 13 | import jakarta.annotation.Resource; |
| 14 | +import lombok.extern.slf4j.Slf4j; | ||
| 13 | import org.springframework.validation.annotation.Validated; | 15 | import org.springframework.validation.annotation.Validated; |
| 14 | import org.springframework.web.bind.annotation.GetMapping; | 16 | import org.springframework.web.bind.annotation.GetMapping; |
| 15 | import org.springframework.web.bind.annotation.RequestMapping; | 17 | import org.springframework.web.bind.annotation.RequestMapping; |
| @@ -21,6 +23,7 @@ import java.util.Comparator; | @@ -21,6 +23,7 @@ import java.util.Comparator; | ||
| 21 | import java.util.LinkedHashMap; | 23 | import java.util.LinkedHashMap; |
| 22 | import java.util.List; | 24 | import java.util.List; |
| 23 | import java.util.Map; | 25 | import java.util.Map; |
| 26 | +import java.util.Set; | ||
| 24 | 27 | ||
| 25 | import static com.zteits.urbanops.framework.common.pojo.CommonResult.success; | 28 | import static com.zteits.urbanops.framework.common.pojo.CommonResult.success; |
| 26 | 29 | ||
| @@ -34,11 +37,28 @@ import static com.zteits.urbanops.framework.common.pojo.CommonResult.success; | @@ -34,11 +37,28 @@ import static com.zteits.urbanops.framework.common.pojo.CommonResult.success; | ||
| 34 | @RestController | 37 | @RestController |
| 35 | @RequestMapping("/member/app-module") | 38 | @RequestMapping("/member/app-module") |
| 36 | @Validated | 39 | @Validated |
| 40 | +@Slf4j | ||
| 37 | public class AppAppModuleController { | 41 | public class AppAppModuleController { |
| 38 | 42 | ||
| 43 | + /** | ||
| 44 | + * 园林巡查员角色ID | ||
| 45 | + */ | ||
| 46 | + private static final Long ROLE_ID_PATROL = 178L; | ||
| 47 | + /** | ||
| 48 | + * 全域督察员角色ID | ||
| 49 | + */ | ||
| 50 | + private static final Long ROLE_ID_INSPECTOR = 183L; | ||
| 51 | + /** | ||
| 52 | + * 巡查工单模块ID | ||
| 53 | + */ | ||
| 54 | + private static final Long MODULE_ID_PATROL_WORKORDER = 7L; | ||
| 55 | + | ||
| 39 | @Resource | 56 | @Resource |
| 40 | private AppModuleService appModuleService; | 57 | private AppModuleService appModuleService; |
| 41 | 58 | ||
| 59 | + @Resource | ||
| 60 | + private PermissionService permissionService; | ||
| 61 | + | ||
| 42 | @GetMapping("/list") | 62 | @GetMapping("/list") |
| 43 | @Operation(summary = "获取 App 功能模块列表", description = "获取用户可见的功能模块列表") | 63 | @Operation(summary = "获取 App 功能模块列表", description = "获取用户可见的功能模块列表") |
| 44 | public CommonResult<List<AppModuleVO>> getAppModuleList(AppModuleListReqVO reqVO) { | 64 | public CommonResult<List<AppModuleVO>> getAppModuleList(AppModuleListReqVO reqVO) { |
| @@ -48,6 +68,15 @@ public class AppAppModuleController { | @@ -48,6 +68,15 @@ public class AppAppModuleController { | ||
| 48 | // 查询用户可见的模块列表 | 68 | // 查询用户可见的模块列表 |
| 49 | List<AppModuleDO> list = appModuleService.getVisibleAppModuleList(userId, reqVO); | 69 | List<AppModuleDO> list = appModuleService.getVisibleAppModuleList(userId, reqVO); |
| 50 | 70 | ||
| 71 | + // 如果用户同时拥有园林巡查员(178)和全域督察员(183)角色,则隐藏巡查工单菜单,只显示督查工单菜单 | ||
| 72 | + if (userId != null) { | ||
| 73 | + Set<Long> roleIds = permissionService.getUserRoleIdListByUserId(userId); | ||
| 74 | + if (roleIds.contains(ROLE_ID_PATROL) && roleIds.contains(ROLE_ID_INSPECTOR)) { | ||
| 75 | + log.info("[getAppModuleList] 用户({})同时拥有巡查员和督察员角色,隐藏巡查工单菜单", userId); | ||
| 76 | + list.removeIf(module -> MODULE_ID_PATROL_WORKORDER.equals(module.getId())); | ||
| 77 | + } | ||
| 78 | + } | ||
| 79 | + | ||
| 51 | // 填充统计数据(根据extra中的statisticKey配置) | 80 | // 填充统计数据(根据extra中的statisticKey配置) |
| 52 | // appModuleService.fillModuleStatistics(list, userId); | 81 | // appModuleService.fillModuleStatistics(list, userId); |
| 53 | 82 |