refactor: 添加组织、工作空间、项目之后刷新 session user
This commit is contained in:
parent
db39402603
commit
1b31181a6c
|
@ -29,4 +29,6 @@ public interface ExtUserMapper {
|
|||
List<String> selectIdsByQuery(@Param("request") UserRequest request);
|
||||
|
||||
void updateLastProjectIdIfNull(@Param("projectId") String projectId, @Param("userId") String userId);
|
||||
|
||||
void updateLastWorkspaceIdIfNull(@Param("workspaceId") String workspaceId, @Param("userId") String userId);
|
||||
}
|
||||
|
|
|
@ -107,4 +107,9 @@
|
|||
update user set last_project_id = #{projectId} where id = #{userId}
|
||||
and (last_project_id is null or last_project_id = '')
|
||||
</update>
|
||||
|
||||
<update id="updateLastWorkspaceIdIfNull">
|
||||
update user set last_workspace_id = #{workspaceId} where id = #{userId}
|
||||
and (last_workspace_id is null or last_workspace_id = '')
|
||||
</update>
|
||||
</mapper>
|
|
@ -2,11 +2,11 @@ package io.metersphere.service;
|
|||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import io.metersphere.base.domain.*;
|
||||
import io.metersphere.base.mapper.*;
|
||||
import io.metersphere.base.mapper.ext.ExtOrganizationMapper;
|
||||
import io.metersphere.base.mapper.ext.ExtUserGroupMapper;
|
||||
import io.metersphere.base.mapper.ext.ExtUserRoleMapper;
|
||||
import io.metersphere.base.mapper.ext.ExtWorkspaceMapper;
|
||||
import io.metersphere.base.mapper.GroupMapper;
|
||||
import io.metersphere.base.mapper.ProjectMapper;
|
||||
import io.metersphere.base.mapper.UserGroupMapper;
|
||||
import io.metersphere.base.mapper.WorkspaceMapper;
|
||||
import io.metersphere.base.mapper.ext.*;
|
||||
import io.metersphere.commons.constants.UserGroupConstants;
|
||||
import io.metersphere.commons.exception.MSException;
|
||||
import io.metersphere.commons.utils.SessionUtils;
|
||||
|
@ -42,8 +42,6 @@ public class WorkspaceService {
|
|||
@Resource
|
||||
private ExtUserRoleMapper extUserRoleMapper;
|
||||
@Resource
|
||||
private UserRoleMapper userRoleMapper;
|
||||
@Resource
|
||||
private GroupMapper groupMapper;
|
||||
@Resource
|
||||
private ExtOrganizationMapper extOrganizationMapper;
|
||||
|
@ -52,11 +50,11 @@ public class WorkspaceService {
|
|||
@Resource
|
||||
private ProjectMapper projectMapper;
|
||||
@Resource
|
||||
private UserService userService;
|
||||
@Resource
|
||||
private UserGroupMapper userGroupMapper;
|
||||
@Resource
|
||||
private ExtUserGroupMapper extUserGroupMapper;
|
||||
@Resource
|
||||
private ExtUserMapper extUserMapper;
|
||||
|
||||
public Workspace saveWorkspace(Workspace workspace) {
|
||||
if (StringUtils.isBlank(workspace.getName())) {
|
||||
|
@ -85,6 +83,8 @@ public class WorkspaceService {
|
|||
userGroup.setGroupId(UserGroupConstants.WS_ADMIN);
|
||||
userGroup.setSourceId(workspace.getId());
|
||||
userGroupMapper.insert(userGroup);
|
||||
// 新项目创建新工作空间时设置
|
||||
extUserMapper.updateLastWorkspaceIdIfNull(workspace.getId(), SessionUtils.getUserId());
|
||||
} else {
|
||||
workspace.setUpdateTime(currentTime);
|
||||
workspaceMapper.updateByPrimaryKeySelective(workspace);
|
||||
|
|
|
@ -109,7 +109,7 @@ export default {
|
|||
return {
|
||||
reload: this.reload,
|
||||
reloadTopMenus: this.reloadTopMenus,
|
||||
}
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
initSessionTimer() {
|
||||
|
@ -148,17 +148,29 @@ export default {
|
|||
},
|
||||
reload() {
|
||||
// 先隐藏
|
||||
this.isShow = false
|
||||
this.isShow = false;
|
||||
this.$nextTick(() => {
|
||||
this.isShow = true
|
||||
})
|
||||
this.isShow = true;
|
||||
});
|
||||
},
|
||||
reloadTopMenus() {
|
||||
// 先隐藏
|
||||
this.isMenuShow = false
|
||||
this.$nextTick(() => {
|
||||
this.isMenuShow = true
|
||||
})
|
||||
this.$get("/isLogin").then(response => {
|
||||
if (response.data.success) {
|
||||
this.$setLang(response.data.data.language);
|
||||
saveLocalStorage(response.data);
|
||||
// 先隐藏
|
||||
this.isMenuShow = false;
|
||||
this.isShow = false;
|
||||
this.$nextTick(() => {
|
||||
this.isShow = true;
|
||||
this.isMenuShow = true;
|
||||
});
|
||||
} else {
|
||||
window.location.href = "/login";
|
||||
}
|
||||
}).catch(() => {
|
||||
window.location.href = "/login";
|
||||
});
|
||||
}
|
||||
},
|
||||
components: {
|
||||
|
|
|
@ -61,8 +61,7 @@
|
|||
</template>
|
||||
|
||||
<script>
|
||||
import {WORKSPACE_ID} from '../../../../common/js/constants';
|
||||
import {getCurrentUser, saveLocalStorage} from "../../../../common/js/utils";
|
||||
import {getCurrentUser, saveLocalStorage} from "@/common/js/utils";
|
||||
|
||||
export default {
|
||||
name: "MsHeaderOrgWs",
|
||||
|
@ -71,7 +70,7 @@ export default {
|
|||
this.getCurrentUserInfo();
|
||||
},
|
||||
inject: [
|
||||
'reloadTopMenus'
|
||||
'reloadTopMenus',
|
||||
],
|
||||
data() {
|
||||
return {
|
||||
|
|
|
@ -233,7 +233,7 @@ export default {
|
|||
}
|
||||
},
|
||||
inject: [
|
||||
'reload'
|
||||
'reloadTopMenus',
|
||||
],
|
||||
methods: {
|
||||
create() {
|
||||
|
@ -252,7 +252,7 @@ export default {
|
|||
this.dialogWsUpdateVisible = false;
|
||||
if (saveType == 'add') {
|
||||
Message.success(this.$t('commons.save_success'));
|
||||
this.reload();
|
||||
this.reloadTopMenus();
|
||||
} else if (saveType == 'update') {
|
||||
Message.success(this.$t('commons.modify_success'));
|
||||
this.list();
|
||||
|
|
|
@ -227,6 +227,9 @@ export default {
|
|||
return getCurrentOrganizationId();
|
||||
}
|
||||
},
|
||||
inject: [
|
||||
'reloadTopMenus',
|
||||
],
|
||||
data() {
|
||||
return {
|
||||
queryPath: '/organization/list',
|
||||
|
@ -384,7 +387,7 @@ export default {
|
|||
refreshSessionAndCookies(DEFAULT, sourceId);
|
||||
}
|
||||
this.$success(this.$t('commons.delete_success'));
|
||||
this.initTableData();
|
||||
this.reloadTopMenus();
|
||||
});
|
||||
}).catch(() => {
|
||||
this.$message({
|
||||
|
@ -418,7 +421,7 @@ export default {
|
|||
if (valid) {
|
||||
this.result = this.$post(this.createPath, this.form, () => {
|
||||
this.$success(this.$t('commons.save_success'));
|
||||
this.initTableData();
|
||||
this.reloadTopMenus();
|
||||
this.dialogOrgAddVisible = false;
|
||||
});
|
||||
} else {
|
||||
|
|
|
@ -242,6 +242,9 @@ export default {
|
|||
activated() {
|
||||
this.list();
|
||||
},
|
||||
inject: [
|
||||
'reloadTopMenus',
|
||||
],
|
||||
methods: {
|
||||
create() {
|
||||
this.dialogWsAddVisible = true;
|
||||
|
@ -271,7 +274,7 @@ export default {
|
|||
}
|
||||
this.result = this.$post("/workspace/" + saveType, this.form, () => {
|
||||
this.dialogWsAddVisible = false;
|
||||
this.list();
|
||||
this.reloadTopMenus();
|
||||
Message.success(this.$t('commons.save_success'));
|
||||
});
|
||||
} else {
|
||||
|
|
|
@ -299,7 +299,7 @@ export default {
|
|||
MsContainer, MsTableOperator, MsCreateBox, MsTablePagination, MsTableHeader, MsDialogFooter
|
||||
},
|
||||
inject: [
|
||||
'reload'
|
||||
'reloadTopMenus'
|
||||
],
|
||||
data() {
|
||||
return {
|
||||
|
@ -434,7 +434,7 @@ export default {
|
|||
this.createVisible = false;
|
||||
Message.success(this.$t('commons.save_success'));
|
||||
if (saveType === 'add') {
|
||||
this.reload();
|
||||
this.reloadTopMenus();
|
||||
} else {
|
||||
this.list();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue