From 1db6530e00453fb69ea5590635e305b0f50a0c75 Mon Sep 17 00:00:00 2001 From: Zzm0809 <934230207@qq.com> Date: Tue, 30 Jan 2024 13:23:55 +0800 Subject: [PATCH] fix npe --- .../java/org/dinky/service/impl/UserServiceImpl.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/dinky-admin/src/main/java/org/dinky/service/impl/UserServiceImpl.java b/dinky-admin/src/main/java/org/dinky/service/impl/UserServiceImpl.java index 0983bbb01f..23b562ebf4 100644 --- a/dinky-admin/src/main/java/org/dinky/service/impl/UserServiceImpl.java +++ b/dinky-admin/src/main/java/org/dinky/service/impl/UserServiceImpl.java @@ -75,6 +75,7 @@ import cn.hutool.core.util.RandomUtil; import cn.hutool.core.util.StrUtil; import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; /** * UserServiceImpl @@ -83,6 +84,7 @@ */ @Service @RequiredArgsConstructor +@Slf4j public class UserServiceImpl extends SuperServiceImpl implements UserService { private static final String DEFAULT_PASSWORD = "123456"; @@ -464,8 +466,14 @@ public List getUserListByTenantId(int id) { userTenantService.list(new LambdaQueryWrapper().eq(UserTenant::getTenantId, id)); userTenants.forEach(userTenant -> { User user = getById(userTenant.getUserId()); - user.setTenantAdminFlag(userTenant.getTenantAdminFlag()); - userList.add(user); + if (!Asserts.isNull(user)) { + user.setTenantAdminFlag(userTenant.getTenantAdminFlag()); + userList.add(user); + } else { + log.error( + "Unable to obtain user information, the user may have been deleted, please contact the administrator to verify, userId:[{}]", + userTenant.getUserId()); + } }); return userList; }