fix(系统设置): 组织不存在项目时或项目被禁用涉及的路由跳转问题
--bug=1039530 --user=宋昌昌 【系统设置】项目-模版-新创建组织没有项目的情况下提示已开启项目模版,建议优化 https://www.tapd.cn/55049933/s/1505085
This commit is contained in:
parent
5bde86d4d9
commit
d9943bbf14
|
@ -113,10 +113,12 @@ public class BugAttachmentService {
|
||||||
Map<String, FileMetadata> fileMetadataMap = getLinkFileMetaMap(associateFileIds);
|
Map<String, FileMetadata> fileMetadataMap = getLinkFileMetaMap(associateFileIds);
|
||||||
fileAssociations.forEach(associatedFile -> {
|
fileAssociations.forEach(associatedFile -> {
|
||||||
FileMetadata associatedFileMetadata = fileMetadataMap.get(associatedFile.getFileId());
|
FileMetadata associatedFileMetadata = fileMetadataMap.get(associatedFile.getFileId());
|
||||||
|
if (associatedFileMetadata != null) {
|
||||||
BugFileDTO associatedFileDTO = BugFileDTO.builder().refId(associatedFile.getId()).fileId(associatedFile.getFileId()).fileName(associatedFileMetadata.getName() + "." + associatedFileMetadata.getType())
|
BugFileDTO associatedFileDTO = BugFileDTO.builder().refId(associatedFile.getId()).fileId(associatedFile.getFileId()).fileName(associatedFileMetadata.getName() + "." + associatedFileMetadata.getType())
|
||||||
.fileType(associatedFileMetadata.getType()).fileSize(associatedFileMetadata.getSize()).createTime(associatedFileMetadata.getCreateTime())
|
.fileType(associatedFileMetadata.getType()).fileSize(associatedFileMetadata.getSize()).createTime(associatedFileMetadata.getCreateTime())
|
||||||
.createUser(associatedFileMetadata.getCreateUser()).local(false).build();
|
.createUser(associatedFileMetadata.getCreateUser()).local(false).build();
|
||||||
bugFiles.add(associatedFileDTO);
|
bugFiles.add(associatedFileDTO);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (CollectionUtils.isEmpty(bugFiles)) {
|
if (CollectionUtils.isEmpty(bugFiles)) {
|
||||||
|
|
|
@ -1,20 +1,22 @@
|
||||||
package io.metersphere.system.controller;
|
package io.metersphere.system.controller;
|
||||||
|
|
||||||
|
|
||||||
|
import io.metersphere.project.domain.Project;
|
||||||
|
import io.metersphere.project.mapper.ProjectMapper;
|
||||||
import io.metersphere.sdk.constants.HttpMethodConstants;
|
import io.metersphere.sdk.constants.HttpMethodConstants;
|
||||||
import io.metersphere.sdk.constants.UserSource;
|
import io.metersphere.sdk.constants.UserSource;
|
||||||
|
import io.metersphere.sdk.exception.MSException;
|
||||||
|
import io.metersphere.sdk.util.RsaKey;
|
||||||
|
import io.metersphere.sdk.util.RsaUtils;
|
||||||
|
import io.metersphere.sdk.util.Translator;
|
||||||
import io.metersphere.system.controller.handler.ResultHolder;
|
import io.metersphere.system.controller.handler.ResultHolder;
|
||||||
import io.metersphere.system.controller.handler.result.MsHttpResultCode;
|
import io.metersphere.system.controller.handler.result.MsHttpResultCode;
|
||||||
import io.metersphere.system.dto.sdk.LoginRequest;
|
import io.metersphere.system.dto.sdk.LoginRequest;
|
||||||
import io.metersphere.system.dto.sdk.SessionUser;
|
import io.metersphere.system.dto.sdk.SessionUser;
|
||||||
import io.metersphere.system.dto.user.UserDTO;
|
import io.metersphere.system.dto.user.UserDTO;
|
||||||
import io.metersphere.sdk.exception.MSException;
|
|
||||||
import io.metersphere.system.log.constants.OperationLogType;
|
import io.metersphere.system.log.constants.OperationLogType;
|
||||||
import io.metersphere.system.service.UserLoginService;
|
import io.metersphere.system.service.UserLoginService;
|
||||||
import io.metersphere.sdk.util.RsaKey;
|
|
||||||
import io.metersphere.sdk.util.RsaUtils;
|
|
||||||
import io.metersphere.system.utils.SessionUtils;
|
import io.metersphere.system.utils.SessionUtils;
|
||||||
import io.metersphere.sdk.util.Translator;
|
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
|
@ -34,6 +36,8 @@ public class LoginController {
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private UserLoginService userLoginService;
|
private UserLoginService userLoginService;
|
||||||
|
@Resource
|
||||||
|
private ProjectMapper projectMapper;
|
||||||
|
|
||||||
|
|
||||||
@GetMapping(value = "/is-login")
|
@GetMapping(value = "/is-login")
|
||||||
|
@ -49,8 +53,9 @@ public class LoginController {
|
||||||
userLoginService.autoSwitch(userDTO);
|
userLoginService.autoSwitch(userDTO);
|
||||||
SessionUser sessionUser = SessionUser.fromUser(userDTO, SessionUtils.getSessionId());
|
SessionUser sessionUser = SessionUser.fromUser(userDTO, SessionUtils.getSessionId());
|
||||||
SessionUtils.putUser(sessionUser);
|
SessionUtils.putUser(sessionUser);
|
||||||
// 用户只有工作空间权限
|
// 用户只有工作空间权限, 或者项目已被禁用
|
||||||
if (StringUtils.isBlank(sessionUser.getLastProjectId())) {
|
Project lastProject = projectMapper.selectByPrimaryKey(sessionUser.getLastProjectId());
|
||||||
|
if (StringUtils.isBlank(sessionUser.getLastProjectId()) || lastProject == null || !lastProject.getEnable()) {
|
||||||
sessionUser.setLastProjectId("no_such_project");
|
sessionUser.setLastProjectId("no_such_project");
|
||||||
}
|
}
|
||||||
return ResultHolder.success(sessionUser);
|
return ResultHolder.success(sessionUser);
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
import { getOrgOptions, switchUserOrg } from '@/api/modules/system';
|
import { getOrgOptions, switchUserOrg } from '@/api/modules/system';
|
||||||
import { useI18n } from '@/hooks/useI18n';
|
import { useI18n } from '@/hooks/useI18n';
|
||||||
import useUser from '@/hooks/useUser';
|
import useUser from '@/hooks/useUser';
|
||||||
import { BOTTOM_MENU_LIST } from '@/router/constants';
|
import { BOTTOM_MENU_LIST, NO_PROJECT_ROUTE_NAME } from '@/router/constants';
|
||||||
import { useAppStore, useUserStore } from '@/store';
|
import { useAppStore, useUserStore } from '@/store';
|
||||||
import useLicenseStore from '@/store/modules/setting/license';
|
import useLicenseStore from '@/store/modules/setting/license';
|
||||||
import { openWindow, regexUrl } from '@/utils';
|
import { openWindow, regexUrl } from '@/utils';
|
||||||
|
@ -20,7 +20,7 @@
|
||||||
import { getFisrtRouterNameByCurrentRoute } from '@/utils/permission';
|
import { getFisrtRouterNameByCurrentRoute } from '@/utils/permission';
|
||||||
import { listenerRouteChange } from '@/utils/route-listener';
|
import { listenerRouteChange } from '@/utils/route-listener';
|
||||||
|
|
||||||
import { SettingRouteEnum } from '@/enums/routeEnum';
|
import { ProjectManagementRouteEnum, SettingRouteEnum } from '@/enums/routeEnum';
|
||||||
|
|
||||||
import useMenuTree from './use-menu-tree';
|
import useMenuTree from './use-menu-tree';
|
||||||
import type { RouteMeta } from 'vue-router';
|
import type { RouteMeta } from 'vue-router';
|
||||||
|
@ -148,6 +148,25 @@
|
||||||
personalMenusVisible.value = false;
|
personalMenusVisible.value = false;
|
||||||
orgKeyword.value = '';
|
orgKeyword.value = '';
|
||||||
await userStore.isLogin(true);
|
await userStore.isLogin(true);
|
||||||
|
if (!appStore.currentProjectId || appStore.currentProjectId === 'no_such_project') {
|
||||||
|
// 没有项目权限(组织没有项目, 或项目全被禁用)
|
||||||
|
router.push({
|
||||||
|
name: NO_PROJECT_ROUTE_NAME,
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (route.name === NO_PROJECT_ROUTE_NAME) {
|
||||||
|
// 无项目权限组织切换到正常组织, 默认跳转到项目基本信息页面
|
||||||
|
router.replace({
|
||||||
|
name: ProjectManagementRouteEnum.PROJECT_MANAGEMENT_PERMISSION_BASIC_INFO,
|
||||||
|
query: {
|
||||||
|
...route.query,
|
||||||
|
orgId: appStore.currentOrgId,
|
||||||
|
pId: appStore.currentProjectId,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
// 正常切换组织
|
||||||
router.replace({
|
router.replace({
|
||||||
path: route.path,
|
path: route.path,
|
||||||
query: {
|
query: {
|
||||||
|
@ -156,6 +175,7 @@
|
||||||
pId: appStore.currentProjectId,
|
pId: appStore.currentProjectId,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
// eslint-disable-next-line no-console
|
// eslint-disable-next-line no-console
|
||||||
console.log(error);
|
console.log(error);
|
||||||
|
|
|
@ -16,6 +16,7 @@ export default function usePermission() {
|
||||||
* @returns 是否
|
* @returns 是否
|
||||||
*/
|
*/
|
||||||
accessRouter(route: RouteLocationNormalized | RouteRecordRaw) {
|
accessRouter(route: RouteLocationNormalized | RouteRecordRaw) {
|
||||||
|
console.log(useUserStore());
|
||||||
if (
|
if (
|
||||||
(useUserStore().lastProjectId === 'no_such_project' || useUserStore().lastProjectId === '') &&
|
(useUserStore().lastProjectId === 'no_such_project' || useUserStore().lastProjectId === '') &&
|
||||||
route.name === 'projectManagement'
|
route.name === 'projectManagement'
|
||||||
|
|
|
@ -36,7 +36,11 @@ const useTemplateStore = defineStore('template', {
|
||||||
if (currentOrgId.value && hasAnyPermission(['ORGANIZATION_TEMPLATE:READ'])) {
|
if (currentOrgId.value && hasAnyPermission(['ORGANIZATION_TEMPLATE:READ'])) {
|
||||||
this.ordStatus = await getOrdTemplate(currentOrgId.value);
|
this.ordStatus = await getOrdTemplate(currentOrgId.value);
|
||||||
}
|
}
|
||||||
if (currentProjectId.value && hasAnyPermission(['PROJECT_TEMPLATE:READ'])) {
|
if (
|
||||||
|
currentProjectId.value &&
|
||||||
|
hasAnyPermission(['PROJECT_TEMPLATE:READ']) &&
|
||||||
|
currentProjectId.value !== 'no_such_project'
|
||||||
|
) {
|
||||||
this.projectStatus = await getProTemplate(currentProjectId.value);
|
this.projectStatus = await getProTemplate(currentProjectId.value);
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|
Loading…
Reference in New Issue