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 java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
@RequestMapping("user")
|
||||
@RestController
|
||||
|
@ -131,7 +132,7 @@ public class UserController {
|
|||
|
||||
@PostMapping("/switch/source/ws/{sourceId}")
|
||||
public UserDTO switchWorkspace(@PathVariable(value = "sourceId") String sourceId) {
|
||||
userService.switchUserResource("workspace", sourceId);
|
||||
userService.switchUserResource("workspace", sourceId, Objects.requireNonNull(SessionUtils.getUser()));
|
||||
return SessionUtils.getUser();
|
||||
}
|
||||
|
||||
|
|
|
@ -410,14 +410,14 @@ public class UserService {
|
|||
}
|
||||
}
|
||||
|
||||
public void switchUserResource(String sign, String sourceId) {
|
||||
SessionUser sessionUser = SessionUtils.getUser();
|
||||
public void switchUserResource(String sign, String sourceId, UserDTO sessionUser) {
|
||||
// 获取最新UserDTO
|
||||
UserDTO user = getUserDTO(sessionUser.getId());
|
||||
User newUser = new User();
|
||||
|
||||
if (StringUtils.equals("workspace", sign)) {
|
||||
user.setLastWorkspaceId(sourceId);
|
||||
sessionUser.setLastWorkspaceId(sourceId);
|
||||
List<Project> projects = getProjectListByWsAndUserId(sessionUser.getId(), sourceId);
|
||||
if (projects.size() > 0) {
|
||||
user.setLastProjectId(projects.get(0).getId());
|
||||
|
@ -665,7 +665,7 @@ public class UserService {
|
|||
.collect(Collectors.toList());
|
||||
if (workspaces.size() > 0) {
|
||||
String wsId = workspaces.get(0).getSourceId();
|
||||
switchUserResource("workspace", wsId);
|
||||
switchUserResource("workspace", wsId, user);
|
||||
} else {
|
||||
// 用户登录之后没有项目和工作空间的权限就把值清空
|
||||
user.setLastWorkspaceId("");
|
||||
|
|
Loading…
Reference in New Issue