workspace check owner

This commit is contained in:
Captain.B 2020-02-18 16:27:25 +08:00
parent 6c93ec36f9
commit 40f0159f89
3 changed files with 21 additions and 4 deletions

View File

@ -19,15 +19,23 @@ public class WorkspaceController {
@Resource
private WorkspaceService workspaceService;
@PostMapping("save")
@PostMapping("add")
@RequiresRoles(RoleConstants.ORG_ADMIN)
public Workspace saveWorkspace(@RequestBody Workspace workspace) {
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);
}

View File

@ -45,4 +45,9 @@ public class WorkspaceService {
public void deleteWorkspace(String workspaceId) {
workspaceMapper.deleteByPrimaryKey(workspaceId);
}
public void checkOwner(String workspaceId) {
// TODO 验证当前用户是否拥有当前此空间权限
}
}

View File

@ -77,12 +77,16 @@
this.$refs[formName].validate((valid) => {
if (valid) {
this.loading = true;
this.$post("/workspace/save", this.form, () => {
let saveType = 'add';
if (this.form.id) {
saveType = 'update'
}
this.$post("/workspace/" + saveType, this.form, () => {
this.createVisible = false;
this.loading = false;
this.list();
Message.success('保存成功');
})
});
} else {
return false;
}