From 558ffc4bcaf7aa5c683e7c9ce01e971feb9e4d95 Mon Sep 17 00:00:00 2001 From: dengzedong <dengzedong@email> Date: 星期一, 14 十月 2024 14:11:48 +0800 Subject: [PATCH] 模型打包租户隔离 备份文件租户隔离 --- iailab-module-system/iailab-module-system-biz/src/main/java/com/iailab/module/system/controller/admin/auth/AuthController.java | 38 ++++++++++++++++++++++++++++++++++++-- 1 files changed, 36 insertions(+), 2 deletions(-) diff --git a/iailab-module-system/iailab-module-system-biz/src/main/java/com/iailab/module/system/controller/admin/auth/AuthController.java b/iailab-module-system/iailab-module-system-biz/src/main/java/com/iailab/module/system/controller/admin/auth/AuthController.java index 52fb0bd..1637ed5 100644 --- a/iailab-module-system/iailab-module-system-biz/src/main/java/com/iailab/module/system/controller/admin/auth/AuthController.java +++ b/iailab-module-system/iailab-module-system-biz/src/main/java/com/iailab/module/system/controller/admin/auth/AuthController.java @@ -8,11 +8,14 @@ import com.iailab.framework.security.config.SecurityProperties; import com.iailab.framework.security.core.util.SecurityFrameworkUtils; import com.iailab.module.system.controller.admin.auth.vo.*; +import com.iailab.module.system.controller.admin.permission.vo.menu.MenuListReqVO; import com.iailab.module.system.convert.auth.AuthConvert; +import com.iailab.module.system.dal.dataobject.app.AppDO; import com.iailab.module.system.dal.dataobject.permission.MenuDO; import com.iailab.module.system.dal.dataobject.permission.RoleDO; import com.iailab.module.system.dal.dataobject.user.AdminUserDO; import com.iailab.module.system.enums.logger.LoginLogTypeEnum; +import com.iailab.module.system.service.app.AppService; import com.iailab.module.system.service.auth.AdminAuthService; import com.iailab.module.system.service.permission.MenuService; import com.iailab.module.system.service.permission.PermissionService; @@ -38,6 +41,8 @@ import static com.iailab.framework.common.pojo.CommonResult.success; import static com.iailab.framework.common.util.collection.CollectionUtils.convertSet; import static com.iailab.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; +import static com.iailab.framework.tenant.core.context.TenantContextHolder.getTenantId; + @Tag(name = "管理后台 - 认证") @RestController @@ -58,9 +63,10 @@ private PermissionService permissionService; @Resource private SocialClientService socialClientService; - @Resource private SecurityProperties securityProperties; + @Resource + private AppService appService; @PostMapping("/login") @PermitAll @@ -109,12 +115,40 @@ // 1.3 获得菜单列表 Set<Long> menuIds = permissionService.getRoleMenuListByRoleId(convertSet(roles, RoleDO::getId)); List<MenuDO> menuList = menuService.getMenuList(menuIds); - menuList.removeIf(menu -> !CommonStatusEnum.ENABLE.getStatus().equals(menu.getStatus())); // 移除禁用的菜单 + menuList = menuService.filterDisableMenus(menuList); // 2. 拼接结果返回 return success(AuthConvert.INSTANCE.convert(user, roles, menuList)); } + @GetMapping("/get-app-permission-info") + @Operation(summary = "获取登录用户的app权限信息") + public CommonResult<AuthPermissionInfoRespVO> getAppPermissionInfo() { + // 1.1 获得用户信息 + AdminUserDO user = userService.getUser(getLoginUserId()); + if (user == null) { + return success(null); + } + + // 1.2 获得角色列表 + Set<Long> roleIds = permissionService.getUserRoleIdListByUserId(getLoginUserId()); + if (CollUtil.isEmpty(roleIds)) { + return success(AuthConvert.INSTANCE.convert(user, Collections.emptyList(), Collections.emptyList())); + } + List<RoleDO> roles = roleService.getRoleList(roleIds); + roles.removeIf(role -> !CommonStatusEnum.ENABLE.getStatus().equals(role.getStatus())); // 移除禁用的角色 + + // 1.3 获得应用菜单列表 + MenuListReqVO reqVO = new MenuListReqVO(); + List<MenuDO> appMenuList = menuService.getAppMenuList(reqVO); + Set<Long> menuIds = permissionService.getRoleMenuListByRoleId(convertSet(roles, RoleDO::getId)); + List<MenuDO> menuList = menuService.getMenuList(menuIds); + menuList.retainAll(appMenuList); + menuList = menuService.filterDisableMenus(menuList); + // 2. 拼接结果返回 + return success(AuthConvert.INSTANCE.convertAppMenu(user, roles, menuList)); + } + // ========== 短信登录相关 ========== @PostMapping("/sms-login") -- Gitblit v1.9.3