diff --git a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtUserRoleMapper.xml b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtUserRoleMapper.xml index 5b50199586..873a5e7229 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtUserRoleMapper.xml +++ b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtUserRoleMapper.xml @@ -30,6 +30,9 @@ \ No newline at end of file diff --git a/backend/src/main/java/io/metersphere/controller/ProjectController.java b/backend/src/main/java/io/metersphere/controller/ProjectController.java index acf07500a0..a9d414afb4 100644 --- a/backend/src/main/java/io/metersphere/controller/ProjectController.java +++ b/backend/src/main/java/io/metersphere/controller/ProjectController.java @@ -3,9 +3,11 @@ package io.metersphere.controller; import com.github.pagehelper.Page; import com.github.pagehelper.PageHelper; import io.metersphere.base.domain.Project; +import io.metersphere.commons.constants.RoleConstants; import io.metersphere.commons.utils.PageUtils; import io.metersphere.commons.utils.Pager; import io.metersphere.service.ProjectService; +import org.apache.shiro.authz.annotation.RequiresRoles; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; @@ -24,22 +26,26 @@ public class ProjectController { } @PostMapping("/add") + @RequiresRoles(RoleConstants.TEST_MANAGER) public Project addProject(@RequestBody Project project) { return projectService.addProject(project); } @PostMapping("/list/{goPage}/{pageSize}") + @RequiresRoles(RoleConstants.TEST_MANAGER) public Pager> getProjectList(@PathVariable int goPage, @PathVariable int pageSize) { Page page = PageHelper.startPage(goPage, pageSize, true); return PageUtils.setPageInfo(page, projectService.getProjectList()); } @GetMapping("/delete/{projectId}") + @RequiresRoles(RoleConstants.TEST_MANAGER) public void deleteProject(@PathVariable(value = "projectId") String projectId) { projectService.deleteProject(projectId); } @PostMapping("/update") + @RequiresRoles(RoleConstants.TEST_MANAGER) public void updateProject(@RequestBody Project Project) { projectService.updateProject(Project); } diff --git a/backend/src/main/java/io/metersphere/controller/UserController.java b/backend/src/main/java/io/metersphere/controller/UserController.java index 1d163c170b..d68f14d03f 100644 --- a/backend/src/main/java/io/metersphere/controller/UserController.java +++ b/backend/src/main/java/io/metersphere/controller/UserController.java @@ -71,7 +71,7 @@ public class UserController { * 获取成员用户 */ @PostMapping("/member/list/{goPage}/{pageSize}") - @RequiresRoles(RoleConstants.TEST_MANAGER) + //@RequiresRoles(RoleConstants.TEST_MANAGER) public Pager> getMemberList(@PathVariable int goPage, @PathVariable int pageSize, @RequestBody QueryMemberRequest request) { Page page = PageHelper.startPage(goPage, pageSize, true); return PageUtils.setPageInfo(page, userService.getMemberList(request)); @@ -81,7 +81,7 @@ public class UserController { * 添加成员 */ @PostMapping("/member/add") - @RequiresRoles(RoleConstants.TEST_MANAGER) + //@RequiresRoles(RoleConstants.TEST_MANAGER) public void addMember(@RequestBody AddMemberRequest request) { userService.addMember(request); } @@ -90,7 +90,7 @@ public class UserController { * 删除成员 */ @GetMapping("/member/delete/{workspaceId}/{userId}") - @RequiresRoles(RoleConstants.TEST_MANAGER) + //@RequiresRoles(RoleConstants.TEST_MANAGER) public void deleteMember(@PathVariable String workspaceId, @PathVariable String userId) { userService.deleteMember(workspaceId, userId); } diff --git a/backend/src/main/java/io/metersphere/controller/WorkspaceController.java b/backend/src/main/java/io/metersphere/controller/WorkspaceController.java index ad910bdb32..52efa2cff9 100644 --- a/backend/src/main/java/io/metersphere/controller/WorkspaceController.java +++ b/backend/src/main/java/io/metersphere/controller/WorkspaceController.java @@ -1,7 +1,13 @@ package io.metersphere.controller; +import com.github.pagehelper.Page; +import com.github.pagehelper.PageHelper; import io.metersphere.base.domain.Workspace; +import io.metersphere.commons.constants.RoleConstants; +import io.metersphere.commons.utils.PageUtils; +import io.metersphere.commons.utils.Pager; import io.metersphere.service.WorkspaceService; +import org.apache.shiro.authz.annotation.RequiresRoles; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; @@ -13,18 +19,30 @@ public class WorkspaceController { @Resource private WorkspaceService workspaceService; - @PostMapping("save") - public Workspace saveWorkspace(@RequestBody Workspace workspace) { + @PostMapping("add") + @RequiresRoles(RoleConstants.ORG_ADMIN) + public Workspace addWorkspace(@RequestBody Workspace workspace) { + return workspaceService.saveWorkspace(workspace); + } + + @PostMapping("update") + @RequiresRoles(RoleConstants.ORG_ADMIN) + public Workspace updateWorkspace(@RequestBody Workspace workspace) { + workspaceService.checkOwner(workspace.getId()); return workspaceService.saveWorkspace(workspace); } @GetMapping("delete/{workspaceId}") + @RequiresRoles(RoleConstants.ORG_ADMIN) public void saveWorkspace(@PathVariable String workspaceId) { + workspaceService.checkOwner(workspaceId); workspaceService.deleteWorkspace(workspaceId); } - @PostMapping("list") - public List getWorkspaceList() { - return workspaceService.getWorkspaceList(); + @PostMapping("list/{goPage}/{pageSize}") + @RequiresRoles(RoleConstants.ORG_ADMIN) + public Pager> getWorkspaceList(@PathVariable int goPage, @PathVariable int pageSize) { + Page page = PageHelper.startPage(goPage, pageSize, true); + return PageUtils.setPageInfo(page, workspaceService.getWorkspaceList()); } } diff --git a/backend/src/main/java/io/metersphere/controller/request/member/QueryMemberRequest.java b/backend/src/main/java/io/metersphere/controller/request/member/QueryMemberRequest.java index 973f27089a..c951665b77 100644 --- a/backend/src/main/java/io/metersphere/controller/request/member/QueryMemberRequest.java +++ b/backend/src/main/java/io/metersphere/controller/request/member/QueryMemberRequest.java @@ -3,9 +3,26 @@ package io.metersphere.controller.request.member; import io.metersphere.commons.constants.RoleConstants; public class QueryMemberRequest { + private String name; private String workspaceId; private String roleId = RoleConstants.TEST_MANAGER; + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getRoleId() { + return roleId; + } + + public void setRoleId(String roleId) { + this.roleId = roleId; + } + public String getWorkspaceId() { return workspaceId; } diff --git a/backend/src/main/java/io/metersphere/service/WorkspaceService.java b/backend/src/main/java/io/metersphere/service/WorkspaceService.java index 98bbf6e036..eab372637b 100644 --- a/backend/src/main/java/io/metersphere/service/WorkspaceService.java +++ b/backend/src/main/java/io/metersphere/service/WorkspaceService.java @@ -45,4 +45,9 @@ public class WorkspaceService { public void deleteWorkspace(String workspaceId) { workspaceMapper.deleteByPrimaryKey(workspaceId); } + + public void checkOwner(String workspaceId) { + // TODO 验证当前用户是否拥有当前此空间权限 + } + } diff --git a/frontend/src/performance/components/project/MsProject.vue b/frontend/src/performance/components/project/MsProject.vue index 2d8e335ceb..65adbe61e8 100644 --- a/frontend/src/performance/components/project/MsProject.vue +++ b/frontend/src/performance/components/project/MsProject.vue @@ -4,7 +4,10 @@
- 项目 + + 项目 + + @@ -21,8 +24,24 @@ +
+ + +
+ + +
+
+
+
- @@ -56,6 +75,9 @@ condition: "", items: [], form: {}, + currentPage: 1, + pageSize: 5, + total: 0, rules: { name: [ {required: true, message: '请输入项目名称', trigger: 'blur'}, @@ -113,10 +135,19 @@ }); }, list() { - this.$post("/project/list/1/10", {}, (response) => { + let url = "/project/list/" + this.currentPage + '/' + this.pageSize; + this.$post(url, {}, (response) => { this.items = response.data; }) - } + }, + handleSizeChange(size) { + this.pageSize = size; + this.list(); + }, + handleCurrentChange(current) { + this.currentPage = current; + this.list(); + }, } } diff --git a/frontend/src/performance/components/settings/Member.vue b/frontend/src/performance/components/settings/Member.vue index 1c637749b6..53dcec6046 100644 --- a/frontend/src/performance/components/settings/Member.vue +++ b/frontend/src/performance/components/settings/Member.vue @@ -7,7 +7,7 @@
-
@@ -42,16 +42,20 @@ - - - - - - + + + + + + - 创建 + 保存
@@ -59,7 +63,6 @@