mirror of https://gitee.com/stylefeng/roses
在线用户列表
parent
7fce5793ac
commit
34e7c3f026
|
@ -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();
|
||||
|
||||
}
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
|
||||
}
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取系统用户
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue