用户管理:已有认证密码账户不允许修改手机号账号

This commit is contained in:
gaoqr
2025-03-10 16:10:47 +08:00
parent 0f5c00281c
commit 9e2e91eca1
3 changed files with 8 additions and 7 deletions
@@ -171,7 +171,7 @@ public interface AdminUserMapper extends BaseMapperX<AdminUserDO> {
* @param id
* @return
*/
@Select("SELECT username FROM system_users WHERE id = #{id} FOR UPDATE")
@Select("SELECT username, password FROM system_users WHERE id = #{id} FOR UPDATE")
AdminUserDO selectByIdForUpdate(@Param("id") Long id);
/**
@@ -78,6 +78,7 @@ import static com.cf.imes.framework.common.util.collection.CollectionUtils.conve
import static com.cf.imes.framework.common.util.collection.CollectionUtils.convertSet;
import static com.cf.imes.module.system.dal.redis.RedisKeyConstants.OAUTH2_ACCESS_TOKEN;
import static com.cf.imes.module.system.enums.ErrorCodeConstants.USER_ME_ERROR;
import static com.cf.imes.module.system.enums.ErrorCodeConstants.USER_MOBILE_UPDATE_NOT_ALLOW_ERROR;
import static com.cf.imes.module.system.enums.ErrorCodeConstants.USER_OPERATE_SELF_STATUS_ERROR;
/**
@@ -200,11 +201,11 @@ public class AdminUserServiceImpl implements AdminUserService {
Long id = updateObj.getId();
if (ObjectUtil.isNotNull(id)) {
AdminUserDO adminUserDO = userMapper.selectByIdForUpdate(id);
// 当手机号(账号)发生改变时,清空密码
if (ObjectUtil.isNotNull(adminUserDO) && !Objects.equals(adminUserDO.getUsername(), mobile)) {
// 清空密码
updateObj.setPassword("");
updateObj.setUsername(mobile);
// 当手机号(账号)发生改变时,只允许密码为空的通过(还没有使用验证码来设置过密码
if (ObjectUtil.isNotNull(adminUserDO) && !StringUtils.equals(adminUserDO.getUsername(), mobile)) {
if(StringUtils.isNotEmpty(adminUserDO.getPassword())) {
throw ServiceExceptionUtil.exception(USER_MOBILE_UPDATE_NOT_ALLOW_ERROR);
}
}
}
userMapper.updateById(updateObj);