diff --git a/src/main/java/com/example/catchTheLetters/service/impl/AuthServiceImpl.java b/src/main/java/com/example/catchTheLetters/service/impl/AuthServiceImpl.java index 32ebb7a..aa8a149 100644 --- a/src/main/java/com/example/catchTheLetters/service/impl/AuthServiceImpl.java +++ b/src/main/java/com/example/catchTheLetters/service/impl/AuthServiceImpl.java @@ -161,7 +161,7 @@ public class AuthServiceImpl implements AuthService { } // 如果用户名修改了,检查是否有重复,有重复则返回null,否则修改 - if (!verify.getUsername().equals(user.getUsername())) { + if (user.getUsername() != null && !verify.getUsername().equals(user.getUsername())) { var regedUser = getUserByName(user.getUsername()); if (regedUser != null) { return R.fail(HttpStatus.USERNAME_CONFLICT.getCode(), HttpStatus.USERNAME_CONFLICT.getDesc()); @@ -171,7 +171,7 @@ public class AuthServiceImpl implements AuthService { } // 如果邮箱修改了,检查是否有重复,有重复则返回null,否则修改 - if (!verify.getEmail().equals(user.getEmail())) { + if (user.getEmail() != null && !verify.getEmail().equals(user.getEmail())) { var regedUser = mongoTemplate.findOne(new Query(Criteria.where("email").is(user.getEmail()).and(CommonConstant.STATUS).ne(0)), User.class); if (regedUser != null) { return R.fail(HttpStatus.USERNAME_CONFLICT.getCode(), HttpStatus.USERNAME_CONFLICT.getDesc()); @@ -181,7 +181,7 @@ public class AuthServiceImpl implements AuthService { } // 如果手机号修改了,检查是否有重复,有重复则返回null,否则修改 - if (!verify.getPhone().equals(user.getPhone())) { + if (user.getPhone() != null && !verify.getPhone().equals(user.getPhone())) { var regedUser = mongoTemplate.findOne(new Query(Criteria.where("phone").is(user.getPhone()).and(CommonConstant.STATUS).ne(0)), User.class); if (regedUser != null) { return R.fail(HttpStatus.USERNAME_CONFLICT.getCode(), HttpStatus.USERNAME_CONFLICT.getDesc());