mirror of
https://gitee.com/fit2cloud-feizhiyun/MeterSphere.git
synced 2024-12-03 12:39:12 +08:00
roles indexOf bug fix
This commit is contained in:
parent
eeadaa2c78
commit
2afa1bca4c
@ -6,7 +6,9 @@ import io.metersphere.base.domain.Workspace;
|
|||||||
import io.metersphere.commons.constants.RoleConstants;
|
import io.metersphere.commons.constants.RoleConstants;
|
||||||
import io.metersphere.commons.utils.PageUtils;
|
import io.metersphere.commons.utils.PageUtils;
|
||||||
import io.metersphere.commons.utils.Pager;
|
import io.metersphere.commons.utils.Pager;
|
||||||
|
import io.metersphere.controller.request.WorkspaceRequest;
|
||||||
import io.metersphere.service.WorkspaceService;
|
import io.metersphere.service.WorkspaceService;
|
||||||
|
import io.metersphere.user.SessionUtils;
|
||||||
import org.apache.shiro.authz.annotation.RequiresRoles;
|
import org.apache.shiro.authz.annotation.RequiresRoles;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
@ -41,9 +43,10 @@ public class WorkspaceController {
|
|||||||
|
|
||||||
@PostMapping("list/{goPage}/{pageSize}")
|
@PostMapping("list/{goPage}/{pageSize}")
|
||||||
@RequiresRoles(RoleConstants.ORG_ADMIN)
|
@RequiresRoles(RoleConstants.ORG_ADMIN)
|
||||||
public Pager<List<Workspace>> getWorkspaceList(@PathVariable int goPage, @PathVariable int pageSize) {
|
public Pager<List<Workspace>> getWorkspaceList(@PathVariable int goPage, @PathVariable int pageSize, @RequestBody WorkspaceRequest request) {
|
||||||
|
request.setOrganizationId(SessionUtils.getCurrentOrganizationId());
|
||||||
Page<Object> page = PageHelper.startPage(goPage, pageSize, true);
|
Page<Object> page = PageHelper.startPage(goPage, pageSize, true);
|
||||||
return PageUtils.setPageInfo(page, workspaceService.getWorkspaceList());
|
return PageUtils.setPageInfo(page, workspaceService.getWorkspaceList(request));
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/list/userworkspace/{userId}")
|
@GetMapping("/list/userworkspace/{userId}")
|
||||||
|
@ -0,0 +1,25 @@
|
|||||||
|
package io.metersphere.controller.request;
|
||||||
|
|
||||||
|
import io.metersphere.commons.annotations.FuzzyQuery;
|
||||||
|
|
||||||
|
public class WorkspaceRequest {
|
||||||
|
private String organizationId;
|
||||||
|
@FuzzyQuery
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
public String getOrganizationId() {
|
||||||
|
return organizationId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOrganizationId(String organizationId) {
|
||||||
|
this.organizationId = organizationId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
}
|
@ -7,6 +7,7 @@ import io.metersphere.base.mapper.WorkspaceMapper;
|
|||||||
import io.metersphere.base.mapper.ext.ExtUserRoleMapper;
|
import io.metersphere.base.mapper.ext.ExtUserRoleMapper;
|
||||||
import io.metersphere.commons.constants.RoleConstants;
|
import io.metersphere.commons.constants.RoleConstants;
|
||||||
import io.metersphere.commons.exception.MSException;
|
import io.metersphere.commons.exception.MSException;
|
||||||
|
import io.metersphere.controller.request.WorkspaceRequest;
|
||||||
import io.metersphere.dto.UserRoleHelpDTO;
|
import io.metersphere.dto.UserRoleHelpDTO;
|
||||||
import io.metersphere.user.SessionUser;
|
import io.metersphere.user.SessionUser;
|
||||||
import io.metersphere.user.SessionUtils;
|
import io.metersphere.user.SessionUtils;
|
||||||
@ -55,8 +56,16 @@ public class WorkspaceService {
|
|||||||
return workspace;
|
return workspace;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Workspace> getWorkspaceList() {
|
public List<Workspace> getWorkspaceList(WorkspaceRequest request) {
|
||||||
return workspaceMapper.selectByExample(null);
|
WorkspaceExample example = new WorkspaceExample();
|
||||||
|
WorkspaceExample.Criteria criteria = example.createCriteria();
|
||||||
|
if (StringUtils.isNotBlank(request.getOrganizationId())) {
|
||||||
|
criteria.andOrganizationIdEqualTo(request.getOrganizationId());
|
||||||
|
}
|
||||||
|
if (StringUtils.isNotBlank(request.getName())) {
|
||||||
|
criteria.andNameLike(request.getName());
|
||||||
|
}
|
||||||
|
return workspaceMapper.selectByExample(example);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void deleteWorkspace(String workspaceId) {
|
public void deleteWorkspace(String workspaceId) {
|
||||||
|
@ -99,12 +99,12 @@
|
|||||||
},
|
},
|
||||||
initMenuData() {
|
initMenuData() {
|
||||||
let roles = this.currentUser.roles.map(r => r.id);
|
let roles = this.currentUser.roles.map(r => r.id);
|
||||||
if (roles.indexOf(ROLE_ORG_ADMIN) > 0) {
|
if (roles.indexOf(ROLE_ORG_ADMIN) > -1) {
|
||||||
this.$get("/organization/list/userorg/" + this.currentUserId, response => {
|
this.$get("/organization/list/userorg/" + this.currentUserId, response => {
|
||||||
this.organizationList = response.data;
|
this.organizationList = response.data;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (roles.indexOf(ROLE_TEST_MANAGER) > 0 || roles.indexOf(ROLE_TEST_USER) > 0 || roles.indexOf(ROLE_TEST_VIEWER) > 0) {
|
if (roles.indexOf(ROLE_TEST_MANAGER) > -1 || roles.indexOf(ROLE_TEST_USER) > -1 || roles.indexOf(ROLE_TEST_VIEWER) > -1) {
|
||||||
this.$get("/workspace/list/userworkspace/" + this.currentUserId, response => {
|
this.$get("/workspace/list/userworkspace/" + this.currentUserId, response => {
|
||||||
this.workspaceList = response.data;
|
this.workspaceList = response.data;
|
||||||
this.workspaceIds = response.data.map(r => r.id);
|
this.workspaceIds = response.data.map(r => r.id);
|
||||||
@ -124,10 +124,10 @@
|
|||||||
let user = {};
|
let user = {};
|
||||||
user.id = this.currentUserInfo.id;
|
user.id = this.currentUserInfo.id;
|
||||||
user.lastSourceId = data.id;
|
user.lastSourceId = data.id;
|
||||||
this.$post("/user/switch/source/" + user.lastSourceId, {},response => {
|
this.$post("/user/switch/source/" + user.lastSourceId, {}, response => {
|
||||||
Cookies.set(TokenKey, response.data);
|
Cookies.set(TokenKey, response.data);
|
||||||
window.location.reload();
|
window.location.reload();
|
||||||
})
|
})
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -118,7 +118,7 @@
|
|||||||
},
|
},
|
||||||
list() {
|
list() {
|
||||||
let url = '/workspace/list/' + this.currentPage + '/' + this.pageSize;
|
let url = '/workspace/list/' + this.currentPage + '/' + this.pageSize;
|
||||||
this.result = this.$post(url, {}, response => {
|
this.result = this.$post(url, {name: this.condition}, response => {
|
||||||
let data = response.data;
|
let data = response.data;
|
||||||
this.items = data.listObject;
|
this.items = data.listObject;
|
||||||
this.total = data.itemCount;
|
this.total = data.itemCount;
|
||||||
|
Loading…
Reference in New Issue
Block a user