fix: 修复工作空间权限第一次登录之后不能显示菜单的问题
This commit is contained in:
parent
136276f6da
commit
f488d8d977
|
@ -30,6 +30,7 @@ import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
@RequestMapping("user")
|
@RequestMapping("user")
|
||||||
@RestController
|
@RestController
|
||||||
|
@ -131,7 +132,7 @@ public class UserController {
|
||||||
|
|
||||||
@PostMapping("/switch/source/ws/{sourceId}")
|
@PostMapping("/switch/source/ws/{sourceId}")
|
||||||
public UserDTO switchWorkspace(@PathVariable(value = "sourceId") String sourceId) {
|
public UserDTO switchWorkspace(@PathVariable(value = "sourceId") String sourceId) {
|
||||||
userService.switchUserResource("workspace", sourceId);
|
userService.switchUserResource("workspace", sourceId, Objects.requireNonNull(SessionUtils.getUser()));
|
||||||
return SessionUtils.getUser();
|
return SessionUtils.getUser();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -410,14 +410,14 @@ public class UserService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void switchUserResource(String sign, String sourceId) {
|
public void switchUserResource(String sign, String sourceId, UserDTO sessionUser) {
|
||||||
SessionUser sessionUser = SessionUtils.getUser();
|
|
||||||
// 获取最新UserDTO
|
// 获取最新UserDTO
|
||||||
UserDTO user = getUserDTO(sessionUser.getId());
|
UserDTO user = getUserDTO(sessionUser.getId());
|
||||||
User newUser = new User();
|
User newUser = new User();
|
||||||
|
|
||||||
if (StringUtils.equals("workspace", sign)) {
|
if (StringUtils.equals("workspace", sign)) {
|
||||||
user.setLastWorkspaceId(sourceId);
|
user.setLastWorkspaceId(sourceId);
|
||||||
|
sessionUser.setLastWorkspaceId(sourceId);
|
||||||
List<Project> projects = getProjectListByWsAndUserId(sessionUser.getId(), sourceId);
|
List<Project> projects = getProjectListByWsAndUserId(sessionUser.getId(), sourceId);
|
||||||
if (projects.size() > 0) {
|
if (projects.size() > 0) {
|
||||||
user.setLastProjectId(projects.get(0).getId());
|
user.setLastProjectId(projects.get(0).getId());
|
||||||
|
@ -665,7 +665,7 @@ public class UserService {
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
if (workspaces.size() > 0) {
|
if (workspaces.size() > 0) {
|
||||||
String wsId = workspaces.get(0).getSourceId();
|
String wsId = workspaces.get(0).getSourceId();
|
||||||
switchUserResource("workspace", wsId);
|
switchUserResource("workspace", wsId, user);
|
||||||
} else {
|
} else {
|
||||||
// 用户登录之后没有项目和工作空间的权限就把值清空
|
// 用户登录之后没有项目和工作空间的权限就把值清空
|
||||||
user.setLastWorkspaceId("");
|
user.setLastWorkspaceId("");
|
||||||
|
|
Loading…
Reference in New Issue