fix(系统设置): 修复修改个人信息邮箱时可修改为已存在邮箱的问题

This commit is contained in:
shiziyuan9527 2020-11-23 16:44:02 +08:00
parent ea3895d315
commit ab0f3535f8
1 changed files with 11 additions and 0 deletions

View File

@ -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);
// 禁用用户之后剔除在线用户