diff --git a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtGroupMapper.xml b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtGroupMapper.xml index 4646822dc2..371914ebe9 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtGroupMapper.xml +++ b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtGroupMapper.xml @@ -5,8 +5,14 @@ diff --git a/backend/src/main/java/io/metersphere/controller/GroupController.java b/backend/src/main/java/io/metersphere/controller/GroupController.java index ff1ed9ebbe..7c18632f0f 100644 --- a/backend/src/main/java/io/metersphere/controller/GroupController.java +++ b/backend/src/main/java/io/metersphere/controller/GroupController.java @@ -10,6 +10,7 @@ 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.commons.utils.SessionUtils; import io.metersphere.controller.request.GroupRequest; import io.metersphere.controller.request.group.EditGroupRequest; import io.metersphere.controller.request.group.EditGroupUserRequest; @@ -17,6 +18,7 @@ import io.metersphere.dto.GroupDTO; import io.metersphere.dto.GroupPermissionDTO; import io.metersphere.log.annotation.MsAuditLog; import io.metersphere.service.GroupService; +import org.apache.commons.lang3.StringUtils; import org.apache.shiro.authz.annotation.Logical; import org.apache.shiro.authz.annotation.RequiresPermissions; import org.springframework.web.bind.annotation.*; @@ -35,13 +37,22 @@ public class GroupController { private GroupService groupService; @PostMapping("/get/{goPage}/{pageSize}") - @RequiresPermissions(value = {PermissionConstants.SYSTEM_GROUP_READ, PermissionConstants.PROJECT_GROUP_READ}, logical = Logical.OR) + @RequiresPermissions(value = {PermissionConstants.SYSTEM_GROUP_READ}, logical = Logical.OR) public Pager> getGroupList(@PathVariable int goPage, @PathVariable int pageSize, @RequestBody EditGroupRequest request) { request.setGoPage(goPage); request.setPageSize(pageSize); return groupService.getGroupList(request); } + @PostMapping("/get/current/project/{goPage}/{pageSize}") + @RequiresPermissions(value = {PermissionConstants.PROJECT_GROUP_READ}, logical = Logical.OR) + public Pager> getCurrentProjectGroupList(@PathVariable int goPage, @PathVariable int pageSize, @RequestBody EditGroupRequest request) { + request.setOnlyQueryCurrentProject(true); + request.setGoPage(goPage); + request.setPageSize(pageSize); + return groupService.getGroupList(request); + } + @GetMapping("/get/all") public List getAllGroup() { return groupService.getAllGroup(); @@ -117,11 +128,23 @@ public class GroupController { } @PostMapping("/user/{goPage}/{pageSize}") + @RequiresPermissions(value = {PermissionConstants.SYSTEM_GROUP_READ}, logical = Logical.OR) public Pager> getGroupUser(@PathVariable int goPage, @PathVariable int pageSize, @RequestBody EditGroupRequest editGroupRequest) { Page page = PageHelper.startPage(goPage, pageSize, true); return PageUtils.setPageInfo(page, groupService.getGroupUser(editGroupRequest)); } + @PostMapping("/current/project/user/{goPage}/{pageSize}") + @RequiresPermissions(value = {PermissionConstants.PROJECT_GROUP_READ}, logical = Logical.OR) + public Pager> getCurrentProjectGroupUser(@PathVariable int goPage, @PathVariable int pageSize, @RequestBody EditGroupRequest editGroupRequest) { + editGroupRequest.setOnlyQueryCurrentProject(true); + if (StringUtils.isBlank(editGroupRequest.getProjectId())) { + editGroupRequest.setProjectId(SessionUtils.getCurrentProjectId()); + } + Page page = PageHelper.startPage(goPage, pageSize, true); + return PageUtils.setPageInfo(page, groupService.getGroupUser(editGroupRequest)); + } + @GetMapping("/rm/{userId}/{groupId}") public void removeGroupMember(@PathVariable String userId, @PathVariable String groupId) { groupService.removeGroupMember(userId, groupId); diff --git a/backend/src/main/java/io/metersphere/controller/request/group/EditGroupRequest.java b/backend/src/main/java/io/metersphere/controller/request/group/EditGroupRequest.java index 58b806936f..4ca04f9667 100644 --- a/backend/src/main/java/io/metersphere/controller/request/group/EditGroupRequest.java +++ b/backend/src/main/java/io/metersphere/controller/request/group/EditGroupRequest.java @@ -27,4 +27,5 @@ public class EditGroupRequest extends Group { private List permissions; private String userGroupId; private List orders; + private boolean onlyQueryCurrentProject = false; } diff --git a/frontend/src/business/components/project/menu/UserGroup.vue b/frontend/src/business/components/project/menu/UserGroup.vue index 12dfb76a4e..4ebcf9023f 100644 --- a/frontend/src/business/components/project/menu/UserGroup.vue +++ b/frontend/src/business/components/project/menu/UserGroup.vue @@ -146,7 +146,7 @@ export default { initData() { this.condition.projectId = this.projectId; if (this.projectId) { - this.result = this.$post("/user/group/get/" + this.currentPage + "/" + this.pageSize, this.condition, res => { + this.result = this.$post("/user/group/get/current/project/" + this.currentPage + "/" + this.pageSize, this.condition, res => { let data = res.data; if (data) { let {itemCount, listObject} = data; @@ -205,7 +205,7 @@ export default { this.initData(); }, memberClick(row) { - this.$refs.groupMember.open(row); + this.$refs.groupMember.open(row, '/user/group/current/project/user/', 'user/ws/current/member/list'); } } }; diff --git a/frontend/src/business/components/settings/system/group/GroupMember.vue b/frontend/src/business/components/settings/system/group/GroupMember.vue index 088468ef29..a42f681a27 100644 --- a/frontend/src/business/components/settings/system/group/GroupMember.vue +++ b/frontend/src/business/components/settings/system/group/GroupMember.vue @@ -129,6 +129,8 @@ export default { title: '', submitType: '', userSelectDisable: false, + initUserGroupUrl: "/user/group/user/", + initUserUrl: "/user/list/", rules: { userIds: {required: true, message: this.$t('member.please_choose_member'), trigger: 'blur'}, sourceIds: {required: true, message: this.$t('group.select_belong_source'), trigger: 'blur'} @@ -153,7 +155,7 @@ export default { methods: { init() { this.condition.userGroupId = this.group.id; - this.result = this.$post("/user/group/user/" + this.currentPage + "/" + this.pageSize, this.condition, res => { + this.result = this.$post(this.initUserGroupUrl + this.currentPage + "/" + this.pageSize, this.condition, res => { let data = res.data; if (data) { let {itemCount, listObject} = data; @@ -162,7 +164,9 @@ export default { } }) }, - open(group) { + open(group, initUserGroupUrl, initUserUrl) { + this.initUserGroupUrl = initUserGroupUrl ? initUserGroupUrl : "/user/group/user/"; + this.initUserUrl = initUserUrl ? initUserUrl : "/user/list/"; this.visible = true; this.group = group; this.init(); @@ -211,7 +215,7 @@ export default { }) }, getUser() { - this.memberResult = this.$get('/user/list/', response => { + this.memberResult = this.$get(this.initUserUrl, response => { this.users = response.data; }) },