refactor: 工作空间查询设置权限

This commit is contained in:
CaptainB 2022-06-08 13:28:52 +08:00 committed by 刘瑞斌
parent 112f089570
commit c3d460964e
4 changed files with 14 additions and 28 deletions

View File

@ -5,6 +5,7 @@ import com.github.pagehelper.PageHelper;
import io.metersphere.base.domain.Workspace;
import io.metersphere.commons.constants.OperLogConstants;
import io.metersphere.commons.constants.OperLogModule;
import io.metersphere.commons.constants.PermissionConstants;
import io.metersphere.commons.utils.PageUtils;
import io.metersphere.commons.utils.Pager;
import io.metersphere.controller.request.WorkspaceRequest;
@ -14,6 +15,8 @@ import io.metersphere.dto.WorkspaceResource;
import io.metersphere.log.annotation.MsAuditLog;
import io.metersphere.service.UserService;
import io.metersphere.service.WorkspaceService;
import org.apache.shiro.authz.annotation.Logical;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
@ -27,51 +30,39 @@ public class WorkspaceController {
@Resource
private UserService userService;
@PostMapping("add")
@MsAuditLog(module = OperLogModule.SYSTEM_WORKSPACE, type = OperLogConstants.CREATE, content = "#msClass.getLogDetails(#workspace.id)", msClass = WorkspaceService.class)
public Workspace addWorkspace(@RequestBody Workspace workspace) {
return workspaceService.saveWorkspace(workspace);
}
@GetMapping("/list")
@RequiresPermissions(value = {
PermissionConstants.SYSTEM_GROUP_READ_CREATE,
PermissionConstants.SYSTEM_GROUP_READ_EDIT,
PermissionConstants.SYSTEM_USER_READ_CREATE,
PermissionConstants.SYSTEM_USER_READ_EDIT,
}, logical = Logical.OR)
public List<Workspace> getWorkspaceList() {
return workspaceService.getWorkspaceList(new WorkspaceRequest());
}
@PostMapping("special/add")
@MsAuditLog(module = OperLogModule.SYSTEM_WORKSPACE, type = OperLogConstants.CREATE, content = "#msClass.getLogDetails(#workspace.id)", msClass = WorkspaceService.class)
@RequiresPermissions(PermissionConstants.SYSTEM_WORKSPACE_READ_CREATE)
public Workspace addWorkspaceByAdmin(@RequestBody Workspace workspace) {
return workspaceService.addWorkspaceByAdmin(workspace);
}
@PostMapping("update")
@MsAuditLog(module = OperLogModule.SYSTEM_WORKSPACE, type = OperLogConstants.UPDATE, beforeEvent = "#msClass.getLogDetails(#workspace.id)", content = "#msClass.getLogDetails(#workspace.id)", msClass = WorkspaceService.class)
public Workspace updateWorkspace(@RequestBody Workspace workspace) {
// workspaceService.checkWorkspaceOwnerByOrgAdmin(workspace.getId());
return workspaceService.saveWorkspace(workspace);
}
@PostMapping("special/update")
@MsAuditLog(module = OperLogModule.SYSTEM_WORKSPACE, type = OperLogConstants.UPDATE, beforeEvent = "#msClass.getLogDetails(#workspace.id)", content = "#msClass.getLogDetails(#workspace.id)", msClass = WorkspaceService.class)
@RequiresPermissions(PermissionConstants.SYSTEM_WORKSPACE_READ_EDIT)
public void updateWorkspaceByAdmin(@RequestBody Workspace workspace) {
workspaceService.updateWorkspaceByAdmin(workspace);
}
@GetMapping("special/delete/{workspaceId}")
@MsAuditLog(module = OperLogModule.SYSTEM_WORKSPACE, type = OperLogConstants.DELETE, beforeEvent = "#msClass.getLogDetails(#workspaceId)", msClass = WorkspaceService.class)
@RequiresPermissions(PermissionConstants.SYSTEM_WORKSPACE_READ_DELETE)
public void deleteWorkspaceByAdmin(@PathVariable String workspaceId) {
userService.refreshSessionUser("workspace", workspaceId);
workspaceService.deleteWorkspace(workspaceId);
}
@GetMapping("delete/{workspaceId}")
@MsAuditLog(module = OperLogModule.SYSTEM_WORKSPACE, type = OperLogConstants.DELETE, beforeEvent = "#msClass.getLogDetails(#workspaceId)", msClass = WorkspaceService.class)
public void deleteWorkspace(@PathVariable String workspaceId) {
// workspaceService.checkWorkspaceOwnerByOrgAdmin(workspaceId);
userService.refreshSessionUser("workspace", workspaceId);
workspaceService.deleteWorkspace(workspaceId);
}
@PostMapping("list/{goPage}/{pageSize}")
public Pager<List<Workspace>> getWorkspaceList(@PathVariable int goPage, @PathVariable int pageSize, @RequestBody WorkspaceRequest request) {
Page<Object> page = PageHelper.startPage(goPage, pageSize, true);

View File

@ -420,11 +420,6 @@ export default {
handleSelectionChange(val) {
this.multipleSelection = val;
},
getWsList() {
this.$get("/workspace/list", response => {
this.$set(this.form, "wsList", response.data);
})
},
importUserDialogOpen(){
this.$refs.userImportDialog.open();
},

View File

@ -151,7 +151,7 @@ export default {
});
},
getWorkspace(resolve) {
this.$get("workspace/list/", res => {
this.$get("workspace/list", res => {
let data = res.data ? res.data : [];
if (data.length > 0) {
data.forEach(d => d.leaf = false);

View File

@ -125,7 +125,7 @@ export default {
});
},
getWorkspace(resolve) {
this.$get("workspace/list/", res => {
this.$get("workspace/list", res => {
let data = res.data ? res.data : [];
data.forEach(d => d.leaf = true);
resolve(data);