切换组织时自动选取工作空间
This commit is contained in:
parent
ba7e9288af
commit
d96578f305
|
@ -22,6 +22,7 @@ import io.metersphere.i18n.Translator;
|
|||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.shiro.authc.DisabledAccountException;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
@ -48,6 +49,9 @@ public class UserService {
|
|||
private WorkspaceMapper workspaceMapper;
|
||||
@Resource
|
||||
private ExtUserMapper extUserMapper;
|
||||
@Lazy
|
||||
@Resource
|
||||
private WorkspaceService workspaceService;
|
||||
|
||||
public UserDTO insert(UserRequest user) {
|
||||
checkUserParam(user);
|
||||
|
@ -250,11 +254,16 @@ public class UserService {
|
|||
SessionUser sessionUser = SessionUtils.getUser();
|
||||
// 获取最新UserDTO
|
||||
UserDTO user = getUserDTO(sessionUser.getId());
|
||||
|
||||
User newUser = new User();
|
||||
|
||||
if (StringUtils.equals("organization", sign)) {
|
||||
user.setLastOrganizationId(sourceId);
|
||||
user.setLastWorkspaceId("");
|
||||
List<Workspace> workspaces = workspaceService.getWorkspaceListByOrgIdAndUserId(sourceId);
|
||||
if (workspaces.size() > 0) {
|
||||
user.setLastWorkspaceId(workspaces.get(0).getId());
|
||||
} else {
|
||||
user.setLastWorkspaceId("");
|
||||
}
|
||||
}
|
||||
if (StringUtils.equals("workspace", sign)) {
|
||||
Workspace workspace = workspaceMapper.selectByPrimaryKey(sourceId);
|
||||
|
|
|
@ -104,6 +104,9 @@
|
|||
}
|
||||
this.$post("/user/switch/source/org/" + orgId, {}, response => {
|
||||
saveLocalStorage(response);
|
||||
if (response.data.workspaceId) {
|
||||
localStorage.setItem("workspace_id", response.data.workspaceId);
|
||||
}
|
||||
this.$router.push('/');
|
||||
window.location.reload();
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue