在线用户列表

pull/3/head
peihongwei 2021-01-05 18:09:39 +08:00 committed by fengshuonan
parent 7fce5793ac
commit 34e7c3f026
5 changed files with 42 additions and 0 deletions

View File

@ -2,6 +2,8 @@ package cn.stylefeng.roses.kernel.auth.api;
import cn.stylefeng.roses.kernel.auth.api.pojo.login.LoginUser;
import java.util.List;
/**
*
* <p>
@ -83,4 +85,10 @@ public interface SessionManagerApi {
*/
void destroySessionCookie();
/**
* 线
* @return
*/
List<LoginUser> onlineUserList();
}

View File

@ -10,7 +10,10 @@ import cn.stylefeng.roses.kernel.rule.util.HttpServletUtil;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
/**
@ -166,4 +169,8 @@ public class DefaultSessionManager implements SessionManagerApi {
}
}
@Override
public List<LoginUser> onlineUserList() {
return new ArrayList<>(loginUserCache.getAllValues());
}
}

View File

@ -1,5 +1,6 @@
package cn.stylefeng.roses.kernel.system;
import cn.stylefeng.roses.kernel.auth.api.pojo.login.LoginUser;
import cn.stylefeng.roses.kernel.system.pojo.user.UserLoginInfoDTO;
import java.util.Date;
@ -73,4 +74,10 @@ public interface UserServiceApi {
*/
List<Long> getUserBindDataScope(Long userId);
/**
* 线
* @return
*/
List<LoginUser> onlineUserList();
}

View File

@ -240,4 +240,15 @@ public class SysUserController {
return new SuccessResponseData(sysUserService.detail(sysUserRequest));
}
/**
* 线
*
* @author fengshuonan
* @date 2021/1/1 19:01
*/
@GetResource(name = "当前在线用户列表", path = "/sysUser/onlineUserList", requiredPermission = false)
public ResponseData onlineUserList() {
return new SuccessResponseData(sysUserService.onlineUserList());
}
}

View File

@ -2,6 +2,7 @@ package cn.stylefeng.roses.kernel.system.modular.user.service.impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.stylefeng.roses.kernel.auth.api.SessionManagerApi;
import cn.stylefeng.roses.kernel.auth.api.context.LoginContext;
import cn.stylefeng.roses.kernel.auth.api.expander.AuthConfigExpander;
import cn.stylefeng.roses.kernel.auth.api.password.PasswordStoredEncryptApi;
@ -91,6 +92,9 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
@Resource
private PasswordStoredEncryptApi passwordStoredEncryptApi;
@Resource
private SessionManagerApi sessionManagerApi;
@Override
@Transactional(rollbackFor = Exception.class)
public void add(SysUserRequest sysUserRequest) {
@ -451,6 +455,11 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
return sysUserDataScopeService.getUserDataScopeIdList(userId);
}
@Override
public List<LoginUser> onlineUserList() {
return sessionManagerApi.onlineUserList();
}
/**
*
*