优化用户修改

This commit is contained in:
石皮幼鸟 2024-04-11 19:56:27 +08:00
parent caf990dbff
commit 494235ffb5
1 changed files with 3 additions and 3 deletions

View File

@ -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());