优化用户修改

This commit is contained in:
石皮幼鸟 2024-04-11 20:02:31 +08:00
parent 494235ffb5
commit 839413d2e2
1 changed files with 3 additions and 3 deletions

View File

@ -161,7 +161,7 @@ public class AuthServiceImpl implements AuthService {
} }
// 如果用户名修改了检查是否有重复有重复则返回null否则修改 // 如果用户名修改了检查是否有重复有重复则返回null否则修改
if (user.getUsername() != null && !verify.getUsername().equals(user.getUsername())) { if (user.getUsername() != null && (verify.getUsername() == null || !verify.getUsername().equals(user.getUsername()))) {
var regedUser = getUserByName(user.getUsername()); var regedUser = getUserByName(user.getUsername());
if (regedUser != null) { if (regedUser != null) {
return R.fail(HttpStatus.USERNAME_CONFLICT.getCode(), HttpStatus.USERNAME_CONFLICT.getDesc()); return R.fail(HttpStatus.USERNAME_CONFLICT.getCode(), HttpStatus.USERNAME_CONFLICT.getDesc());
@ -171,7 +171,7 @@ public class AuthServiceImpl implements AuthService {
} }
// 如果邮箱修改了检查是否有重复有重复则返回null否则修改 // 如果邮箱修改了检查是否有重复有重复则返回null否则修改
if (user.getEmail() != null && !verify.getEmail().equals(user.getEmail())) { if (user.getEmail() != null && (verify.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); var regedUser = mongoTemplate.findOne(new Query(Criteria.where("email").is(user.getEmail()).and(CommonConstant.STATUS).ne(0)), User.class);
if (regedUser != null) { if (regedUser != null) {
return R.fail(HttpStatus.USERNAME_CONFLICT.getCode(), HttpStatus.USERNAME_CONFLICT.getDesc()); return R.fail(HttpStatus.USERNAME_CONFLICT.getCode(), HttpStatus.USERNAME_CONFLICT.getDesc());
@ -181,7 +181,7 @@ public class AuthServiceImpl implements AuthService {
} }
// 如果手机号修改了检查是否有重复有重复则返回null否则修改 // 如果手机号修改了检查是否有重复有重复则返回null否则修改
if (user.getPhone() != null && !verify.getPhone().equals(user.getPhone())) { if (user.getPhone() != null && (verify.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); var regedUser = mongoTemplate.findOne(new Query(Criteria.where("phone").is(user.getPhone()).and(CommonConstant.STATUS).ne(0)), User.class);
if (regedUser != null) { if (regedUser != null) {
return R.fail(HttpStatus.USERNAME_CONFLICT.getCode(), HttpStatus.USERNAME_CONFLICT.getDesc()); return R.fail(HttpStatus.USERNAME_CONFLICT.getCode(), HttpStatus.USERNAME_CONFLICT.getDesc());