diff --git a/backend/src/main/java/io/metersphere/controller/request/resourcepool/UserBatchProcessRequest.java b/backend/src/main/java/io/metersphere/controller/request/resourcepool/UserBatchProcessRequest.java index 73223334ab..d7743880fa 100644 --- a/backend/src/main/java/io/metersphere/controller/request/resourcepool/UserBatchProcessRequest.java +++ b/backend/src/main/java/io/metersphere/controller/request/resourcepool/UserBatchProcessRequest.java @@ -21,5 +21,7 @@ public class UserBatchProcessRequest { List batchProcessValue; String workspaceId; UserRequest condition; + + String selectUserGroupId; } diff --git a/backend/src/main/java/io/metersphere/service/UserService.java b/backend/src/main/java/io/metersphere/service/UserService.java index cfab67acb9..c06850c56e 100644 --- a/backend/src/main/java/io/metersphere/service/UserService.java +++ b/backend/src/main/java/io/metersphere/service/UserService.java @@ -815,7 +815,22 @@ public class UserService { private void batchAddUserToProject(UserBatchProcessRequest request) { List userIds = this.selectIdByUserRequest(request); - String toSetGroup = UserGroupConstants.READ_ONLY; + String defaultGroup = UserGroupConstants.READ_ONLY; + String toSetGroup = request.getSelectUserGroupId(); + if (StringUtils.isBlank(toSetGroup)) { + toSetGroup = defaultGroup; + } else { + // 验证用户组ID有效性 + GroupExample groupExample = new GroupExample(); + groupExample.createCriteria() + .andIdEqualTo(toSetGroup) + .andTypeEqualTo(UserGroupType.PROJECT); + List groups = groupMapper.selectByExample(groupExample); + if (CollectionUtils.isEmpty(groups)) { + toSetGroup = defaultGroup; + } + } + List projectIds = request.getBatchProcessValue(); for (String userId : userIds) { UserGroupExample userGroupExample = new UserGroupExample(); diff --git a/frontend/src/business/components/settings/system/User.vue b/frontend/src/business/components/settings/system/User.vue index 3088110c69..2250ea4753 100644 --- a/frontend/src/business/components/settings/system/User.vue +++ b/frontend/src/business/components/settings/system/User.vue @@ -447,7 +447,7 @@ export default { addUserGroupBatch(){ this.$refs.groupCascaderDialog.open(); }, - cascaderConfirm(batchProcessTypeParam, selectValueArr){ + cascaderConfirm(batchProcessTypeParam, selectValueArr, selectedUserGroup){ if(selectValueArr.length === 0){ this.$success(this.$t('commons.modify_success')); } @@ -455,6 +455,7 @@ export default { params = this.buildBatchParam(params); params.batchType = batchProcessTypeParam; params.batchProcessValue = selectValueArr; + params.selectUserGroupId = selectedUserGroup; this.$post('/user/special/batchProcessUserInfo', params, () => { this.$success(this.$t('commons.modify_success')); this.search(); diff --git a/frontend/src/business/components/settings/system/components/ProjectCascader.vue b/frontend/src/business/components/settings/system/components/ProjectCascader.vue index 204605f535..1e6923dc0e 100644 --- a/frontend/src/business/components/settings/system/components/ProjectCascader.vue +++ b/frontend/src/business/components/settings/system/components/ProjectCascader.vue @@ -2,12 +2,21 @@
+ + + + @@ -35,6 +44,7 @@ import ElUploadList from "element-ui/packages/upload/src/upload-list"; import MsTableButton from '../../../../components/common/components/MsTableButton'; import {listenGoBack, removeGoBackListener} from "@/common/js/utils"; import MsDialogFooter from "@/business/components/common/components/MsDialogFooter"; +import {GROUP_PROJECT} from "@/common/js/constants"; export default { name: "User2ProjectCascader", @@ -58,6 +68,8 @@ export default { ], }, selectedIds: [], + selectedUserGroup: "", + projectUserGroups: [], isResourceShow: 0, props: { multiple: true, @@ -85,6 +97,9 @@ export default { default: '' } }, + created() { + this.getProjectUserGroup(); + }, methods: { close() { removeGoBackListener(this.close); @@ -107,7 +122,7 @@ export default { for (let i = 0; i < checkNodes.length; i++) { selectValueArr.push(checkNodes[i].value); } - this.$emit('confirm', 'ADD_PROJECT', selectValueArr); + this.$emit('confirm', 'ADD_PROJECT', selectValueArr, this.selectedUserGroup); this.loading = true; } else { return false; @@ -131,6 +146,11 @@ export default { } resolve(data); }) + }, + getProjectUserGroup() { + this.$post("/user/group/get", {type: GROUP_PROJECT}, (res) => { + this.projectUserGroups = res.data ? res.data : []; + }) } } }