diff --git a/blade-service/blade-user/src/main/java/org/springblade/system/user/service/IUserService.java b/blade-service/blade-user/src/main/java/org/springblade/system/user/service/IUserService.java index 9770458a..bf8b15fb 100644 --- a/blade-service/blade-user/src/main/java/org/springblade/system/user/service/IUserService.java +++ b/blade-service/blade-user/src/main/java/org/springblade/system/user/service/IUserService.java @@ -69,6 +69,14 @@ public interface IUserService extends BaseService { */ IPage selectUserPage(IPage page, User user, Long deptId, String tenantId); + /** + * 用户信息 + * + * @param userId + * @return + */ + UserInfo userInfo(Long userId); + /** * 用户信息 * diff --git a/blade-service/blade-user/src/main/java/org/springblade/system/user/service/impl/UserServiceImpl.java b/blade-service/blade-user/src/main/java/org/springblade/system/user/service/impl/UserServiceImpl.java index ab4635b7..45c671c5 100644 --- a/blade-service/blade-user/src/main/java/org/springblade/system/user/service/impl/UserServiceImpl.java +++ b/blade-service/blade-user/src/main/java/org/springblade/system/user/service/impl/UserServiceImpl.java @@ -141,16 +141,25 @@ public class UserServiceImpl extends BaseServiceImpl implement List deptIdList = SysCache.getDeptChildIds(deptId); return page.setRecords(baseMapper.selectUserPage(page, user, deptIdList, tenantId)); } - @Override public User userByAccount(String tenantId, String account) { return baseMapper.selectOne(Wrappers.query().lambda().eq(User::getTenantId, tenantId).eq(User::getAccount, account).eq(User::getIsDeleted, BladeConstant.DB_NOT_DELETED)); } + @Override + public UserInfo userInfo(Long userId) { + User user = baseMapper.selectById(userId); + return buildUserInfo(user); + } + @Override public UserInfo userInfo(String tenantId, String account) { - UserInfo userInfo = new UserInfo(); User user = baseMapper.getUser(tenantId, account); + return buildUserInfo(user); + } + + private UserInfo buildUserInfo(User user) { + UserInfo userInfo = new UserInfo(); userInfo.setUser(user); if (Func.isNotEmpty(user)) { R> result = sysClient.getRoleAliases(user.getRoleId()); @@ -168,8 +177,7 @@ public class UserServiceImpl extends BaseServiceImpl implement UserOauth uo = userOauthService.getOne(Wrappers.query().lambda().eq(UserOauth::getSource, userOauth.getSource()).eq(UserOauth::getUsername, userOauth.getUsername())); UserInfo userInfo; if (Func.isNotEmpty(uo) && Func.isNotEmpty(uo.getUserId())) { - User user = UserCache.getUser(uo.getUserId()); - userInfo = this.userInfo(user.getTenantId(), user.getAccount()); + userInfo = this.userInfo(uo.getUserId()); userInfo.setOauthId(Func.toStr(uo.getId())); } else { userInfo = new UserInfo();