diff --git a/backend/src/main/java/io/metersphere/service/ProjectService.java b/backend/src/main/java/io/metersphere/service/ProjectService.java index 3848c275c2..777790a5fb 100644 --- a/backend/src/main/java/io/metersphere/service/ProjectService.java +++ b/backend/src/main/java/io/metersphere/service/ProjectService.java @@ -91,7 +91,7 @@ public class ProjectService { } ProjectExample example = new ProjectExample(); example.createCriteria() - .andWorkspaceIdEqualTo(SessionUtils.getCurrentWorkspaceId()) + .andWorkspaceIdEqualTo(project.getWorkspaceId()) .andNameEqualTo(project.getName()); if (projectMapper.countByExample(example) > 0) { MSException.throwException(Translator.get("project_name_already_exists")); @@ -106,15 +106,15 @@ public class ProjectService { project.setCreateTime(createTime); project.setUpdateTime(createTime); // set workspace id - project.setWorkspaceId(SessionUtils.getCurrentWorkspaceId()); - project.setCreateUser(SessionUtils.getUserId()); + project.setWorkspaceId(project.getWorkspaceId()); + project.setCreateUser(project.getCreateUser()); project.setSystemId(systemId); projectMapper.insertSelective(project); // 创建项目为当前用户添加用户组 UserGroup userGroup = new UserGroup(); userGroup.setId(UUID.randomUUID().toString()); - userGroup.setUserId(SessionUtils.getUserId()); + userGroup.setUserId(project.getCreateUser()); userGroup.setCreateTime(System.currentTimeMillis()); userGroup.setUpdateTime(System.currentTimeMillis()); userGroup.setGroupId(UserGroupConstants.PROJECT_ADMIN); @@ -122,7 +122,7 @@ public class ProjectService { userGroupMapper.insert(userGroup); // 创建新项目检查当前用户 last_project_id - extUserMapper.updateLastProjectIdIfNull(project.getId(), SessionUtils.getUserId()); + extUserMapper.updateLastProjectIdIfNull(project.getId(), project.getCreateUser()); return project; } diff --git a/frontend/src/business/components/settings/project/ProjectList.vue b/frontend/src/business/components/settings/project/ProjectList.vue index 1dcf8c618b..c51dacc796 100644 --- a/frontend/src/business/components/settings/project/ProjectList.vue +++ b/frontend/src/business/components/settings/project/ProjectList.vue @@ -147,7 +147,7 @@ import MsTableOperator from "../../common/components/MsTableOperator"; import MsDialogFooter from "../../common/components/MsDialogFooter"; import { getCurrentProjectID, - getCurrentUser, + getCurrentUser, getCurrentUserId, getCurrentWorkspaceId, listenGoBack, removeGoBackListener @@ -295,6 +295,8 @@ export default { var protocol = document.location.protocol; protocol = protocol.substring(0, protocol.indexOf(":")); this.form.protocal = protocol; + this.form.workspaceId = getCurrentWorkspaceId(); + this.form.createUser = getCurrentUserId(); this.result = this.$post("/project/" + saveType, this.form, () => { this.createVisible = false; this.list(); diff --git a/frontend/src/business/components/settings/workspace/MsProject.vue b/frontend/src/business/components/settings/workspace/MsProject.vue index d7220c3926..d830173896 100644 --- a/frontend/src/business/components/settings/workspace/MsProject.vue +++ b/frontend/src/business/components/settings/workspace/MsProject.vue @@ -221,7 +221,7 @@ import MsDialogFooter from "../../common/components/MsDialogFooter"; import { getCurrentOrganizationId, getCurrentProjectID, - getCurrentUser, + getCurrentUser, getCurrentUserId, getCurrentWorkspaceId, listenGoBack, removeGoBackListener @@ -392,6 +392,8 @@ export default { var protocol = document.location.protocol; protocol = protocol.substring(0, protocol.indexOf(":")); this.form.protocal = protocol; + this.form.workspaceId = getCurrentWorkspaceId(); + this.form.createUser = getCurrentUserId(); this.result = this.$post("/project/" + saveType, this.form, () => { this.createVisible = false; Message.success(this.$t('commons.save_success'));