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 | 7 | import com.zteits.urbanops.module.system.convert.appmodule.AppModuleConvert; |
| 8 | 8 | import com.zteits.urbanops.module.system.dal.dataobject.appmodule.AppModuleDO; |
| 9 | 9 | import com.zteits.urbanops.module.system.service.appmodule.AppModuleService; |
| 10 | +import com.zteits.urbanops.module.system.service.permission.PermissionService; | |
| 10 | 11 | import io.swagger.v3.oas.annotations.Operation; |
| 11 | 12 | import io.swagger.v3.oas.annotations.tags.Tag; |
| 12 | 13 | import jakarta.annotation.Resource; |
| 14 | +import lombok.extern.slf4j.Slf4j; | |
| 13 | 15 | import org.springframework.validation.annotation.Validated; |
| 14 | 16 | import org.springframework.web.bind.annotation.GetMapping; |
| 15 | 17 | import org.springframework.web.bind.annotation.RequestMapping; |
| ... | ... | @@ -21,6 +23,7 @@ import java.util.Comparator; |
| 21 | 23 | import java.util.LinkedHashMap; |
| 22 | 24 | import java.util.List; |
| 23 | 25 | import java.util.Map; |
| 26 | +import java.util.Set; | |
| 24 | 27 | |
| 25 | 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 | 37 | @RestController |
| 35 | 38 | @RequestMapping("/member/app-module") |
| 36 | 39 | @Validated |
| 40 | +@Slf4j | |
| 37 | 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 | 56 | @Resource |
| 40 | 57 | private AppModuleService appModuleService; |
| 41 | 58 | |
| 59 | + @Resource | |
| 60 | + private PermissionService permissionService; | |
| 61 | + | |
| 42 | 62 | @GetMapping("/list") |
| 43 | 63 | @Operation(summary = "获取 App 功能模块列表", description = "获取用户可见的功能模块列表") |
| 44 | 64 | public CommonResult<List<AppModuleVO>> getAppModuleList(AppModuleListReqVO reqVO) { |
| ... | ... | @@ -48,6 +68,15 @@ public class AppAppModuleController { |
| 48 | 68 | // 查询用户可见的模块列表 |
| 49 | 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 | 80 | // 填充统计数据(根据extra中的statisticKey配置) |
| 52 | 81 | // appModuleService.fillModuleStatistics(list, userId); |
| 53 | 82 | ... | ... |