Commit 2a4c8e1e by 丁伟峰

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

2 parents c991694e b78b3d3c
...@@ -90,6 +90,15 @@ public class UserService { ...@@ -90,6 +90,15 @@ public class UserService {
long timestamp = System.currentTimeMillis() + LIVE_TIME_MILLIS; long timestamp = System.currentTimeMillis() + LIVE_TIME_MILLIS;
redisService.set(RedisKeyGroup.authToken + ":" + uuid, user, timestamp); 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); UserLoginDTO userDTO = BeanUtil.copyProperties(user, UserLoginDTO.class);
// 获取角色 // 获取角色
List<UserRoleEntity> userRoles = userRoleDao.findByUserId(user.getId()); List<UserRoleEntity> userRoles = userRoleDao.findByUserId(user.getId());
...@@ -102,6 +111,7 @@ public class UserService { ...@@ -102,6 +111,7 @@ public class UserService {
// 获取资源 // 获取资源
List<RoleResourceEntity> roleResources = roleResourceDao.findByRoleIdIn(ids); List<RoleResourceEntity> roleResources = roleResourceDao.findByRoleIdIn(ids);
log.info("role size:{} roleResources:{}", ids.size(), CollectionUtils.isNotEmpty(roleResources));
if (CollectionUtils.isNotEmpty(roleResources)) { if (CollectionUtils.isNotEmpty(roleResources)) {
List<String> resourceIds = roleResources.stream().map(r -> r.getResourceId()) List<String> resourceIds = roleResources.stream().map(r -> r.getResourceId())
.collect(Collectors.toList()); .collect(Collectors.toList());
...@@ -111,16 +121,14 @@ public class UserService { ...@@ -111,16 +121,14 @@ public class UserService {
} }
} }
userDTO.setToken(uuid); return userDTO;
return Result.success(userDTO);
} else {
return Result.failed("鉴权失败");
}
} }
public Result<?> getUserInfo(String token) { public Result<?> getUserInfo(String token) {
UserEntity user = (UserEntity) redisService.get(RedisKeyGroup.authToken + ":" + 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) { 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!