From ab0f3535f80c5ef17bfb99c158f7c0d02722f44a Mon Sep 17 00:00:00 2001 From: shiziyuan9527 Date: Mon, 23 Nov 2020 16:44:02 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E7=B3=BB=E7=BB=9F=E8=AE=BE=E7=BD=AE):=20?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=BF=AE=E6=94=B9=E4=B8=AA=E4=BA=BA=E4=BF=A1?= =?UTF-8?q?=E6=81=AF=E9=82=AE=E7=AE=B1=E6=97=B6=E5=8F=AF=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E4=B8=BA=E5=B7=B2=E5=AD=98=E5=9C=A8=E9=82=AE=E7=AE=B1=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/io/metersphere/service/UserService.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/backend/src/main/java/io/metersphere/service/UserService.java b/backend/src/main/java/io/metersphere/service/UserService.java index 6a20ed42c3..ebb1c99ead 100644 --- a/backend/src/main/java/io/metersphere/service/UserService.java +++ b/backend/src/main/java/io/metersphere/service/UserService.java @@ -318,6 +318,17 @@ public class UserService { } public void updateUser(User user) { + // todo 提取重复代码 + if (StringUtils.isNotBlank(user.getEmail())) { + UserExample example = new UserExample(); + UserExample.Criteria criteria = example.createCriteria(); + criteria.andEmailEqualTo(user.getEmail()); + criteria.andIdNotEqualTo(user.getId()); + if (userMapper.countByExample(example) > 0) { + MSException.throwException(Translator.get("user_email_already_exists")); + } + } + user.setUpdateTime(System.currentTimeMillis()); userMapper.updateByPrimaryKeySelective(user); // 禁用用户之后,剔除在线用户