diff --git a/framework/sdk-parent/frontend/src/api/user.js b/framework/sdk-parent/frontend/src/api/user.js index 80b05b70c6..85a39d4d3a 100644 --- a/framework/sdk-parent/frontend/src/api/user.js +++ b/framework/sdk-parent/frontend/src/api/user.js @@ -77,8 +77,8 @@ export function getUserInfo() { return get(`/user/info`); } -export function getWsAndPj(userId) { - return get(`/user/get/ws-pj/${userId}`); +export function getWsAndPj() { + return get(`/user/get/ws-pj`); } export function getUserKeys() { diff --git a/framework/sdk-parent/frontend/src/components/personal/PersonRouter.vue b/framework/sdk-parent/frontend/src/components/personal/PersonRouter.vue index 0eacf972a7..2f17c23616 100644 --- a/framework/sdk-parent/frontend/src/components/personal/PersonRouter.vue +++ b/framework/sdk-parent/frontend/src/components/personal/PersonRouter.vue @@ -196,7 +196,7 @@ export default { }) }, getWsAndPj() { - getWsAndPj(encodeURIComponent(this.currentUser().id)) + getWsAndPj() .then(response => { let data = response.data; this.workspaceList = data.workspace; diff --git a/framework/sdk-parent/sdk/src/main/java/io/metersphere/controller/BaseProjectController.java b/framework/sdk-parent/sdk/src/main/java/io/metersphere/controller/BaseProjectController.java index 62dda8db40..7d42e41742 100644 --- a/framework/sdk-parent/sdk/src/main/java/io/metersphere/controller/BaseProjectController.java +++ b/framework/sdk-parent/sdk/src/main/java/io/metersphere/controller/BaseProjectController.java @@ -5,6 +5,7 @@ import io.metersphere.base.domain.Project; import io.metersphere.commons.constants.OperLogConstants; import io.metersphere.commons.constants.OperLogModule; import io.metersphere.commons.constants.PermissionConstants; +import io.metersphere.commons.utils.SessionUtils; import io.metersphere.dto.ProjectDTO; import io.metersphere.log.annotation.MsAuditLog; import io.metersphere.request.ProjectRequest; @@ -30,6 +31,8 @@ public class BaseProjectController { */ @PostMapping("/list/related") public List getUserProject(@RequestBody ProjectRequest request) { + // 仅支持查询当前用户的项目 + request.setUserId(SessionUtils.getUserId()); return baseProjectService.getUserProject(request); } diff --git a/framework/sdk-parent/sdk/src/main/java/io/metersphere/controller/BaseUserController.java b/framework/sdk-parent/sdk/src/main/java/io/metersphere/controller/BaseUserController.java index 804b202164..2d4f5eb600 100644 --- a/framework/sdk-parent/sdk/src/main/java/io/metersphere/controller/BaseUserController.java +++ b/framework/sdk-parent/sdk/src/main/java/io/metersphere/controller/BaseUserController.java @@ -110,9 +110,9 @@ public class BaseUserController { /** * 根据userId 获取 user 所属工作空间和所属工作项目 */ - @GetMapping("/get/ws-pj/{userId}") - public Map getWSAndProjectByUserId(@PathVariable String userId) { - return baseUserService.getWSAndProjectByUserId(userId); + @GetMapping("/get/ws-pj") + public Map getWSAndProjectByUserId() { + return baseUserService.getWSAndProjectByUserId(SessionUtils.getUserId()); }