在线用户修改
This commit is contained in:
parent
7bd6cf497e
commit
6683780144
|
|
@ -5,6 +5,7 @@ import java.util.Collection;
|
|||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.bonus.common.annotation.RequiresPermissions;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
|
|
@ -45,7 +46,16 @@ public class SysUserOnlineController extends BaseController {
|
|||
Collection<String> keys = redisCache.keys(CacheConstants.LOGIN_TOKEN_KEY + "*");
|
||||
List<SysUserOnline> userOnlineList = new ArrayList<SysUserOnline>();
|
||||
for (String key : keys) {
|
||||
LoginUser user = redisCache.getCacheObject(key);
|
||||
LoginUser user = null;
|
||||
Object cacheObject = redisCache.getCacheObject(key);
|
||||
if (cacheObject instanceof JSONObject) {
|
||||
user = ((JSONObject) cacheObject).toJavaObject(LoginUser.class);
|
||||
} else if (cacheObject instanceof LoginUser) {
|
||||
user = (LoginUser) cacheObject;
|
||||
} else {
|
||||
// 处理其他情况或抛出异常
|
||||
throw new RuntimeException("缓存对象类型不匹配");
|
||||
}
|
||||
if (StringUtils.isNotEmpty(ipaddr) && StringUtils.isNotEmpty(userName)) {
|
||||
userOnlineList.add(userOnlineService.selectOnlineByInfo(ipaddr, userName, user));
|
||||
} else if (StringUtils.isNotEmpty(ipaddr)) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue