From 366ee0a820ad11f1083ef2656ff06e4bb3ed311a Mon Sep 17 00:00:00 2001 From: CaptainB Date: Thu, 27 Jul 2023 13:53:37 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E6=9D=83=E9=99=90?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- framework/sdk-parent/frontend/src/api/user.js | 4 ++-- .../frontend/src/components/personal/PersonRouter.vue | 2 +- .../io/metersphere/controller/BaseProjectController.java | 3 +++ .../java/io/metersphere/controller/BaseUserController.java | 6 +++--- 4 files changed, 9 insertions(+), 6 deletions(-) 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()); }