diff --git a/backend/src/main/java/io/metersphere/controller/UserController.java b/backend/src/main/java/io/metersphere/controller/UserController.java index 5338a0ef39..8c38b04282 100644 --- a/backend/src/main/java/io/metersphere/controller/UserController.java +++ b/backend/src/main/java/io/metersphere/controller/UserController.java @@ -118,10 +118,8 @@ public class UserController { return userService.getUserList(); } - @PostMapping("/update/currentuser") + @PostMapping("/update/current") public UserDTO updateCurrentUser(@RequestBody User user) { - SessionUser sessionUser = SessionUtils.getUser(); - BeanUtils.copyProperties(user, sessionUser); userService.updateUser(user); return SessionUtils.getUser(); } diff --git a/backend/src/main/java/io/metersphere/excel/listener/TestCaseDataListener.java b/backend/src/main/java/io/metersphere/excel/listener/TestCaseDataListener.java index 6f37017e3d..b400c1fe07 100644 --- a/backend/src/main/java/io/metersphere/excel/listener/TestCaseDataListener.java +++ b/backend/src/main/java/io/metersphere/excel/listener/TestCaseDataListener.java @@ -7,7 +7,9 @@ import io.metersphere.base.domain.TestCaseWithBLOBs; import io.metersphere.commons.constants.TestCaseConstants; import io.metersphere.commons.utils.BeanUtils; import io.metersphere.service.TestCaseService; +import org.apache.commons.lang3.StringUtils; +import java.util.Arrays; import java.util.List; import java.util.Set; import java.util.UUID; @@ -38,12 +40,19 @@ public class TestCaseDataListener extends EasyExcelListener { public String validate(TestCaseExcelData data, String errMsg) { String nodePath = data.getNodePath(); StringBuilder stringBuilder = new StringBuilder(errMsg); - if ( nodePath.split("/").length > TestCaseConstants.MAX_NODE_DEPTH + 1) { + String[] nodes = nodePath.split("/"); + + if ( nodes.length > TestCaseConstants.MAX_NODE_DEPTH + 1) { stringBuilder.append("节点最多为" + TestCaseConstants.MAX_NODE_DEPTH + "层;"); } - if ( nodePath.trim().contains(" ")) { - stringBuilder.append("所属模块不能包含空格"); + + for (int i = 0; i < nodes.length; i++) { + if (i != 0 && StringUtils.equals(nodes[i].trim(), "")) { + stringBuilder.append("所属模块不能为空格"); + break; + } } + if (!userIds.contains(data.getMaintainer())) { stringBuilder.append("该工作空间下无该用户:" + data.getMaintainer() + ";"); } diff --git a/backend/src/main/java/io/metersphere/service/UserService.java b/backend/src/main/java/io/metersphere/service/UserService.java index acb0dcc975..448de856fc 100644 --- a/backend/src/main/java/io/metersphere/service/UserService.java +++ b/backend/src/main/java/io/metersphere/service/UserService.java @@ -124,6 +124,9 @@ public class UserService { } public void updateUser(User user) { + UserDTO userDTO = getUserDTO(user.getId()); + BeanUtils.copyProperties(user, userDTO); + SessionUtils.putUser(SessionUser.fromUser(userDTO)); user.setUpdateTime(System.currentTimeMillis()); userMapper.updateByPrimaryKeySelective(user); } diff --git a/frontend/src/business/components/settings/personal/PersonSetting.vue b/frontend/src/business/components/settings/personal/PersonSetting.vue index dc2c78823c..049670d38c 100644 --- a/frontend/src/business/components/settings/personal/PersonSetting.vue +++ b/frontend/src/business/components/settings/personal/PersonSetting.vue @@ -68,7 +68,7 @@ result: {}, updateVisible: false, tableData: [], - updatePath: '/user/update/currentuser', + updatePath: '/user/update/current', form: {}, rule: { name: [ diff --git a/frontend/src/business/components/track/case/components/TestCaseEdit.vue b/frontend/src/business/components/track/case/components/TestCaseEdit.vue index 4f969158f9..acdc85bebc 100644 --- a/frontend/src/business/components/track/case/components/TestCaseEdit.vue +++ b/frontend/src/business/components/track/case/components/TestCaseEdit.vue @@ -13,7 +13,7 @@ :label="$t('test_track.case.name')" :label-width="formLabelWidth" prop="name"> - + @@ -313,6 +313,11 @@ if(localStorage.getItem(CURRENT_PROJECT)) { param.projectId = JSON.parse(localStorage.getItem(CURRENT_PROJECT)).id; } + param.name = param.name.trim(); + if (param.name == '') { + this.$warning(this.$t('test_track.case.input_name')); + return; + } this.$post('/test/case/' + this.operationType, param, () => { this.$success(this.$t('commons.save_success')); this.dialogFormVisible = false; diff --git a/frontend/src/business/components/track/case/components/TestCaseMove.vue b/frontend/src/business/components/track/case/components/TestCaseMove.vue index 0240d2f6b3..8f1e6ef5bb 100644 --- a/frontend/src/business/components/track/case/components/TestCaseMove.vue +++ b/frontend/src/business/components/track/case/components/TestCaseMove.vue @@ -5,7 +5,7 @@ :before-close="close" width="20%"> - { this.$success(this.$t('commons.save_success')); diff --git a/frontend/src/business/components/track/common/NodeEdit.vue b/frontend/src/business/components/track/common/NodeEdit.vue index 46e4bd8f24..988282824d 100644 --- a/frontend/src/business/components/track/common/NodeEdit.vue +++ b/frontend/src/business/components/track/common/NodeEdit.vue @@ -12,7 +12,7 @@ :label="$t('test_track.module.name')" :label-width="formLabelWidth" prop="name"> - + @@ -69,7 +69,10 @@ if (valid) { let param = {}; let url = this.buildParam(param); - + if (param.name.trim() == '') { + this.$warning(this.$t('test_track.case.input_name')); + return; + } this.$post(url, param, () => { this.$success(this.$t('commons.save_success')); this.$emit('refresh'); @@ -95,7 +98,7 @@ param.id = this.node.id; param.level = this.node.level; } - param.name = this.form.name; + param.name = this.form.name.trim(); param.label = this.form.name; if (localStorage.getItem(CURRENT_PROJECT)) { param.projectId = JSON.parse(localStorage.getItem(CURRENT_PROJECT)).id; diff --git a/frontend/src/business/components/track/plan/components/TestPlanEdit.vue b/frontend/src/business/components/track/plan/components/TestPlanEdit.vue index c2322c567c..dfeb4cd842 100644 --- a/frontend/src/business/components/track/plan/components/TestPlanEdit.vue +++ b/frontend/src/business/components/track/plan/components/TestPlanEdit.vue @@ -15,7 +15,7 @@ :label="$t('test_track.plan.plan_name')" :label-width="formLabelWidth" prop="name"> - + @@ -149,6 +149,11 @@ if (valid) { let param = {}; Object.assign(param, this.form); + param.name = param.name.trim(); + if (param.name == '') { + this.$warning(this.$t('test_track.plan.input_plan_name')); + return; + } param.workspaceId = localStorage.getItem(WORKSPACE_ID); this.$post('/test/plan/' + this.operationType, param, () => { this.$success(this.$t('commons.save_success'));