切换工工作空间修改

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

View File

@ -114,7 +114,7 @@
let user = {}; let user = {};
user.id = this.currentUserInfo.id; user.id = this.currentUserInfo.id;
user.lastSourceId = data.id; user.lastSourceId = data.id;
this.$post("/user/update", user); this.$post("/user/switch/source/" + user.lastSourceId, {});
window.location.reload(); window.location.reload();
} }
} }