refactor: 场景项目接口优化

This commit is contained in:
chenjianxing 2021-06-23 19:43:18 +08:00 committed by jianxing
parent 6b83069a3d
commit 236fbe5371
3 changed files with 11 additions and 7 deletions

View File

@ -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;
}

View File

@ -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();

View File

@ -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'));