切换工工作空间修改

This commit is contained in:
Captain.B 2020-02-20 11:14:54 +08:00
parent 8c546b7afa
commit 7816dc56b9
2 changed files with 9 additions and 5 deletions

View File

@ -13,6 +13,8 @@ import io.metersphere.controller.request.member.QueryMemberRequest;
import io.metersphere.dto.UserDTO;
import io.metersphere.dto.UserRoleDTO;
import io.metersphere.dto.UserRoleHelpDTO;
import io.metersphere.user.SessionUser;
import io.metersphere.user.SessionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
@ -219,8 +221,10 @@ public class UserService {
public void switchUserRole(UserDTO user, String sourceId) {
User newUser = new User();
user.setLastSourceId(sourceId);
BeanUtils.copyProperties(user, newUser);
newUser.setLastSourceId(sourceId);
// 切换工作空间或组织之后更新 session 里的 user
SessionUtils.putUser(SessionUser.fromUser(user));
userMapper.updateByPrimaryKeySelective(newUser);
}

View File

@ -81,10 +81,10 @@
data() {
return {
organizationList: [
{ index: '7-1', name: '组织1'},
{index: '7-1', name: '组织1'},
],
workspaceList: [
{ index: '2-1', name: '无工作空间'},
{index: '2-1', name: '无工作空间'},
],
currentUserInfo: {},
currentUserId: JSON.parse(Cookies.get(TokenKey)).id,
@ -93,7 +93,7 @@
},
methods: {
initMenuData() {
this.$get("/organization/list/userorg/" + this.currentUserId,response => {
this.$get("/organization/list/userorg/" + this.currentUserId, response => {
this.organizationList = response.data;
})
this.$get("/workspace/list/userworkspace/" + this.currentUserId, response => {
@ -114,7 +114,7 @@
let user = {};
user.id = this.currentUserInfo.id;
user.lastSourceId = data.id;
this.$post("/user/update", user);
this.$post("/user/switch/source/" + user.lastSourceId, {});
window.location.reload();
}
}