refactor: 切换工作空间权限修改

This commit is contained in:
Captain.B 2021-06-14 09:33:31 +08:00 committed by 刘瑞斌
parent 7ad79057ac
commit 61be97d3c5
4 changed files with 7 additions and 21 deletions

View File

@ -92,15 +92,9 @@ public class WorkspaceController {
return workspaceService.getWorkspaceListByUserId(userId); return workspaceService.getWorkspaceListByUserId(userId);
} }
@GetMapping("/list/orgworkspace/") @GetMapping("/list/orgworkspace/{userId}/{orgId}")
public List<Workspace> getWorkspaceListByOrgIdAndUserId() { public List<Workspace> getWorkspaceListByOrgId(@PathVariable String userId, @PathVariable String orgId) {
String currentOrganizationId = SessionUtils.getCurrentOrganizationId(); return workspaceService.getWorkspaceListByOrgIdAndUserId(userId, orgId);
return workspaceService.getWorkspaceListByOrgIdAndUserId(currentOrganizationId);
}
@GetMapping("/list/orgworkspace/{orgId}")
public List<WorkspaceDTO> getWorkspaceListByOrgId(@PathVariable String orgId) {
return workspaceService.getWorkspaceIdsByOrgId(orgId);
} }
@PostMapping("/member/update") @PostMapping("/member/update")

View File

@ -467,7 +467,7 @@ public class UserService {
if (StringUtils.equals("organization", sign)) { if (StringUtils.equals("organization", sign)) {
user.setLastOrganizationId(sourceId); user.setLastOrganizationId(sourceId);
List<Workspace> workspaces = workspaceService.getWorkspaceListByOrgIdAndUserId(sourceId); List<Workspace> workspaces = workspaceService.getWorkspaceListByOrgIdAndUserId(user.getId(), sourceId);
if (workspaces.size() > 0) { if (workspaces.size() > 0) {
user.setLastWorkspaceId(workspaces.get(0).getId()); user.setLastWorkspaceId(workspaces.get(0).getId());
List<Project> projects = getProjectListByWsAndUserId(workspaces.get(0).getId()); List<Project> projects = getProjectListByWsAndUserId(workspaces.get(0).getId());

View File

@ -202,9 +202,8 @@ public class WorkspaceService {
return workspaceMapper.selectByExample(workspaceExample); return workspaceMapper.selectByExample(workspaceExample);
} }
public List<Workspace> getWorkspaceListByOrgIdAndUserId(String orgId) { public List<Workspace> getWorkspaceListByOrgIdAndUserId(String userId, String orgId) {
String useId = SessionUtils.getUser().getId(); List<RelatedSource> relatedSource = extUserGroupMapper.getRelatedSource(userId);
List<RelatedSource> relatedSource = extUserGroupMapper.getRelatedSource(useId);
List<String> wsIds = relatedSource List<String> wsIds = relatedSource
.stream() .stream()
.filter(r -> StringUtils.equals(r.getOrganizationId(), orgId)) .filter(r -> StringUtils.equals(r.getOrganizationId(), orgId))

View File

@ -60,7 +60,6 @@ export default {
name: "MsHeaderOrgWs", name: "MsHeaderOrgWs",
created() { created() {
this.initMenuData(); this.initMenuData();
this.getCurrentUserInfo();
}, },
inject: [ inject: [
'reloadTopMenus', 'reloadTopMenus',
@ -73,7 +72,6 @@ export default {
workspaceList: [ workspaceList: [
{name: this.$t('workspace.none')}, {name: this.$t('workspace.none')},
], ],
currentUserInfo: {},
currentUserId: getCurrentUser().id, currentUserId: getCurrentUser().id,
workspaceIds: [], workspaceIds: [],
currentOrganizationName: '', currentOrganizationName: '',
@ -113,7 +111,7 @@ export default {
this.currentOrganizationName = org[0].name; this.currentOrganizationName = org[0].name;
} }
this.organizationList.forEach(org => { this.organizationList.forEach(org => {
this.$get("/workspace/list/orgworkspace/" + org.id, response => { this.$get("/workspace/list/orgworkspace/" + encodeURIComponent(this.currentUserId) + "/" + org.id, response => {
let d = response.data; let d = response.data;
if (d.length === 0) { if (d.length === 0) {
// org.workspaceList = [{name: this.$t('workspace.none')}]; // org.workspaceList = [{name: this.$t('workspace.none')}];
@ -147,11 +145,6 @@ export default {
} }
});*/ });*/
}, },
getCurrentUserInfo() {
this.$get("/user/info/" + encodeURIComponent(this.currentUserId), response => {
this.currentUserInfo = response.data;
});
},
changeOrg(data) { changeOrg(data) {
let orgId = data.id; let orgId = data.id;
if (!orgId) { if (!orgId) {