Commit 2a4c8e1e by 丁伟峰

Merge remote-tracking branch 'origin/develop' into develop

2 parents c991694e b78b3d3c
......@@ -90,6 +90,15 @@ public class UserService {
long timestamp = System.currentTimeMillis() + LIVE_TIME_MILLIS;
redisService.set(RedisKeyGroup.authToken + ":" + uuid, user, timestamp);
UserLoginDTO userDTO = convertToUserLoginDTO(user);
userDTO.setToken(uuid);
return Result.success(userDTO);
} else {
return Result.failed("鉴权失败");
}
}
private UserLoginDTO convertToUserLoginDTO(UserEntity user) {
UserLoginDTO userDTO = BeanUtil.copyProperties(user, UserLoginDTO.class);
// 获取角色
List<UserRoleEntity> userRoles = userRoleDao.findByUserId(user.getId());
......@@ -102,6 +111,7 @@ public class UserService {
// 获取资源
List<RoleResourceEntity> roleResources = roleResourceDao.findByRoleIdIn(ids);
log.info("role size:{} roleResources:{}", ids.size(), CollectionUtils.isNotEmpty(roleResources));
if (CollectionUtils.isNotEmpty(roleResources)) {
List<String> resourceIds = roleResources.stream().map(r -> r.getResourceId())
.collect(Collectors.toList());
......@@ -111,16 +121,14 @@ public class UserService {
}
}
userDTO.setToken(uuid);
return Result.success(userDTO);
} else {
return Result.failed("鉴权失败");
}
return userDTO;
}
public Result<?> getUserInfo(String token) {
UserEntity user = (UserEntity) redisService.get(RedisKeyGroup.authToken + ":" + token);
return Result.success(user);
UserLoginDTO userDTO = convertToUserLoginDTO(user);
userDTO.setToken(token);
return Result.success(userDTO);
}
public String getUserName(String userId) {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!