From ab23a3d5f3bb4195ab349a8a10c09656a181e081 Mon Sep 17 00:00:00 2001 From: shiziyuan9527 Date: Wed, 27 May 2020 14:06:30 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E7=AE=A1=E7=90=86=E5=91=98=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E6=88=90=E5=91=98=E6=97=B6=E6=8F=90=E7=A4=BA=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../io/metersphere/controller/UserController.java | 2 +- .../java/io/metersphere/service/UserService.java | 4 ++-- .../main/resources/i18n/messages_en_US.properties | 1 + .../main/resources/i18n/messages_zh_CN.properties | 1 + .../main/resources/i18n/messages_zh_TW.properties | 1 + .../settings/organization/OrganizationMember.vue | 2 +- .../settings/workspace/WorkspaceMember.vue | 14 +++++++++----- 7 files changed, 16 insertions(+), 9 deletions(-) diff --git a/backend/src/main/java/io/metersphere/controller/UserController.java b/backend/src/main/java/io/metersphere/controller/UserController.java index a901a32e77..00a3e5fac7 100644 --- a/backend/src/main/java/io/metersphere/controller/UserController.java +++ b/backend/src/main/java/io/metersphere/controller/UserController.java @@ -120,7 +120,7 @@ public class UserController { } @GetMapping("/list") - @RequiresRoles(value = {RoleConstants.ADMIN, RoleConstants.ORG_ADMIN}, logical = Logical.OR) + @RequiresRoles(value = {RoleConstants.ADMIN, RoleConstants.ORG_ADMIN, RoleConstants.TEST_MANAGER}, logical = Logical.OR) public List getUserList() { return userService.getUserList(); } diff --git a/backend/src/main/java/io/metersphere/service/UserService.java b/backend/src/main/java/io/metersphere/service/UserService.java index f96c460205..83424c9a50 100644 --- a/backend/src/main/java/io/metersphere/service/UserService.java +++ b/backend/src/main/java/io/metersphere/service/UserService.java @@ -243,7 +243,7 @@ public class UserService { if (userRoles.size() > 0) { User user = userMapper.selectByPrimaryKey(userId); String username = user.getName(); - MSException.throwException("The user [" + username + "] already exists in the current workspace!"); + MSException.throwException(Translator.get("user_already_exists")); } else { for (String roleId : request.getRoleIds()) { UserRole userRole = new UserRole(); @@ -276,7 +276,7 @@ public class UserService { if (userRoles.size() > 0) { User user = userMapper.selectByPrimaryKey(userId); String username = user.getName(); - MSException.throwException("The user [" + username + "] already exists in the current organization!"); + MSException.throwException(Translator.get("user_already_exists")); } else { for (String roleId : request.getRoleIds()) { UserRole userRole = new UserRole(); diff --git a/backend/src/main/resources/i18n/messages_en_US.properties b/backend/src/main/resources/i18n/messages_en_US.properties index 0980eb534b..e5a9d1e3db 100644 --- a/backend/src/main/resources/i18n/messages_en_US.properties +++ b/backend/src/main/resources/i18n/messages_en_US.properties @@ -14,6 +14,7 @@ password_is_null=Password cannot be null user_id_already_exists=User ID already exists password_modification_failed=Password modification failed cannot_delete_current_user=Cannot delete the user currently logged in +user_already_exists=The user already exists in the current member list #load test edit_load_test_not_found=Cannot edit test, test not found= run_load_test_not_found=Cannot run test, test not found= diff --git a/backend/src/main/resources/i18n/messages_zh_CN.properties b/backend/src/main/resources/i18n/messages_zh_CN.properties index 51df23dd7b..c1f168a74e 100644 --- a/backend/src/main/resources/i18n/messages_zh_CN.properties +++ b/backend/src/main/resources/i18n/messages_zh_CN.properties @@ -14,6 +14,7 @@ user_id_already_exists=用户id已存在 password_modification_failed=密码修改失败 cannot_delete_current_user=无法删除当前登录用户 connection_failed=连接失败 +user_already_exists=该用户已存在于当前成员列表中 #load test edit_load_test_not_found=无法编辑测试,未找到测试: run_load_test_not_found=无法运行测试,未找到测试: diff --git a/backend/src/main/resources/i18n/messages_zh_TW.properties b/backend/src/main/resources/i18n/messages_zh_TW.properties index 91b8e87bdf..af71d422c2 100644 --- a/backend/src/main/resources/i18n/messages_zh_TW.properties +++ b/backend/src/main/resources/i18n/messages_zh_TW.properties @@ -14,6 +14,7 @@ password_is_null=密碼不能為空 user_id_already_exists=用戶id已存在 password_modification_failed=密碼修改失敗 cannot_delete_current_user=無法刪除當前登錄用戶 +user_already_exists=該用戶已存在於當前成員列表中 #load test edit_load_test_not_found=無法編輯測試,未找到測試: run_load_test_not_found=無法運行測試,未找到測試: diff --git a/frontend/src/business/components/settings/organization/OrganizationMember.vue b/frontend/src/business/components/settings/organization/OrganizationMember.vue index 1444ed8c21..1a5c4908c1 100644 --- a/frontend/src/business/components/settings/organization/OrganizationMember.vue +++ b/frontend/src/business/components/settings/organization/OrganizationMember.vue @@ -212,7 +212,7 @@ } this.form = {}; this.createVisible = true; - this.result = this.$get('/user/besideorg/list/' + this.currentUser().lastOrganizationId, response => { + this.result = this.$get('/user/list/', response => { this.userList = response.data; }); this.result = this.$get('/role/list/org', response => { diff --git a/frontend/src/business/components/settings/workspace/WorkspaceMember.vue b/frontend/src/business/components/settings/workspace/WorkspaceMember.vue index 3dc83e08c4..4c926508b8 100644 --- a/frontend/src/business/components/settings/workspace/WorkspaceMember.vue +++ b/frontend/src/business/components/settings/workspace/WorkspaceMember.vue @@ -214,16 +214,20 @@ }, create() { this.form = {}; - let param = { - name: this.condition.name, - organizationId: this.currentUser().lastOrganizationId - }; + // let param = { + // name: this.condition.name, + // organizationId: this.currentUser().lastOrganizationId + // }; let wsId = this.currentUser().lastWorkspaceId; if (typeof wsId == "undefined" || wsId == null || wsId == "") { this.$warning(this.$t('workspace.please_select_a_workspace_first')); return false; } - this.$post('/user/org/member/list/all', param, response => { + // this.$post('/user/org/member/list/all', param, response => { + // this.createVisible = true; + // this.userList = response.data; + // }) + this.$get('/user/list/', response => { this.createVisible = true; this.userList = response.data; }) From eeb6dd0a70ef0d483e0c0563143fc1b664add781 Mon Sep 17 00:00:00 2001 From: shiziyuan9527 Date: Wed, 27 May 2020 14:42:54 +0800 Subject: [PATCH 2/3] =?UTF-8?q?bug=20fix=20=E7=A6=81=E7=94=A8=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E5=90=8E=E4=BB=8D=E5=8F=AF=E7=99=BB=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/io/metersphere/controller/UserController.java | 5 +++++ .../src/main/java/io/metersphere/service/UserService.java | 4 ---- frontend/src/business/components/settings/system/User.vue | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/backend/src/main/java/io/metersphere/controller/UserController.java b/backend/src/main/java/io/metersphere/controller/UserController.java index 00a3e5fac7..50b1a34bc4 100644 --- a/backend/src/main/java/io/metersphere/controller/UserController.java +++ b/backend/src/main/java/io/metersphere/controller/UserController.java @@ -69,6 +69,11 @@ public class UserController { userService.updateUserRole(user); } + @PostMapping("/special/update_status") + public void updateStatus(@RequestBody User user) { + userService.updateUser(user); + } + @PostMapping("/special/ws/member/list/{goPage}/{pageSize}") @RequiresRoles(RoleConstants.ADMIN) public Pager> getMemberListByAdmin(@PathVariable int goPage, @PathVariable int pageSize, @RequestBody QueryMemberRequest request) { diff --git a/backend/src/main/java/io/metersphere/service/UserService.java b/backend/src/main/java/io/metersphere/service/UserService.java index 83424c9a50..71434fcd33 100644 --- a/backend/src/main/java/io/metersphere/service/UserService.java +++ b/backend/src/main/java/io/metersphere/service/UserService.java @@ -241,8 +241,6 @@ public class UserService { userRoleExample.createCriteria().andUserIdEqualTo(userId).andSourceIdEqualTo(request.getWorkspaceId()); List userRoles = userRoleMapper.selectByExample(userRoleExample); if (userRoles.size() > 0) { - User user = userMapper.selectByPrimaryKey(userId); - String username = user.getName(); MSException.throwException(Translator.get("user_already_exists")); } else { for (String roleId : request.getRoleIds()) { @@ -274,8 +272,6 @@ public class UserService { userRoleExample.createCriteria().andUserIdEqualTo(userId).andSourceIdEqualTo(request.getOrganizationId()); List userRoles = userRoleMapper.selectByExample(userRoleExample); if (userRoles.size() > 0) { - User user = userMapper.selectByPrimaryKey(userId); - String username = user.getName(); MSException.throwException(Translator.get("user_already_exists")); } else { for (String roleId : request.getRoleIds()) { diff --git a/frontend/src/business/components/settings/system/User.vue b/frontend/src/business/components/settings/system/User.vue index 51fe7b70bf..ea5e70ced2 100644 --- a/frontend/src/business/components/settings/system/User.vue +++ b/frontend/src/business/components/settings/system/User.vue @@ -489,7 +489,7 @@ this.btnAddRole = false; }, changeSwitch(row) { - this.$post(this.updatePath, row, () => { + this.$post('/user/special/update_status', row, () => { this.$success(this.$t('commons.modify_success')); }) }, From 37de2c2c4eb048f6758e1f16c31521a4530d1fc0 Mon Sep 17 00:00:00 2001 From: shiziyuan9527 Date: Wed, 27 May 2020 14:45:06 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E6=9D=83=E9=99=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/io/metersphere/controller/UserController.java | 1 + 1 file changed, 1 insertion(+) diff --git a/backend/src/main/java/io/metersphere/controller/UserController.java b/backend/src/main/java/io/metersphere/controller/UserController.java index 50b1a34bc4..9a724fc608 100644 --- a/backend/src/main/java/io/metersphere/controller/UserController.java +++ b/backend/src/main/java/io/metersphere/controller/UserController.java @@ -70,6 +70,7 @@ public class UserController { } @PostMapping("/special/update_status") + @RequiresRoles(RoleConstants.ADMIN) public void updateStatus(@RequestBody User user) { userService.updateUser(user); }