Browse Source

优化userInfo接口

test
smallchill 5 years ago
parent
commit
713980a356
  1. 8
      blade-service/blade-user/src/main/java/org/springblade/system/user/service/IUserService.java
  2. 16
      blade-service/blade-user/src/main/java/org/springblade/system/user/service/impl/UserServiceImpl.java

8
blade-service/blade-user/src/main/java/org/springblade/system/user/service/IUserService.java

@ -69,6 +69,14 @@ public interface IUserService extends BaseService<User> {
*/
IPage<User> selectUserPage(IPage<User> page, User user, Long deptId, String tenantId);
/**
* 用户信息
*
* @param userId
* @return
*/
UserInfo userInfo(Long userId);
/**
* 用户信息
*

16
blade-service/blade-user/src/main/java/org/springblade/system/user/service/impl/UserServiceImpl.java

@ -141,16 +141,25 @@ public class UserServiceImpl extends BaseServiceImpl<UserMapper, User> implement
List<Long> 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.<User>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<List<String>> result = sysClient.getRoleAliases(user.getRoleId());
@ -168,8 +177,7 @@ public class UserServiceImpl extends BaseServiceImpl<UserMapper, User> implement
UserOauth uo = userOauthService.getOne(Wrappers.<UserOauth>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();

Loading…
Cancel
Save