mirror of https://gitee.com/stylefeng/roses
Merge branch 'master' of https://git.stylefeng.cn/guns-technology/roses-kernel
commit
3c25754381
|
@ -46,4 +46,22 @@ public enum SexEnum {
|
|||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 编码转化成中文含义
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @date 2021/1/11 22:34
|
||||
*/
|
||||
public static String codeToMessage(String code) {
|
||||
if (null != code) {
|
||||
for (SexEnum e : SexEnum.values()) {
|
||||
if (e.getCode().equals(code)) {
|
||||
return e.getMessage();
|
||||
}
|
||||
}
|
||||
}
|
||||
return "未知";
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
package cn.stylefeng.roses.kernel.rule.util;
|
||||
|
||||
import java.net.InetAddress;
|
||||
import java.net.UnknownHostException;
|
||||
|
||||
/**
|
||||
* IP工具类
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @date 2021/1/10 14:25
|
||||
*/
|
||||
public class IpInfoUtils {
|
||||
|
||||
/**
|
||||
* 获取当前机器的hostname
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @date 2021/1/10 18:40
|
||||
*/
|
||||
public static String getHostName() {
|
||||
try {
|
||||
return InetAddress.getLocalHost().getHostName();
|
||||
} catch (UnknownHostException ignored) {
|
||||
return "未知";
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -7,6 +7,7 @@ import cn.stylefeng.roses.kernel.auth.api.pojo.login.basic.SimpleUserInfo;
|
|||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
|
@ -73,6 +74,16 @@ public class LoginUser implements Serializable {
|
|||
*/
|
||||
private Set<String> buttonCodes;
|
||||
|
||||
/**
|
||||
* 登录的时间
|
||||
*/
|
||||
private Date loginTime;
|
||||
|
||||
/**
|
||||
* 用户的token,当返回用户会话信息时候回带token
|
||||
*/
|
||||
private String token;
|
||||
|
||||
/**
|
||||
* 其他信息,Dict为Map的拓展
|
||||
*/
|
||||
|
|
|
@ -10,10 +10,7 @@ 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.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 基于redis的会话管理
|
||||
|
@ -182,7 +179,17 @@ public class DefaultSessionManager implements SessionManagerApi {
|
|||
|
||||
@Override
|
||||
public List<LoginUser> onlineUserList() {
|
||||
return new ArrayList<>(loginUserCache.getAllValues());
|
||||
Map<String, LoginUser> allKeyValues = loginUserCache.getAllKeyValues();
|
||||
|
||||
ArrayList<LoginUser> loginUsers = new ArrayList<>();
|
||||
for (Map.Entry<String, LoginUser> userEntry : allKeyValues.entrySet()) {
|
||||
String token = userEntry.getKey();
|
||||
LoginUser loginUser = userEntry.getValue();
|
||||
loginUser.setToken(token);
|
||||
loginUsers.add(loginUser);
|
||||
}
|
||||
|
||||
return loginUsers;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -1,9 +1,10 @@
|
|||
package cn.stylefeng.roses.kernel.system;
|
||||
|
||||
import cn.stylefeng.roses.kernel.system.pojo.user.OnlineUserResponse;
|
||||
import cn.stylefeng.roses.kernel.system.pojo.user.SysUserDTO;
|
||||
import cn.stylefeng.roses.kernel.auth.api.pojo.login.LoginUser;
|
||||
import cn.stylefeng.roses.kernel.system.pojo.user.SysUserResponse;
|
||||
import cn.stylefeng.roses.kernel.system.pojo.user.UserLoginInfoDTO;
|
||||
import cn.stylefeng.roses.kernel.system.pojo.user.request.OnlineUserRequest;
|
||||
import cn.stylefeng.roses.kernel.system.pojo.user.request.SysUserRequest;
|
||||
|
||||
import java.util.Date;
|
||||
|
@ -83,7 +84,7 @@ public interface UserServiceApi {
|
|||
* @author fengshuonan
|
||||
* @date 2021/1/10 9:56
|
||||
*/
|
||||
List<LoginUser> onlineUserList();
|
||||
List<OnlineUserResponse> onlineUserList(OnlineUserRequest onlineUserRequest);
|
||||
|
||||
/**
|
||||
* 根据用户ID获取用户信息
|
||||
|
@ -104,8 +105,6 @@ public interface UserServiceApi {
|
|||
*/
|
||||
List<Long> queryAllUserIdList(SysUserRequest sysUserRequest);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 获取用户信息
|
||||
*
|
||||
|
|
|
@ -1,7 +1,10 @@
|
|||
package cn.stylefeng.roses.kernel.system.pojo.menu.layui;
|
||||
|
||||
import cn.stylefeng.roses.kernel.rule.abstracts.AbstractTreeNode;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 角色分配资源和菜单的树
|
||||
*
|
||||
|
@ -9,7 +12,7 @@ import lombok.Data;
|
|||
* @date 2021/1/9 16:59
|
||||
*/
|
||||
@Data
|
||||
public class LayuiMenuAndButtonTreeResponse {
|
||||
public class LayuiMenuAndButtonTreeResponse implements AbstractTreeNode {
|
||||
|
||||
/**
|
||||
* 节点ID
|
||||
|
@ -41,4 +44,23 @@ public class LayuiMenuAndButtonTreeResponse {
|
|||
*/
|
||||
private String buttonCode;
|
||||
|
||||
/**
|
||||
* 子节点集合
|
||||
*/
|
||||
private List children;
|
||||
|
||||
@Override
|
||||
public String getNodeId() {
|
||||
return this.id.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNodeParentId() {
|
||||
return this.pid.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setChildrenNodes(List childrenNodes) {
|
||||
this.children = childrenNodes;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,57 @@
|
|||
package cn.stylefeng.roses.kernel.system.pojo.user;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
|
||||
/**
|
||||
* 当前的在线用户的信息封装
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @date 2021/1/11 22:30
|
||||
*/
|
||||
@Data
|
||||
public class OnlineUserResponse {
|
||||
|
||||
/**
|
||||
* 用户的token
|
||||
*/
|
||||
private String token;
|
||||
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
private Long userId;
|
||||
|
||||
/**
|
||||
* 账号
|
||||
*/
|
||||
private String account;
|
||||
|
||||
/**
|
||||
* 昵称
|
||||
*/
|
||||
private String nickName;
|
||||
|
||||
/**
|
||||
* 姓名
|
||||
*/
|
||||
private String realName;
|
||||
|
||||
/**
|
||||
* 性别
|
||||
*/
|
||||
private String sex;
|
||||
|
||||
/**
|
||||
* 角色名称
|
||||
*/
|
||||
private String roleName;
|
||||
|
||||
/**
|
||||
* 登录的时间
|
||||
*/
|
||||
private Date loginTime;
|
||||
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
package cn.stylefeng.roses.kernel.system.pojo.user.request;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
|
||||
|
||||
/**
|
||||
* 当前的在线用户的信息请求
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @date 2021/1/11 22:30
|
||||
*/
|
||||
@Data
|
||||
public class OnlineUserRequest {
|
||||
|
||||
/**
|
||||
* 用户的token
|
||||
*/
|
||||
@NotBlank(message = "参数token不能为空")
|
||||
private String token;
|
||||
|
||||
/**
|
||||
* 用户账号
|
||||
*/
|
||||
private String account;
|
||||
|
||||
}
|
|
@ -1,6 +1,13 @@
|
|||
package cn.stylefeng.roses.kernel.system.pojo.ztree;
|
||||
|
||||
import cn.stylefeng.roses.kernel.rule.abstracts.AbstractTreeNode;
|
||||
import cn.stylefeng.roses.kernel.system.constants.SystemConstants;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* jquery ztree 插件的节点封装
|
||||
|
@ -8,11 +15,15 @@ import cn.stylefeng.roses.kernel.system.constants.SystemConstants;
|
|||
* @author fengshuonan
|
||||
* @date 2021/1/6 21:47
|
||||
*/
|
||||
public class ZTreeNode {
|
||||
@ToString
|
||||
@EqualsAndHashCode
|
||||
public class ZTreeNode implements AbstractTreeNode {
|
||||
|
||||
/**
|
||||
* 节点id
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
|
@ -23,23 +34,38 @@ public class ZTreeNode {
|
|||
/**
|
||||
* 节点名称
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 是否打开节点
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
private Boolean open;
|
||||
|
||||
/**
|
||||
* 是否被选中
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
private Boolean checked;
|
||||
|
||||
/**
|
||||
* 节点图标 single or group
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
private String iconSkin;
|
||||
|
||||
/**
|
||||
* 子节点集合
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
private List children;
|
||||
|
||||
/**
|
||||
* 创建ztree的父级节点
|
||||
*
|
||||
|
@ -56,51 +82,27 @@ public class ZTreeNode {
|
|||
return zTreeNode;
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
|
||||
@Override
|
||||
public String getNodeId() {
|
||||
return id.toString();
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
@Override
|
||||
public String getNodeParentId() {
|
||||
return pId.toString();
|
||||
}
|
||||
|
||||
public Long getpId() {
|
||||
return pId;
|
||||
@Override
|
||||
public void setChildrenNodes(List childrenNodes) {
|
||||
this.children = childrenNodes;
|
||||
}
|
||||
|
||||
public void setpId(Long pId) {
|
||||
this.pId = pId;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public Boolean getOpen() {
|
||||
return open;
|
||||
}
|
||||
|
||||
public void setOpen(Boolean open) {
|
||||
this.open = open;
|
||||
}
|
||||
|
||||
public Boolean getChecked() {
|
||||
return checked;
|
||||
}
|
||||
|
||||
public void setChecked(Boolean checked) {
|
||||
this.checked = checked;
|
||||
}
|
||||
|
||||
public String getIconSkin() {
|
||||
return iconSkin;
|
||||
}
|
||||
|
||||
public void setIconSkin(String iconSkin) {
|
||||
this.iconSkin = iconSkin;
|
||||
public Long getpId() {
|
||||
return pId;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -136,14 +136,26 @@ public class SysMenuController {
|
|||
}
|
||||
|
||||
/**
|
||||
* 获取系统菜单树(包含按钮),用于给角色授权时选择
|
||||
* 获取系统菜单平级树(包含按钮),用于给角色授权时选择(layui版本使用)
|
||||
*
|
||||
* @author majianguo
|
||||
* @date 2021/1/9 17:10
|
||||
*/
|
||||
@GetResource(name = "获取系统菜单树(包含按钮),用于给角色授权时选择", path = "/sysMenu/menuAndButtonTree")
|
||||
public List<LayuiMenuAndButtonTreeResponse> menuAndButtonTree(SysRoleRequest sysRoleRequest) {
|
||||
return sysMenuService.getMenuAndButtonTree(sysRoleRequest);
|
||||
return sysMenuService.getMenuAndButtonTree(sysRoleRequest, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取系统菜单树(包含按钮),用于给角色授权时选择(antd vue版本使用)
|
||||
*
|
||||
* @author majianguo
|
||||
* @date 2021/1/9 17:10
|
||||
*/
|
||||
@GetResource(name = "获取系统菜单树(包含按钮),用于给角色授权时选择", path = "/sysMenu/menuAndButtonTreeChildren")
|
||||
public ResponseData menuAndButtonTreeChildren(SysRoleRequest sysRoleRequest) {
|
||||
List<LayuiMenuAndButtonTreeResponse> treeResponseList = sysMenuService.getMenuAndButtonTree(sysRoleRequest, false);
|
||||
return new SuccessResponseData(treeResponseList);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -176,8 +176,11 @@ public interface SysMenuService extends IService<SysMenu> {
|
|||
/**
|
||||
* 获取包含按钮的系统菜单
|
||||
*
|
||||
* @param sysRoleRequest 请求参数
|
||||
* @param lateralFlag true-不带树形结构,false-返回带树形结构的
|
||||
* @author majianguo
|
||||
* @date 2021/1/9 17:11
|
||||
*/
|
||||
List<LayuiMenuAndButtonTreeResponse> getMenuAndButtonTree(SysRoleRequest sysRoleRequest);
|
||||
List<LayuiMenuAndButtonTreeResponse> getMenuAndButtonTree(SysRoleRequest sysRoleRequest, Boolean lateralFlag);
|
||||
|
||||
}
|
||||
|
|
|
@ -330,7 +330,7 @@ public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> impl
|
|||
}
|
||||
|
||||
@Override
|
||||
public List<LayuiMenuAndButtonTreeResponse> getMenuAndButtonTree(SysRoleRequest sysRoleRequest) {
|
||||
public List<LayuiMenuAndButtonTreeResponse> getMenuAndButtonTree(SysRoleRequest sysRoleRequest, Boolean lateralFlag) {
|
||||
List<LayuiMenuAndButtonTreeResponse> menuTreeNodeList = CollectionUtil.newArrayList();
|
||||
|
||||
LambdaQueryWrapper<SysMenu> munuWrapper = new LambdaQueryWrapper<>();
|
||||
|
@ -426,7 +426,12 @@ public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> impl
|
|||
menuTreeNodeList.add(menuTree);
|
||||
}
|
||||
|
||||
// 返回结果
|
||||
if (lateralFlag) {
|
||||
return menuTreeNodeList;
|
||||
} else {
|
||||
return new DefaultTreeBuildFactory<LayuiMenuAndButtonTreeResponse>().doTreeBuild(menuTreeNodeList);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -139,7 +139,20 @@ public class HrOrganizationController {
|
|||
*/
|
||||
@GetResource(name = "获取zTree形式的组织机构树(用于角色配置数据范围类型,并且数据范围类型是指定组织机构时)(layui版本)", path = "/hrOrganization/zTree")
|
||||
public List<ZTreeNode> layuiSelectParentMenuTreeList(@Validated(HrOrganizationRequest.orgZTree.class) HrOrganizationRequest hrOrganizationRequest) {
|
||||
return hrOrganizationService.orgZTree(hrOrganizationRequest);
|
||||
return hrOrganizationService.orgZTree(hrOrganizationRequest, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取zTree形式的组织机构树(用于角色配置数据范围类型,并且数据范围类型是指定组织机构时)(antd vue版本)
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @date 2021/1/9 18:37
|
||||
*/
|
||||
@GetResource(name = "获取zTree形式的组织机构树(用于角色配置数据范围类型,并且数据范围类型是指定组织机构时)(antd vue版本)", path = "/hrOrganization/treeWithChildren")
|
||||
public ResponseData treeWithChildren(@Validated(HrOrganizationRequest.orgZTree.class) HrOrganizationRequest hrOrganizationRequest) {
|
||||
List<ZTreeNode> zTreeNodes = hrOrganizationService.orgZTree(hrOrganizationRequest, true);
|
||||
return new SuccessResponseData(zTreeNodes);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -119,10 +119,11 @@ public interface HrOrganizationService extends IService<HrOrganization> {
|
|||
* 获取ztree形式的组织机构树(用于角色配置数据范围类型,并且数据范围类型是指定组织机构时)(layui版本)
|
||||
*
|
||||
* @param hrOrganizationRequest 请求参数
|
||||
* @param buildTree 是否构建成树结构的节点,true-带树结构,false-不带
|
||||
* @return ztree形式的组织机构树
|
||||
* @author fengshuonan
|
||||
* @date 2021/1/9 18:40
|
||||
*/
|
||||
List<ZTreeNode> orgZTree(HrOrganizationRequest hrOrganizationRequest);
|
||||
List<ZTreeNode> orgZTree(HrOrganizationRequest hrOrganizationRequest, boolean buildTree);
|
||||
|
||||
}
|
||||
|
|
|
@ -308,7 +308,7 @@ public class HrOrganizationServiceImpl extends ServiceImpl<HrOrganizationMapper,
|
|||
}
|
||||
|
||||
@Override
|
||||
public List<ZTreeNode> orgZTree(HrOrganizationRequest hrOrganizationRequest) {
|
||||
public List<ZTreeNode> orgZTree(HrOrganizationRequest hrOrganizationRequest, boolean buildTree) {
|
||||
|
||||
// 获取角色id
|
||||
Long roleId = hrOrganizationRequest.getRoleId();
|
||||
|
@ -328,8 +328,12 @@ public class HrOrganizationServiceImpl extends ServiceImpl<HrOrganizationMapper,
|
|||
}
|
||||
}
|
||||
|
||||
if (buildTree) {
|
||||
return new DefaultTreeBuildFactory<ZTreeNode>().doTreeBuild(zTreeNodes);
|
||||
} else {
|
||||
return zTreeNodes;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建组织架构的通用条件查询wrapper
|
||||
|
|
|
@ -68,14 +68,26 @@ public class ResourceController {
|
|||
}
|
||||
|
||||
/**
|
||||
* 获取资源平级树列表,用于分配接口权限
|
||||
* 获取资源平级树列表,用于分配接口权限(适用于layui版本)
|
||||
*
|
||||
* @author majianguo
|
||||
* @date 2021/1/9 15:07
|
||||
*/
|
||||
@GetResource(name = "获取资源平级树列表,用于分配接口权限", path = "/resource/getLateralTree")
|
||||
public List<ResourceTreeNode> getLateralTree(SysRoleRequest sysRoleRequest) {
|
||||
return sysResourceService.getResourceLateralTree(sysRoleRequest.getRoleId());
|
||||
return sysResourceService.getResourceTree(sysRoleRequest.getRoleId(), true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取资源树列表,用于分配接口权限(适用于antd vue版本)
|
||||
*
|
||||
* @author majianguo
|
||||
* @date 2021/1/9 15:07
|
||||
*/
|
||||
@GetResource(name = "获取资源树列表,用于分配接口权限", path = "/resource/getLateralTreeChildren")
|
||||
public ResponseData getLateralTreeChildren(SysRoleRequest sysRoleRequest) {
|
||||
List<ResourceTreeNode> resourceLateralTree = sysResourceService.getResourceTree(sysRoleRequest.getRoleId(), false);
|
||||
return new SuccessResponseData(resourceLateralTree);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package cn.stylefeng.roses.kernel.resource.modular.pojo;
|
||||
|
||||
import cn.stylefeng.roses.kernel.rule.abstracts.AbstractTreeNode;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
@ -11,7 +12,7 @@ import java.util.List;
|
|||
* @date 2020/3/26 14:29
|
||||
*/
|
||||
@Data
|
||||
public class ResourceTreeNode {
|
||||
public class ResourceTreeNode implements AbstractTreeNode {
|
||||
|
||||
/**
|
||||
* 资源id
|
||||
|
@ -46,4 +47,18 @@ public class ResourceTreeNode {
|
|||
*/
|
||||
private List children;
|
||||
|
||||
@Override
|
||||
public String getNodeId() {
|
||||
return this.code;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNodeParentId() {
|
||||
return this.parentCode;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setChildrenNodes(List childrenNodes) {
|
||||
this.children = childrenNodes;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -70,8 +70,10 @@ public interface SysResourceService extends IService<SysResource> {
|
|||
/**
|
||||
* 获取平级树节点列表
|
||||
*
|
||||
* @param roleId 角色id
|
||||
* @param lateralFlag true-不带树形结构,false-返回带树形结构的
|
||||
* @author majianguo
|
||||
* @date 2021/1/9 15:08
|
||||
*/
|
||||
List<ResourceTreeNode> getResourceLateralTree(Long roleId);
|
||||
List<ResourceTreeNode> getResourceTree(Long roleId, Boolean lateralFlag);
|
||||
}
|
||||
|
|
|
@ -19,10 +19,12 @@ import cn.stylefeng.roses.kernel.resource.modular.pojo.ResourceTreeNode;
|
|||
import cn.stylefeng.roses.kernel.resource.modular.service.SysResourceService;
|
||||
import cn.stylefeng.roses.kernel.rule.constants.RuleConstants;
|
||||
import cn.stylefeng.roses.kernel.rule.enums.YesOrNotEnum;
|
||||
import cn.stylefeng.roses.kernel.rule.factory.DefaultTreeBuildFactory;
|
||||
import cn.stylefeng.roses.kernel.system.ResourceServiceApi;
|
||||
import cn.stylefeng.roses.kernel.system.RoleServiceApi;
|
||||
import cn.stylefeng.roses.kernel.system.UserServiceApi;
|
||||
import cn.stylefeng.roses.kernel.system.constants.SystemConstants;
|
||||
import cn.stylefeng.roses.kernel.system.pojo.organization.layui.LayuiOrganizationTreeNode;
|
||||
import cn.stylefeng.roses.kernel.system.pojo.resource.request.ResourceRequest;
|
||||
import cn.stylefeng.roses.kernel.system.pojo.role.response.SysRoleResourceResponse;
|
||||
import cn.stylefeng.roses.kernel.system.pojo.role.response.SysRoleResponse;
|
||||
|
@ -137,7 +139,7 @@ public class SysResourceServiceImpl extends ServiceImpl<SysResourceMapper, SysRe
|
|||
}
|
||||
|
||||
@Override
|
||||
public List<ResourceTreeNode> getResourceLateralTree(Long roleId) {
|
||||
public List<ResourceTreeNode> getResourceTree(Long roleId, Boolean lateralFlag) {
|
||||
// 结果
|
||||
List<ResourceTreeNode> res = new ArrayList<>();
|
||||
|
||||
|
@ -214,7 +216,11 @@ public class SysResourceServiceImpl extends ServiceImpl<SysResourceMapper, SysRe
|
|||
}
|
||||
|
||||
// 根据map组装资源树
|
||||
if (lateralFlag) {
|
||||
return res;
|
||||
} else {
|
||||
return new DefaultTreeBuildFactory<ResourceTreeNode>().doTreeBuild(res);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -0,0 +1,56 @@
|
|||
package cn.stylefeng.roses.kernel.system.modular.user.controller;
|
||||
|
||||
import cn.stylefeng.roses.kernel.auth.api.SessionManagerApi;
|
||||
import cn.stylefeng.roses.kernel.resource.api.annotation.ApiResource;
|
||||
import cn.stylefeng.roses.kernel.resource.api.annotation.GetResource;
|
||||
import cn.stylefeng.roses.kernel.resource.api.annotation.PostResource;
|
||||
import cn.stylefeng.roses.kernel.rule.pojo.response.ResponseData;
|
||||
import cn.stylefeng.roses.kernel.rule.pojo.response.SuccessResponseData;
|
||||
import cn.stylefeng.roses.kernel.system.modular.user.service.SysUserService;
|
||||
import cn.stylefeng.roses.kernel.system.pojo.user.request.OnlineUserRequest;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.validation.Valid;
|
||||
|
||||
/**
|
||||
* 在线用户管理
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @date 2021/1/11 22:52
|
||||
*/
|
||||
@RestController
|
||||
@ApiResource(name = "在线用户管理")
|
||||
public class OnlineUserController {
|
||||
|
||||
@Resource
|
||||
private SysUserService sysUserService;
|
||||
|
||||
@Resource
|
||||
private SessionManagerApi sessionManagerApi;
|
||||
|
||||
/**
|
||||
* 当前在线用户列表
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @date 2021/1/11 22:53
|
||||
*/
|
||||
@GetResource(name = "当前在线用户列表", path = "/sysUser/onlineUserList")
|
||||
public ResponseData onlineUserList(OnlineUserRequest onlineUserRequest) {
|
||||
return new SuccessResponseData(sysUserService.onlineUserList(onlineUserRequest));
|
||||
}
|
||||
|
||||
/**
|
||||
* 踢掉在线用户
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @date 2021/1/11 22:53
|
||||
*/
|
||||
@PostResource(name = "踢掉在线用户", path = "/sysUser/removeSession")
|
||||
public ResponseData removeSession(@Valid @RequestBody OnlineUserRequest onlineUserRequest) {
|
||||
sessionManagerApi.removeSession(onlineUserRequest.getToken());
|
||||
return new SuccessResponseData();
|
||||
}
|
||||
|
||||
}
|
|
@ -8,9 +8,9 @@ import cn.stylefeng.roses.kernel.resource.api.annotation.PostResource;
|
|||
import cn.stylefeng.roses.kernel.rule.pojo.request.BaseRequest;
|
||||
import cn.stylefeng.roses.kernel.rule.pojo.response.ResponseData;
|
||||
import cn.stylefeng.roses.kernel.rule.pojo.response.SuccessResponseData;
|
||||
import cn.stylefeng.roses.kernel.system.pojo.user.request.SysUserRequest;
|
||||
import cn.stylefeng.roses.kernel.system.modular.user.service.SysUserRoleService;
|
||||
import cn.stylefeng.roses.kernel.system.modular.user.service.SysUserService;
|
||||
import cn.stylefeng.roses.kernel.system.pojo.user.request.SysUserRequest;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
@ -240,15 +240,4 @@ 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());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,41 @@
|
|||
package cn.stylefeng.roses.kernel.system.modular.user.factory;
|
||||
|
||||
import cn.stylefeng.roses.kernel.auth.api.pojo.login.LoginUser;
|
||||
import cn.stylefeng.roses.kernel.rule.enums.SexEnum;
|
||||
import cn.stylefeng.roses.kernel.system.pojo.user.OnlineUserResponse;
|
||||
|
||||
/**
|
||||
* 当前在线用户的创建工厂
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @date 2021/1/11 22:31
|
||||
*/
|
||||
public class OnlineUserCreateFactory {
|
||||
|
||||
/**
|
||||
* 登录用户转化为在线用户
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @date 2021/1/11 22:31
|
||||
*/
|
||||
public static OnlineUserResponse createOnlineUser(LoginUser loginUser) {
|
||||
|
||||
OnlineUserResponse onlineUserResponse = new OnlineUserResponse();
|
||||
|
||||
onlineUserResponse.setUserId(loginUser.getUserId());
|
||||
onlineUserResponse.setAccount(loginUser.getAccount());
|
||||
onlineUserResponse.setSex(SexEnum.codeToMessage(loginUser.getSimpleUserInfo().getSex()));
|
||||
onlineUserResponse.setRealName(loginUser.getSimpleUserInfo().getRealName());
|
||||
onlineUserResponse.setNickName(loginUser.getSimpleUserInfo().getNickName());
|
||||
|
||||
if (loginUser.getSimpleRoleInfoList() != null && loginUser.getSimpleRoleInfoList().size() > 0) {
|
||||
onlineUserResponse.setRoleName(loginUser.getSimpleRoleInfoList().get(0).getRoleName());
|
||||
}
|
||||
|
||||
onlineUserResponse.setLoginTime(loginUser.getLoginTime());
|
||||
onlineUserResponse.setToken(loginUser.getToken());
|
||||
|
||||
return onlineUserResponse;
|
||||
}
|
||||
|
||||
}
|
|
@ -13,10 +13,7 @@ import cn.stylefeng.roses.kernel.system.pojo.role.response.SysRoleResponse;
|
|||
import cn.stylefeng.roses.kernel.system.pojo.user.SysUserOrgResponse;
|
||||
import cn.stylefeng.roses.kernel.system.pojo.user.UserLoginInfoDTO;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 组装当前登录用户的信息
|
||||
|
@ -34,7 +31,7 @@ public class UserLoginInfoFactory {
|
|||
* @param dataScopeResponse 数据范围信息
|
||||
* @param userOrgInfo 组织机构信息
|
||||
* @param resourceUrlsListByCodes 用户的所有资源url
|
||||
* @param roleButtonCodes
|
||||
* @param roleButtonCodes 用户的所拥有的按钮编码
|
||||
* @author fengshuonan
|
||||
* @date 2020/12/26 17:53
|
||||
*/
|
||||
|
@ -102,6 +99,9 @@ public class UserLoginInfoFactory {
|
|||
// 填充用户拥有的按钮编码
|
||||
loginUser.setButtonCodes(roleButtonCodes);
|
||||
|
||||
// 设置用户的登录时间
|
||||
loginUser.setLoginTime(new Date());
|
||||
|
||||
// 响应dto
|
||||
userLoginInfoDTO.setLoginUser(loginUser);
|
||||
return userLoginInfoDTO;
|
||||
|
|
|
@ -22,13 +22,13 @@
|
|||
left join sys_user_org suorg on suser.user_id = suorg.user_id
|
||||
<where>
|
||||
<if test="sysUserRequest.realName != null and sysUserRequest.realName != ''">
|
||||
and sys_user.real_name like concat('%',#{sysUserRequest.realName},'%')
|
||||
and suser.real_name like concat('%',#{sysUserRequest.realName},'%')
|
||||
</if>
|
||||
<if test="sysUserRequest.account != null and sysUserRequest.account != ''">
|
||||
and sys_user.account like concat('%',#{sysUserRequest.account},'%')
|
||||
and suser.account like concat('%',#{sysUserRequest.account},'%')
|
||||
</if>
|
||||
<if test="sysUserRequest.statusFlag != null and sysUserRequest.statusFlag != ''">
|
||||
and sys_user.status_flag like concat('%',#{sysUserRequest.statusFlag},'%')
|
||||
and suser.status_flag like concat('%',#{sysUserRequest.statusFlag},'%')
|
||||
</if>
|
||||
<if test="sysUserRequest.orgId != null and sysUserRequest.orgId != ''">
|
||||
and suorg.org_id = #{sysUserRequest.orgId}
|
||||
|
|
|
@ -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.hutool.core.util.StrUtil;
|
||||
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;
|
||||
|
@ -25,11 +26,10 @@ import cn.stylefeng.roses.kernel.system.exception.enums.SysUserExceptionEnum;
|
|||
import cn.stylefeng.roses.kernel.system.modular.user.entity.SysUser;
|
||||
import cn.stylefeng.roses.kernel.system.modular.user.entity.SysUserDataScope;
|
||||
import cn.stylefeng.roses.kernel.system.modular.user.entity.SysUserRole;
|
||||
import cn.stylefeng.roses.kernel.system.modular.user.factory.OnlineUserCreateFactory;
|
||||
import cn.stylefeng.roses.kernel.system.modular.user.factory.SysUserCreateFactory;
|
||||
import cn.stylefeng.roses.kernel.system.modular.user.factory.UserLoginInfoFactory;
|
||||
import cn.stylefeng.roses.kernel.system.modular.user.mapper.SysUserMapper;
|
||||
import cn.stylefeng.roses.kernel.system.pojo.user.SysUserDTO;
|
||||
import cn.stylefeng.roses.kernel.system.pojo.user.request.SysUserRequest;
|
||||
import cn.stylefeng.roses.kernel.system.modular.user.pojo.response.SysUserResponse;
|
||||
import cn.stylefeng.roses.kernel.system.modular.user.service.SysUserDataScopeService;
|
||||
import cn.stylefeng.roses.kernel.system.modular.user.service.SysUserOrgService;
|
||||
|
@ -37,8 +37,12 @@ import cn.stylefeng.roses.kernel.system.modular.user.service.SysUserRoleService;
|
|||
import cn.stylefeng.roses.kernel.system.modular.user.service.SysUserService;
|
||||
import cn.stylefeng.roses.kernel.system.pojo.organization.DataScopeResponse;
|
||||
import cn.stylefeng.roses.kernel.system.pojo.role.response.SysRoleResponse;
|
||||
import cn.stylefeng.roses.kernel.system.pojo.user.OnlineUserResponse;
|
||||
import cn.stylefeng.roses.kernel.system.pojo.user.SysUserDTO;
|
||||
import cn.stylefeng.roses.kernel.system.pojo.user.SysUserOrgResponse;
|
||||
import cn.stylefeng.roses.kernel.system.pojo.user.UserLoginInfoDTO;
|
||||
import cn.stylefeng.roses.kernel.system.pojo.user.request.OnlineUserRequest;
|
||||
import cn.stylefeng.roses.kernel.system.pojo.user.request.SysUserRequest;
|
||||
import cn.stylefeng.roses.kernel.system.util.DataScopeUtil;
|
||||
import com.alibaba.excel.support.ExcelTypeEnum;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
|
@ -473,8 +477,18 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
|||
}
|
||||
|
||||
@Override
|
||||
public List<LoginUser> onlineUserList() {
|
||||
return sessionManagerApi.onlineUserList();
|
||||
public List<OnlineUserResponse> onlineUserList(OnlineUserRequest onlineUserRequest) {
|
||||
List<LoginUser> loginUsers = sessionManagerApi.onlineUserList();
|
||||
|
||||
// 对象转化
|
||||
List<OnlineUserResponse> result = loginUsers.stream().map(OnlineUserCreateFactory::createOnlineUser).collect(Collectors.toList());
|
||||
|
||||
// 如果带了条件则根据account筛选结果
|
||||
if (StrUtil.isNotBlank(onlineUserRequest.getAccount())) {
|
||||
return result.stream().filter(i -> i.getAccount().equals(onlineUserRequest.getAccount())).collect(Collectors.toList());
|
||||
} else {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in New Issue