数据权限?
This commit is contained in:
parent
69aaf0d922
commit
883a68b7b2
|
|
@ -2,7 +2,6 @@ package com.ruoyi.web.controller.system;
|
|||
|
||||
import com.ruoyi.common.annotation.Log;
|
||||
import com.ruoyi.common.constant.UserConstants;
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
import com.ruoyi.common.enums.BusinessType;
|
||||
|
|
@ -13,6 +12,7 @@ import com.ruoyi.system.domain.SysUser;
|
|||
import com.ruoyi.system.domain.SysUserRole;
|
||||
import com.ruoyi.system.service.ISysRoleService;
|
||||
import com.ruoyi.system.service.ISysUserService;
|
||||
import com.ruoyi.web.controller.system.base.WebController;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
|
|
@ -30,7 +30,7 @@ import java.util.List;
|
|||
*/
|
||||
@Controller
|
||||
@RequestMapping("/system/role")
|
||||
public class SysRoleController extends BaseController {
|
||||
public class SysRoleController extends WebController {
|
||||
private String prefix = "system/role";
|
||||
|
||||
@Autowired
|
||||
|
|
@ -49,7 +49,7 @@ public class SysRoleController extends BaseController {
|
|||
@PostMapping("/list")
|
||||
@ResponseBody
|
||||
public TableDataInfo list(SysRole role) {
|
||||
return getDataTable(roleService.selectRoleList(role, getPageRequest()));
|
||||
return getDataTable(roleService.selectRoleList(role, getPageRequest(), getUser()));
|
||||
}
|
||||
|
||||
@Log(title = "角色管理", businessType = BusinessType.EXPORT)
|
||||
|
|
@ -57,7 +57,7 @@ public class SysRoleController extends BaseController {
|
|||
@PostMapping("/export")
|
||||
@ResponseBody
|
||||
public AjaxResult export(SysRole role) {
|
||||
List<SysRole> list = roleService.selectRoleList(role, Pageable.unpaged()).getContent();
|
||||
List<SysRole> list = roleService.selectRoleList(role, Pageable.unpaged(), getUser()).getContent();
|
||||
ExcelUtil<SysRole> util = new ExcelUtil<SysRole>(SysRole.class);
|
||||
return util.exportExcel(list, "角色数据");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,12 @@
|
|||
package com.ruoyi.web.controller.system.base;
|
||||
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.framework.util.ShiroUtils;
|
||||
import com.ruoyi.system.domain.SysUser;
|
||||
|
||||
public class WebController extends BaseController {
|
||||
|
||||
protected SysUser getUser(){
|
||||
return ShiroUtils.getSysUser();
|
||||
}
|
||||
}
|
||||
|
|
@ -68,7 +68,7 @@ spring:
|
|||
url: jdbc:mysql://localhost:3306/mysql?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
|
||||
user: ${db.username}
|
||||
password: ${db.password}
|
||||
#需要目标数据库已经存在,不自动升级
|
||||
#目标数据库已经存在,不自动升级
|
||||
baseline-on-migrate: false
|
||||
encoding: utf-8
|
||||
clean-on-validation-error: false
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
|
|
@ -1,317 +1,319 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<meta name="renderer" content="webkit">
|
||||
<title>若依系统首页</title>
|
||||
<!--[if lt IE 9]>
|
||||
<meta http-equiv="refresh" content="0;ie.html"/>
|
||||
<![endif]-->
|
||||
<link th:href="@{favicon.ico}" rel="stylesheet"/>
|
||||
<link th:href="@{/css/bootstrap.min.css}" rel="stylesheet"/>
|
||||
<link th:href="@{/css/jquery.contextMenu.min.css}" rel="stylesheet"/>
|
||||
<link th:href="@{/css/font-awesome.min.css}" rel="stylesheet"/>
|
||||
<link th:href="@{/css/animate.css}" rel="stylesheet"/>
|
||||
<link th:href="@{/css/style.css}" rel="stylesheet"/>
|
||||
<link th:href="@{/css/skins.css}" rel="stylesheet"/>
|
||||
<link th:href="@{/ruoyi/css/ry-ui.css?v=4.1.0}" rel="stylesheet"/>
|
||||
</head>
|
||||
<body class="fixed-sidebar full-height-layout gray-bg" style="overflow: hidden">
|
||||
<div id="wrapper">
|
||||
|
||||
<!--左侧导航开始-->
|
||||
<nav class="navbar-default navbar-static-side" role="navigation">
|
||||
<div class="nav-close">
|
||||
<i class="fa fa-times-circle"></i>
|
||||
</div>
|
||||
<div class="sidebar-collapse">
|
||||
<ul class="nav" id="side-menu">
|
||||
<a th:href="@{/index}">
|
||||
<li class="logo">
|
||||
<span class="logo-lg" >RuoYi</span>
|
||||
</li>
|
||||
</a>
|
||||
<li>
|
||||
<div class="user-panel">
|
||||
<a class="menuItem" title="个人中心" th:href="@{/system/user/profile}">
|
||||
<div class="hide" th:text="个人中心"></div>
|
||||
<div class="pull-left image">
|
||||
<img th:src="(${user.avatar} == '') ? @{/img/profile.jpg} : @{${user.avatar}}" class="img-circle" alt="User Image">
|
||||
</div>
|
||||
</a>
|
||||
<div class="pull-left info">
|
||||
<p>[[${user.loginName}]]</p>
|
||||
<a href="#"><i class="fa fa-circle text-success"></i> 在线</a>
|
||||
<a th:href="@{logout}" style="padding-left:5px;"><i class="fa fa-sign-out text-danger"></i> 注销</a>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<a href="#"><i class="fa fa-home"></i> <span class="nav-label">主页</span> <span class="fa arrow"></span></a>
|
||||
<ul class="nav nav-second-level">
|
||||
<li><a class="menuItem" th:href="@{/system/main}">了解若依</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li th:each="menu : ${menus}">
|
||||
<a th:class="@{${menu.url != '' && menu.url != '#'} ? ${menu.target}}" th:href="@{${menu.url == ''} ? |#| : ${menu.url}}">
|
||||
<i class="fa fa-bar-chart-o" th:class="${menu.icon}"></i>
|
||||
<span class="nav-label" th:text="${menu.menuName}">一级菜单</span>
|
||||
<span th:class="${menu.url == '' || menu.url == '#'} ? |fa arrow|"></span>
|
||||
</a>
|
||||
<ul class="nav nav-second-level collapse">
|
||||
<li th:each="cmenu : ${menu.children}">
|
||||
<a th:if="${#lists.isEmpty(cmenu.children)}" th:class="${cmenu.target == ''} ? |menuItem| : ${cmenu.target}" th:utext="${cmenu.menuName}" th:href="@{${cmenu.url}}">二级菜单</a>
|
||||
<a th:if="${not #lists.isEmpty(cmenu.children)}" href="#">[[${cmenu.menuName}]]<span class="fa arrow"></span></a>
|
||||
<ul th:if="${not #lists.isEmpty(cmenu.children)}" class="nav nav-third-level">
|
||||
<li th:each="emenu : ${cmenu.children}">
|
||||
<a th:if="${#lists.isEmpty(emenu.children)}" th:class="${emenu.target == ''} ? |menuItem| : ${emenu.target}" th:text="${emenu.menuName}" th:href="@{${emenu.url}}">三级菜单</a>
|
||||
<a th:if="${not #lists.isEmpty(emenu.children)}" href="#">[[${emenu.menuName}]]<span class="fa arrow"></span></a>
|
||||
<ul th:if="${not #lists.isEmpty(emenu.children)}" class="nav nav-four-level">
|
||||
<li th:each="fmenu : ${emenu.children}"><a th:if="${#lists.isEmpty(fmenu.children)}" th:class="${fmenu.target == ''} ? |menuItem| : ${fmenu.target}" th:text="${fmenu.menuName}" th:href="@{${fmenu.url}}">四级菜单</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li th:if="${demoEnabled}">
|
||||
<a href="#"><i class="fa fa-desktop"></i><span class="nav-label">实例演示</span><span class="fa arrow"></span></a>
|
||||
<ul class="nav nav-second-level collapse">
|
||||
<li> <a>表单<span class="fa arrow"></span></a>
|
||||
<ul class="nav nav-third-level">
|
||||
<li><a class="menuItem" th:href="@{/demo/form/button}">按钮</a></li>
|
||||
<li><a class="menuItem" th:href="@{/demo/form/grid}">栅格</a></li>
|
||||
<li><a class="menuItem" th:href="@{/demo/form/select}">下拉框</a></li>
|
||||
<li><a class="menuItem" th:href="@{/demo/form/timeline}">时间轴</a></li>
|
||||
<li><a class="menuItem" th:href="@{/demo/form/basic}">基本表单</a></li>
|
||||
<li><a class="menuItem" th:href="@{/demo/form/cards}">卡片列表</a></li>
|
||||
<li><a class="menuItem" th:href="@{/demo/form/jasny}">功能扩展</a></li>
|
||||
<li><a class="menuItem" th:href="@{/demo/form/sortable}">拖动排序</a></li>
|
||||
<li><a class="menuItem" th:href="@{/demo/form/tabs_panels}">选项卡 & 面板</a></li>
|
||||
<li><a class="menuItem" th:href="@{/demo/form/validate}">表单校验</a></li>
|
||||
<li><a class="menuItem" th:href="@{/demo/form/wizard}">表单向导</a></li>
|
||||
<li><a class="menuItem" th:href="@{/demo/form/upload}">文件上传</a></li>
|
||||
<li><a class="menuItem" th:href="@{/demo/form/datetime}">日期和时间</a></li>
|
||||
<li><a class="menuItem" th:href="@{/demo/form/summernote}">富文本编辑器</a></li>
|
||||
<li><a class="menuItem" th:href="@{/demo/form/duallistbox}">左右互选组件</a></li>
|
||||
<li><a class="menuItem" th:href="@{/demo/form/autocomplete}">搜索自动补全</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li> <a>表格<span class="fa arrow"></span></a>
|
||||
<ul class="nav nav-third-level">
|
||||
<li><a class="menuItem" th:href="@{/demo/table/search}">查询条件</a></li>
|
||||
<li><a class="menuItem" th:href="@{/demo/table/footer}">数据汇总</a></li>
|
||||
<li><a class="menuItem" th:href="@{/demo/table/groupHeader}">组合表头</a></li>
|
||||
<li><a class="menuItem" th:href="@{/demo/table/export}">表格导出</a></li>
|
||||
<li><a class="menuItem" th:href="@{/demo/table/remember}">翻页记住选择</a></li>
|
||||
<li><a class="menuItem" th:href="@{/demo/table/pageGo}">跳转至指定页</a></li>
|
||||
<li><a class="menuItem" th:href="@{/demo/table/params}">自定义查询参数</a></li>
|
||||
<li><a class="menuItem" th:href="@{/demo/table/multi}">初始多表格</a></li>
|
||||
<li><a class="menuItem" th:href="@{/demo/table/button}">点击按钮加载表格</a></li>
|
||||
<li><a class="menuItem" th:href="@{/demo/table/fixedColumns}">表格冻结列</a></li>
|
||||
<li><a class="menuItem" th:href="@{/demo/table/event}">自定义触发事件</a></li>
|
||||
<li><a class="menuItem" th:href="@{/demo/table/detail}">表格细节视图</a></li>
|
||||
<li><a class="menuItem" th:href="@{/demo/table/child}">表格父子视图</a></li>
|
||||
<li><a class="menuItem" th:href="@{/demo/table/image}">表格图片预览</a></li>
|
||||
<li><a class="menuItem" th:href="@{/demo/table/curd}">动态增删改查</a></li>
|
||||
<li><a class="menuItem" th:href="@{/demo/table/reorder}">表格拖拽操作</a></li>
|
||||
<li><a class="menuItem" th:href="@{/demo/table/editable}">表格行内编辑</a></li>
|
||||
<li><a class="menuItem" th:href="@{/demo/table/other}">表格其他操作</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li> <a>弹框<span class="fa arrow"></span></a>
|
||||
<ul class="nav nav-third-level">
|
||||
<li><a class="menuItem" th:href="@{/demo/modal/dialog}">模态窗口</a></li>
|
||||
<li><a class="menuItem" th:href="@{/demo/modal/layer}">弹层组件</a></li>
|
||||
<li><a class="menuItem" th:href="@{/demo/modal/table}">弹层表格</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li> <a>操作<span class="fa arrow"></span></a>
|
||||
<ul class="nav nav-third-level">
|
||||
<li><a class="menuItem" th:href="@{/demo/operate/table}">表格</a></li>
|
||||
<li><a class="menuItem" th:href="@{/demo/operate/other}">其他</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li> <a>报表<span class="fa arrow"></span></a>
|
||||
<ul class="nav nav-third-level">
|
||||
<li><a class="menuItem" th:href="@{/demo/report/echarts}">百度ECharts</a></li>
|
||||
<li><a class="menuItem" th:href="@{/demo/report/peity}">peity</a></li>
|
||||
<li><a class="menuItem" th:href="@{/demo/report/sparkline}">sparkline</a></li>
|
||||
<li><a class="menuItem" th:href="@{/demo/report/metrics}">图表组合</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li> <a>图标<span class="fa arrow"></span></a>
|
||||
<ul class="nav nav-third-level">
|
||||
<li><a class="menuItem" th:href="@{/demo/icon/fontawesome}">Font Awesome</a></li>
|
||||
<li><a class="menuItem" th:href="@{/demo/icon/glyphicons}">Glyphicons</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li>
|
||||
<a href="#"><i class="fa fa-sitemap"></i> <span class="nav-label">四层菜单 </span><span class="fa arrow"></span></a>
|
||||
<ul class="nav nav-second-level collapse">
|
||||
<li>
|
||||
<a href="#" id="damian">三级菜单1<span class="fa arrow"></span></a>
|
||||
<ul class="nav nav-third-level">
|
||||
<li>
|
||||
<a href="#">四级菜单1</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="#">四级菜单2</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a href="#">三级菜单2</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</nav>
|
||||
<!--左侧导航结束-->
|
||||
|
||||
<!--右侧部分开始-->
|
||||
<div id="page-wrapper" class="gray-bg dashbard-1">
|
||||
<div class="row border-bottom">
|
||||
<nav class="navbar navbar-static-top" role="navigation" style="margin-bottom: 0">
|
||||
<div class="navbar-header">
|
||||
<a class="navbar-minimalize minimalize-styl-2" style="color:#FFF;" href="#" title="收起菜单">
|
||||
<i class="fa fa-bars"></i>
|
||||
</a>
|
||||
</div>
|
||||
<ul class="nav navbar-top-links navbar-right welcome-message">
|
||||
<li><a title="阿里云双12" href="https://www.aliyun.com/minisite/goods?userCode=brki8iof&share_source=copy_link" target="_blank"><i class="fa fa-cloud"></i> 阿里云双12</a></li>
|
||||
<li><a title="视频教程" href="http://doc.ruoyi.vip/ruoyi/document/spjc.html" target="_blank"><i class="fa fa-video-camera"></i> 视频教程</a></li>
|
||||
<li><a title="开发文档" href="http://doc.ruoyi.vip" target="_blank"><i class="fa fa-question-circle"></i> 开发文档</a></li>
|
||||
<li><a title="全屏显示" href="javascript:void(0)" id="fullScreen"><i class="fa fa-arrows-alt"></i> 全屏显示</a></li>
|
||||
<li class="dropdown user-menu">
|
||||
<a href="javascript:void(0)" class="dropdown-toggle" data-hover="dropdown">
|
||||
<img th:src="(${user.avatar} == '') ? @{/img/profile.jpg} : @{${user.avatar}}" class="user-image">
|
||||
<span class="hidden-xs">[[${user.userName}]]</span>
|
||||
</a>
|
||||
<ul class="dropdown-menu">
|
||||
<li class="mt5">
|
||||
<a th:href="@{/system/user/profile}" class="menuItem">
|
||||
<i class="fa fa-user"></i> 个人中心</a>
|
||||
</li>
|
||||
<li>
|
||||
<a onclick="resetPwd()">
|
||||
<i class="fa fa-key"></i> 修改密码</a>
|
||||
</li>
|
||||
<li>
|
||||
<a onclick="switchSkin()">
|
||||
<i class="fa fa-dashboard"></i> 切换主题</a>
|
||||
</li>
|
||||
<li class="divider"></li>
|
||||
<li>
|
||||
<a th:href="@{logout}">
|
||||
<i class="fa fa-sign-out"></i> 退出登录</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</nav>
|
||||
</div>
|
||||
<div class="row content-tabs">
|
||||
<button class="roll-nav roll-left tabLeft">
|
||||
<i class="fa fa-backward"></i>
|
||||
</button>
|
||||
<nav class="page-tabs menuTabs">
|
||||
<div class="page-tabs-content">
|
||||
<a href="javascript:;" class="active menuTab" data-id="/system/main">首页</a>
|
||||
</div>
|
||||
</nav>
|
||||
<button class="roll-nav roll-right tabRight">
|
||||
<i class="fa fa-forward"></i>
|
||||
</button>
|
||||
<a href="javascript:void(0);" class="roll-nav roll-right tabReload"><i class="fa fa-refresh"></i> 刷新</a>
|
||||
</div>
|
||||
|
||||
<a id="ax_close_max" class="ax_close_max" href="#" title="关闭全屏"> <i class="fa fa-times-circle-o"></i> </a>
|
||||
|
||||
<div class="row mainContent" id="content-main">
|
||||
<iframe class="RuoYi_iframe" name="iframe0" width="100%" height="100%" data-id="/system/main"
|
||||
th:src="@{/system/main}" frameborder="0" seamless></iframe>
|
||||
</div>
|
||||
<div class="footer">
|
||||
<div class="pull-right">© [[${copyrightYear}]] RuoYi Copyright </div>
|
||||
</div>
|
||||
</div>
|
||||
<!--右侧部分结束-->
|
||||
</div>
|
||||
<!-- 全局js -->
|
||||
<script th:src="@{/js/jquery.min.js}"></script>
|
||||
<script th:src="@{/js/bootstrap.min.js}"></script>
|
||||
<script th:src="@{/js/plugins/metisMenu/jquery.metisMenu.js}"></script>
|
||||
<script th:src="@{/js/plugins/slimscroll/jquery.slimscroll.min.js}"></script>
|
||||
<script th:src="@{/js/jquery.contextMenu.min.js}"></script>
|
||||
<script th:src="@{/ajax/libs/blockUI/jquery.blockUI.js}"></script>
|
||||
<script th:src="@{/ajax/libs/layer/layer.min.js}"></script>
|
||||
<script th:src="@{/ruoyi/js/ry-ui.js?v=4.1.0}"></script>
|
||||
<script th:src="@{/ruoyi/js/common.js?v=4.1.0}"></script>
|
||||
<script th:src="@{/ruoyi/index.js}"></script>
|
||||
<script th:src="@{/ajax/libs/fullscreen/jquery.fullscreen.js}"></script>
|
||||
<script th:inline="javascript">
|
||||
var ctx = [[@{/}]];
|
||||
// 皮肤缓存
|
||||
var skin = storage.get("skin");
|
||||
// history(表示去掉地址的#)否则地址以"#"形式展示
|
||||
var mode = "history";
|
||||
// 历史访问路径缓存
|
||||
var historyPath = storage.get("historyPath");
|
||||
// 排除非左侧菜单链接
|
||||
var excludesUrl = ["/system/user/profile"];
|
||||
|
||||
// 本地主题优先,未设置取系统配置
|
||||
if($.common.isNotEmpty(skin)){
|
||||
$("body").addClass(skin.split('|')[0]);
|
||||
$("body").addClass(skin.split('|')[1]);
|
||||
} else {
|
||||
var sideTheme = [[${@config.getKey('sys.index.sideTheme')}]];
|
||||
var skinName = [[${@config.getKey('sys.index.skinName')}]];
|
||||
$("body").addClass(sideTheme);
|
||||
$("body").addClass(skinName);
|
||||
}
|
||||
|
||||
/* 用户管理-重置密码 */
|
||||
function resetPwd() {
|
||||
var url = ctx + 'system/user/profile/resetPwd';
|
||||
$.modal.open("重置密码", url, '770', '380');
|
||||
}
|
||||
/* 切换主题 */
|
||||
function switchSkin() {
|
||||
layer.open({
|
||||
type : 2,
|
||||
shadeClose : true,
|
||||
title : "切换主题",
|
||||
area : ["530px", "386px"],
|
||||
content : [ctx + "system/switchSkin", 'no']
|
||||
})
|
||||
}
|
||||
|
||||
/** 刷新时访问路径页签 */
|
||||
function applyPath(url) {
|
||||
$('a[href$="' + decodeURI(url) + '"]').click();
|
||||
if($.inArray(url, excludesUrl)){
|
||||
$('a[href$="' + url + '"]').parent("li").addClass("selected").parents("li").addClass("active").end().parents("ul").addClass("in");
|
||||
}
|
||||
}
|
||||
|
||||
$(function() {
|
||||
if($.common.equals("history", mode) && window.performance.navigation.type == 1) {
|
||||
var url = storage.get('publicPath');
|
||||
if ($.common.isNotEmpty(url)) {
|
||||
applyPath(url);
|
||||
}
|
||||
} else {
|
||||
var hash = location.hash;
|
||||
if ($.common.isNotEmpty(hash)) {
|
||||
var url = hash.substring(1, hash.length);
|
||||
applyPath(url);
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<meta name="renderer" content="webkit">
|
||||
<title>若依系统首页</title>
|
||||
<!--[if lt IE 9]>
|
||||
<meta http-equiv="refresh" content="0;ie.html"/>
|
||||
<![endif]-->
|
||||
<link th:href="@{favicon.ico}" rel="stylesheet"/>
|
||||
<link th:href="@{/css/bootstrap.min.css}" rel="stylesheet"/>
|
||||
<link th:href="@{/css/jquery.contextMenu.min.css}" rel="stylesheet"/>
|
||||
<link th:href="@{/css/font-awesome.min.css}" rel="stylesheet"/>
|
||||
<link th:href="@{/css/animate.css}" rel="stylesheet"/>
|
||||
<link th:href="@{/css/style.css}" rel="stylesheet"/>
|
||||
<link th:href="@{/css/skins.css}" rel="stylesheet"/>
|
||||
<link th:href="@{/ruoyi/css/ry-ui.css?v=4.1.0}" rel="stylesheet"/>
|
||||
</head>
|
||||
<body class="fixed-sidebar full-height-layout gray-bg" style="overflow: hidden">
|
||||
<div id="wrapper">
|
||||
|
||||
<!--左侧导航开始-->
|
||||
<nav class="navbar-default navbar-static-side" role="navigation">
|
||||
<div class="nav-close">
|
||||
<i class="fa fa-times-circle"></i>
|
||||
</div>
|
||||
<div class="sidebar-collapse">
|
||||
<ul class="nav" id="side-menu">
|
||||
<a th:href="@{/index}">
|
||||
<li class="logo">
|
||||
<span class="logo-lg" >RuoYi</span>
|
||||
</li>
|
||||
</a>
|
||||
<li>
|
||||
<div class="user-panel">
|
||||
<a class="menuItem" title="个人中心" th:href="@{/system/user/profile}">
|
||||
<div class="hide" th:text="个人中心"></div>
|
||||
<div class="pull-left image">
|
||||
<img th:src="(${user.avatar} == '') ? @{/img/profile.jpg} : @{${user.avatar}}" class="img-circle" alt="User Image">
|
||||
</div>
|
||||
</a>
|
||||
<div class="pull-left info">
|
||||
<p>[[${user.loginName}]]</p>
|
||||
<a href="#"><i class="fa fa-circle text-success"></i> 在线</a>
|
||||
<a th:href="@{logout}" style="padding-left:5px;"><i class="fa fa-sign-out text-danger"></i> 注销</a>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<a href="#"><i class="fa fa-home"></i> <span class="nav-label">主页</span> <span class="fa arrow"></span></a>
|
||||
<ul class="nav nav-second-level">
|
||||
<li><a class="menuItem" th:href="@{/system/main}">了解若依</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li th:each="menu : ${menus}">
|
||||
<a th:class="@{${menu.url != '' && menu.url != '#'} ? ${menu.target}}" th:href="@{${menu.url == ''} ? |#| : ${menu.url}}">
|
||||
<i class="fa fa-bar-chart-o" th:class="${menu.icon}"></i>
|
||||
<span class="nav-label" th:text="${menu.menuName}">一级菜单</span>
|
||||
<span th:class="${menu.url == '' || menu.url == '#'} ? |fa arrow|"></span>
|
||||
</a>
|
||||
<ul class="nav nav-second-level collapse">
|
||||
<li th:each="cmenu : ${menu.children}">
|
||||
<a th:if="${#lists.isEmpty(cmenu.children)}" th:class="${cmenu.target == ''} ? |menuItem| : ${cmenu.target}" th:utext="${cmenu.menuName}" th:href="@{${cmenu.url}}" th:id="${cmenu.menuId}">二级菜单</a>
|
||||
<a th:if="${not #lists.isEmpty(cmenu.children)}" href="#">[[${cmenu.menuName}]]<span class="fa arrow"></span></a>
|
||||
<ul th:if="${not #lists.isEmpty(cmenu.children)}" class="nav nav-third-level">
|
||||
<li th:each="emenu : ${cmenu.children}">
|
||||
<a th:if="${#lists.isEmpty(emenu.children)}" th:class="${emenu.target == ''} ? |menuItem| : ${emenu.target}" th:text="${emenu.menuName}" th:href="@{${emenu.url}}" th:id="${cmenu.menuId}">三级菜单</a>
|
||||
<a th:if="${not #lists.isEmpty(emenu.children)}" href="#">[[${emenu.menuName}]]<span class="fa arrow"></span></a>
|
||||
<ul th:if="${not #lists.isEmpty(emenu.children)}" class="nav nav-four-level">
|
||||
<li th:each="fmenu : ${emenu.children}">
|
||||
<a th:if="${#lists.isEmpty(fmenu.children)}" th:class="${fmenu.target == ''} ? |menuItem| : ${fmenu.target}" th:text="${fmenu.menuName}" th:href="@{${fmenu.url}}" th:id="${cmenu.menuId}">四级菜单</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li th:if="${demoEnabled}">
|
||||
<a href="#"><i class="fa fa-desktop"></i><span class="nav-label">实例演示</span><span class="fa arrow"></span></a>
|
||||
<ul class="nav nav-second-level collapse">
|
||||
<li> <a>表单<span class="fa arrow"></span></a>
|
||||
<ul class="nav nav-third-level">
|
||||
<li><a class="menuItem" th:href="@{/demo/form/button}">按钮</a></li>
|
||||
<li><a class="menuItem" th:href="@{/demo/form/grid}">栅格</a></li>
|
||||
<li><a class="menuItem" th:href="@{/demo/form/select}">下拉框</a></li>
|
||||
<li><a class="menuItem" th:href="@{/demo/form/timeline}">时间轴</a></li>
|
||||
<li><a class="menuItem" th:href="@{/demo/form/basic}">基本表单</a></li>
|
||||
<li><a class="menuItem" th:href="@{/demo/form/cards}">卡片列表</a></li>
|
||||
<li><a class="menuItem" th:href="@{/demo/form/jasny}">功能扩展</a></li>
|
||||
<li><a class="menuItem" th:href="@{/demo/form/sortable}">拖动排序</a></li>
|
||||
<li><a class="menuItem" th:href="@{/demo/form/tabs_panels}">选项卡 & 面板</a></li>
|
||||
<li><a class="menuItem" th:href="@{/demo/form/validate}">表单校验</a></li>
|
||||
<li><a class="menuItem" th:href="@{/demo/form/wizard}">表单向导</a></li>
|
||||
<li><a class="menuItem" th:href="@{/demo/form/upload}">文件上传</a></li>
|
||||
<li><a class="menuItem" th:href="@{/demo/form/datetime}">日期和时间</a></li>
|
||||
<li><a class="menuItem" th:href="@{/demo/form/summernote}">富文本编辑器</a></li>
|
||||
<li><a class="menuItem" th:href="@{/demo/form/duallistbox}">左右互选组件</a></li>
|
||||
<li><a class="menuItem" th:href="@{/demo/form/autocomplete}">搜索自动补全</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li> <a>表格<span class="fa arrow"></span></a>
|
||||
<ul class="nav nav-third-level">
|
||||
<li><a class="menuItem" th:href="@{/demo/table/search}">查询条件</a></li>
|
||||
<li><a class="menuItem" th:href="@{/demo/table/footer}">数据汇总</a></li>
|
||||
<li><a class="menuItem" th:href="@{/demo/table/groupHeader}">组合表头</a></li>
|
||||
<li><a class="menuItem" th:href="@{/demo/table/export}">表格导出</a></li>
|
||||
<li><a class="menuItem" th:href="@{/demo/table/remember}">翻页记住选择</a></li>
|
||||
<li><a class="menuItem" th:href="@{/demo/table/pageGo}">跳转至指定页</a></li>
|
||||
<li><a class="menuItem" th:href="@{/demo/table/params}">自定义查询参数</a></li>
|
||||
<li><a class="menuItem" th:href="@{/demo/table/multi}">初始多表格</a></li>
|
||||
<li><a class="menuItem" th:href="@{/demo/table/button}">点击按钮加载表格</a></li>
|
||||
<li><a class="menuItem" th:href="@{/demo/table/fixedColumns}">表格冻结列</a></li>
|
||||
<li><a class="menuItem" th:href="@{/demo/table/event}">自定义触发事件</a></li>
|
||||
<li><a class="menuItem" th:href="@{/demo/table/detail}">表格细节视图</a></li>
|
||||
<li><a class="menuItem" th:href="@{/demo/table/child}">表格父子视图</a></li>
|
||||
<li><a class="menuItem" th:href="@{/demo/table/image}">表格图片预览</a></li>
|
||||
<li><a class="menuItem" th:href="@{/demo/table/curd}">动态增删改查</a></li>
|
||||
<li><a class="menuItem" th:href="@{/demo/table/reorder}">表格拖拽操作</a></li>
|
||||
<li><a class="menuItem" th:href="@{/demo/table/editable}">表格行内编辑</a></li>
|
||||
<li><a class="menuItem" th:href="@{/demo/table/other}">表格其他操作</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li> <a>弹框<span class="fa arrow"></span></a>
|
||||
<ul class="nav nav-third-level">
|
||||
<li><a class="menuItem" th:href="@{/demo/modal/dialog}">模态窗口</a></li>
|
||||
<li><a class="menuItem" th:href="@{/demo/modal/layer}">弹层组件</a></li>
|
||||
<li><a class="menuItem" th:href="@{/demo/modal/table}">弹层表格</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li> <a>操作<span class="fa arrow"></span></a>
|
||||
<ul class="nav nav-third-level">
|
||||
<li><a class="menuItem" th:href="@{/demo/operate/table}">表格</a></li>
|
||||
<li><a class="menuItem" th:href="@{/demo/operate/other}">其他</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li> <a>报表<span class="fa arrow"></span></a>
|
||||
<ul class="nav nav-third-level">
|
||||
<li><a class="menuItem" th:href="@{/demo/report/echarts}">百度ECharts</a></li>
|
||||
<li><a class="menuItem" th:href="@{/demo/report/peity}">peity</a></li>
|
||||
<li><a class="menuItem" th:href="@{/demo/report/sparkline}">sparkline</a></li>
|
||||
<li><a class="menuItem" th:href="@{/demo/report/metrics}">图表组合</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li> <a>图标<span class="fa arrow"></span></a>
|
||||
<ul class="nav nav-third-level">
|
||||
<li><a class="menuItem" th:href="@{/demo/icon/fontawesome}">Font Awesome</a></li>
|
||||
<li><a class="menuItem" th:href="@{/demo/icon/glyphicons}">Glyphicons</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li>
|
||||
<a href="#"><i class="fa fa-sitemap"></i> <span class="nav-label">四层菜单 </span><span class="fa arrow"></span></a>
|
||||
<ul class="nav nav-second-level collapse">
|
||||
<li>
|
||||
<a href="#" id="damian">三级菜单1<span class="fa arrow"></span></a>
|
||||
<ul class="nav nav-third-level">
|
||||
<li>
|
||||
<a href="#">四级菜单1</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="#">四级菜单2</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a href="#">三级菜单2</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</nav>
|
||||
<!--左侧导航结束-->
|
||||
|
||||
<!--右侧部分开始-->
|
||||
<div id="page-wrapper" class="gray-bg dashbard-1">
|
||||
<div class="row border-bottom">
|
||||
<nav class="navbar navbar-static-top" role="navigation" style="margin-bottom: 0">
|
||||
<div class="navbar-header">
|
||||
<a class="navbar-minimalize minimalize-styl-2" style="color:#FFF;" href="#" title="收起菜单">
|
||||
<i class="fa fa-bars"></i>
|
||||
</a>
|
||||
</div>
|
||||
<ul class="nav navbar-top-links navbar-right welcome-message">
|
||||
<li><a title="阿里云双12" href="https://www.aliyun.com/minisite/goods?userCode=brki8iof&share_source=copy_link" target="_blank"><i class="fa fa-cloud"></i> 阿里云双12</a></li>
|
||||
<li><a title="视频教程" href="http://doc.ruoyi.vip/ruoyi/document/spjc.html" target="_blank"><i class="fa fa-video-camera"></i> 视频教程</a></li>
|
||||
<li><a title="开发文档" href="http://doc.ruoyi.vip" target="_blank"><i class="fa fa-question-circle"></i> 开发文档</a></li>
|
||||
<li><a title="全屏显示" href="javascript:void(0)" id="fullScreen"><i class="fa fa-arrows-alt"></i> 全屏显示</a></li>
|
||||
<li class="dropdown user-menu">
|
||||
<a href="javascript:void(0)" class="dropdown-toggle" data-hover="dropdown">
|
||||
<img th:src="(${user.avatar} == '') ? @{/img/profile.jpg} : @{${user.avatar}}" class="user-image">
|
||||
<span class="hidden-xs">[[${user.userName}]]</span>
|
||||
</a>
|
||||
<ul class="dropdown-menu">
|
||||
<li class="mt5">
|
||||
<a th:href="@{/system/user/profile}" class="menuItem">
|
||||
<i class="fa fa-user"></i> 个人中心</a>
|
||||
</li>
|
||||
<li>
|
||||
<a onclick="resetPwd()">
|
||||
<i class="fa fa-key"></i> 修改密码</a>
|
||||
</li>
|
||||
<li>
|
||||
<a onclick="switchSkin()">
|
||||
<i class="fa fa-dashboard"></i> 切换主题</a>
|
||||
</li>
|
||||
<li class="divider"></li>
|
||||
<li>
|
||||
<a th:href="@{logout}">
|
||||
<i class="fa fa-sign-out"></i> 退出登录</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</nav>
|
||||
</div>
|
||||
<div class="row content-tabs">
|
||||
<button class="roll-nav roll-left tabLeft">
|
||||
<i class="fa fa-backward"></i>
|
||||
</button>
|
||||
<nav class="page-tabs menuTabs">
|
||||
<div class="page-tabs-content">
|
||||
<a href="javascript:;" class="active menuTab" data-id="/system/main">首页</a>
|
||||
</div>
|
||||
</nav>
|
||||
<button class="roll-nav roll-right tabRight">
|
||||
<i class="fa fa-forward"></i>
|
||||
</button>
|
||||
<a href="javascript:void(0);" class="roll-nav roll-right tabReload"><i class="fa fa-refresh"></i> 刷新</a>
|
||||
</div>
|
||||
|
||||
<a id="ax_close_max" class="ax_close_max" href="#" title="关闭全屏"> <i class="fa fa-times-circle-o"></i> </a>
|
||||
|
||||
<div class="row mainContent" id="content-main">
|
||||
<iframe class="RuoYi_iframe" name="iframe0" width="100%" height="100%" data-id="/system/main"
|
||||
th:src="@{/system/main}" frameborder="0" seamless></iframe>
|
||||
</div>
|
||||
<div class="footer">
|
||||
<div class="pull-right">© [[${copyrightYear}]] RuoYi Copyright </div>
|
||||
</div>
|
||||
</div>
|
||||
<!--右侧部分结束-->
|
||||
</div>
|
||||
<!-- 全局js -->
|
||||
<script th:src="@{/js/jquery.min.js}"></script>
|
||||
<script th:src="@{/js/bootstrap.min.js}"></script>
|
||||
<script th:src="@{/js/plugins/metisMenu/jquery.metisMenu.js}"></script>
|
||||
<script th:src="@{/js/plugins/slimscroll/jquery.slimscroll.min.js}"></script>
|
||||
<script th:src="@{/js/jquery.contextMenu.min.js}"></script>
|
||||
<script th:src="@{/ajax/libs/blockUI/jquery.blockUI.js}"></script>
|
||||
<script th:src="@{/ajax/libs/layer/layer.min.js}"></script>
|
||||
<script th:src="@{/ruoyi/js/ry-ui.js?v=4.1.0}"></script>
|
||||
<script th:src="@{/ruoyi/js/common.js?v=4.1.0}"></script>
|
||||
<script th:src="@{/ruoyi/index.js}"></script>
|
||||
<script th:src="@{/ajax/libs/fullscreen/jquery.fullscreen.js}"></script>
|
||||
<script th:inline="javascript">
|
||||
var ctx = [[@{/}]];
|
||||
// 皮肤缓存
|
||||
var skin = storage.get("skin");
|
||||
// history(表示去掉地址的#)否则地址以"#"形式展示
|
||||
var mode = "history";
|
||||
// 历史访问路径缓存
|
||||
var historyPath = storage.get("historyPath");
|
||||
// 排除非左侧菜单链接
|
||||
var excludesUrl = ["/system/user/profile"];
|
||||
|
||||
// 本地主题优先,未设置取系统配置
|
||||
if($.common.isNotEmpty(skin)){
|
||||
$("body").addClass(skin.split('|')[0]);
|
||||
$("body").addClass(skin.split('|')[1]);
|
||||
} else {
|
||||
var sideTheme = [[${@config.getKey('sys.index.sideTheme')}]];
|
||||
var skinName = [[${@config.getKey('sys.index.skinName')}]];
|
||||
$("body").addClass(sideTheme);
|
||||
$("body").addClass(skinName);
|
||||
}
|
||||
|
||||
/* 用户管理-重置密码 */
|
||||
function resetPwd() {
|
||||
var url = ctx + 'system/user/profile/resetPwd';
|
||||
$.modal.open("重置密码", url, '770', '380');
|
||||
}
|
||||
/* 切换主题 */
|
||||
function switchSkin() {
|
||||
layer.open({
|
||||
type : 2,
|
||||
shadeClose : true,
|
||||
title : "切换主题",
|
||||
area : ["530px", "386px"],
|
||||
content : [ctx + "system/switchSkin", 'no']
|
||||
})
|
||||
}
|
||||
|
||||
/** 刷新时访问路径页签 */
|
||||
function applyPath(url) {
|
||||
$('a[href$="' + decodeURI(url) + '"]').click();
|
||||
if($.inArray(url, excludesUrl)){
|
||||
$('a[href$="' + url + '"]').parent("li").addClass("selected").parents("li").addClass("active").end().parents("ul").addClass("in");
|
||||
}
|
||||
}
|
||||
|
||||
$(function() {
|
||||
if($.common.equals("history", mode) && window.performance.navigation.type == 1) {
|
||||
var url = storage.get('publicPath');
|
||||
if ($.common.isNotEmpty(url)) {
|
||||
applyPath(url);
|
||||
}
|
||||
} else {
|
||||
var hash = location.hash;
|
||||
if ($.common.isNotEmpty(hash)) {
|
||||
var url = hash.substring(1, hash.length);
|
||||
applyPath(url);
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
|||
|
|
@ -11,17 +11,13 @@ import java.lang.annotation.Target;
|
|||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
@Target(ElementType.METHOD)
|
||||
@Target(ElementType.TYPE)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Documented
|
||||
public @interface DataScope {
|
||||
/**
|
||||
* 部门表的别名
|
||||
* 业务表的所属用户的字段名称:过滤仅本人的数据权限,
|
||||
* 该字段的类型为:{@link com.ruoyi.system.domain.SysUser}
|
||||
*/
|
||||
public String deptAlias() default "";
|
||||
|
||||
/**
|
||||
* 用户表的别名
|
||||
*/
|
||||
public String userAlias() default "";
|
||||
String userFieldName() default "";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,25 @@
|
|||
package com.ruoyi.common.annotation;
|
||||
|
||||
public enum DataScopes implements Comparable<DataScopes>{
|
||||
/**
|
||||
* 全部数据权限
|
||||
*/
|
||||
DATA_SCOPE_ALL,
|
||||
/**
|
||||
* 自定数据权限
|
||||
*/
|
||||
DATA_SCOPE_CUSTOM,
|
||||
/**
|
||||
* 部门数据权限
|
||||
*/
|
||||
DATA_SCOPE_DEPT,
|
||||
/**
|
||||
* 部门及以下数据权限
|
||||
*/
|
||||
DATA_SCOPE_DEPT_AND_CHILD,
|
||||
/**
|
||||
* 仅本人数据权限
|
||||
*/
|
||||
DATA_SCOPE_SELF,
|
||||
;
|
||||
}
|
||||
|
|
@ -5,9 +5,11 @@ import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
|||
import org.springframework.data.querydsl.QuerydslPredicateExecutor;
|
||||
import org.springframework.data.repository.NoRepositoryBean;
|
||||
|
||||
import javax.persistence.criteria.CriteriaBuilder;
|
||||
import javax.persistence.criteria.Predicate;
|
||||
|
||||
@NoRepositoryBean
|
||||
public interface BaseRepository<T, ID> extends JpaRepository<T, ID>,
|
||||
JpaSpecificationExecutor<T>,
|
||||
QuerydslPredicateExecutor<T> {
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,9 +1,6 @@
|
|||
package com.ruoyi.common.base;
|
||||
|
||||
import com.querydsl.core.types.dsl.BooleanExpression;
|
||||
import com.querydsl.core.types.dsl.ComparableExpression;
|
||||
import com.querydsl.core.types.dsl.NumberPath;
|
||||
import com.querydsl.core.types.dsl.StringPath;
|
||||
import com.querydsl.core.types.dsl.*;
|
||||
import com.ruoyi.common.utils.querydsl.ExpressionUtils;
|
||||
|
||||
public class BaseService {
|
||||
|
|
@ -12,7 +9,7 @@ public class BaseService {
|
|||
return ExpressionUtils.buildLike(path, value);
|
||||
}
|
||||
|
||||
protected <T extends Comparable<T>> BooleanExpression buildEqual(ComparableExpression<T> path, T value){
|
||||
protected <T extends Comparable<T>> BooleanExpression buildEqual(ComparableExpressionBase<T> path, T value){
|
||||
return ExpressionUtils.buildEqual(path, value);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -171,4 +171,5 @@ public class BaseController {
|
|||
public String redirect(String url) {
|
||||
return StringUtils.format("redirect:{}", url);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,230 @@
|
|||
package com.ruoyi.common.repository;
|
||||
|
||||
import com.querydsl.core.types.OrderSpecifier;
|
||||
import com.querydsl.core.types.Predicate;
|
||||
import org.springframework.data.domain.Example;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.data.jpa.domain.Specification;
|
||||
import org.springframework.data.jpa.repository.support.*;
|
||||
import org.springframework.data.querydsl.QuerydslPredicateExecutor;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
import javax.persistence.EntityManager;
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
|
||||
public class DataScopeRepository<T, ID extends Serializable> implements JpaRepositoryImplementation<T, ID>,
|
||||
QuerydslPredicateExecutor<T> {
|
||||
|
||||
private @Nullable
|
||||
CrudMethodMetadata metadata;
|
||||
|
||||
private SimpleJpaRepository<T, ID> simpleJpaRepository;
|
||||
private QuerydslPredicateExecutor<T> querydslPredicateExecutor;
|
||||
|
||||
public DataScopeRepository(JpaEntityInformation<T, ?> entityInformation, EntityManager entityManager) {
|
||||
Assert.notNull(entityInformation, "JpaEntityInformation must not be null!");
|
||||
Assert.notNull(entityManager, "EntityManager must not be null!");
|
||||
this.simpleJpaRepository = new SimpleJpaRepository<T, ID>(entityInformation, entityManager);
|
||||
}
|
||||
|
||||
public DataScopeRepository(Class<T> domainClass, EntityManager em) {
|
||||
this.simpleJpaRepository = new SimpleJpaRepository<T, ID>(JpaEntityInformationSupport.getEntityInformation(domainClass, em), em);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRepositoryMethodMetadata(CrudMethodMetadata crudMethodMetadata) {
|
||||
this.metadata = crudMethodMetadata;
|
||||
simpleJpaRepository.setRepositoryMethodMetadata(crudMethodMetadata);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<T> findAll() {
|
||||
return simpleJpaRepository.findAll();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<T> findAll(Sort sort) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<T> findAll(Pageable pageable) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<T> findAllById(Iterable<ID> ids) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long count() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteById(ID id) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(T entity) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteAll(Iterable<? extends T> entities) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteAll() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public <S extends T> S save(S entity) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <S extends T> List<S> saveAll(Iterable<S> entities) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<T> findById(ID id) {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean existsById(ID id) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void flush() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public <S extends T> S saveAndFlush(S entity) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteInBatch(Iterable<T> entities) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteAllInBatch() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public T getOne(ID id) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <S extends T> Optional<S> findOne(Example<S> example) {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public <S extends T> List<S> findAll(Example<S> example) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <S extends T> List<S> findAll(Example<S> example, Sort sort) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <S extends T> Page<S> findAll(Example<S> example, Pageable pageable) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <S extends T> long count(Example<S> example) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <S extends T> boolean exists(Example<S> example) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<T> findOne(Specification<T> spec) {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<T> findAll(Specification<T> spec) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<T> findAll(Specification<T> spec, Pageable pageable) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<T> findAll(Specification<T> spec, Sort sort) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long count(Specification<T> spec) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<T> findOne(Predicate predicate) {
|
||||
return querydslPredicateExecutor.findOne(predicate);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<T> findAll(Predicate predicate) {
|
||||
return querydslPredicateExecutor.findAll(predicate);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<T> findAll(Predicate predicate, Sort sort) {
|
||||
return querydslPredicateExecutor.findAll(predicate, sort);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<T> findAll(Predicate predicate, OrderSpecifier<?>... orders) {
|
||||
return querydslPredicateExecutor.findAll(predicate, orders);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<T> findAll(OrderSpecifier<?>... orders) {
|
||||
return querydslPredicateExecutor.findAll(orders);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<T> findAll(Predicate predicate, Pageable pageable) {
|
||||
return querydslPredicateExecutor.findAll(predicate, pageable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long count(Predicate predicate) {
|
||||
return querydslPredicateExecutor.count(predicate);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean exists(Predicate predicate) {
|
||||
return querydslPredicateExecutor.exists(predicate);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,9 +1,6 @@
|
|||
package com.ruoyi.common.utils.querydsl;
|
||||
|
||||
import com.querydsl.core.types.dsl.BooleanExpression;
|
||||
import com.querydsl.core.types.dsl.ComparableExpression;
|
||||
import com.querydsl.core.types.dsl.NumberPath;
|
||||
import com.querydsl.core.types.dsl.StringPath;
|
||||
import com.querydsl.core.types.dsl.*;
|
||||
|
||||
/**
|
||||
* QueryDsl 构建查询条件的工具类
|
||||
|
|
@ -35,7 +32,7 @@ public class ExpressionUtils {
|
|||
* @param <T>
|
||||
* @return
|
||||
*/
|
||||
public static <T extends Comparable<T>> BooleanExpression buildEqual(ComparableExpression<T> path, T value){
|
||||
public static <T extends Comparable<T>> BooleanExpression buildEqual(ComparableExpressionBase<T> path, T value){
|
||||
return path.eq(value);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,20 +1,32 @@
|
|||
package com.ruoyi.framework.aspectj;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import org.aspectj.lang.JoinPoint;
|
||||
import org.aspectj.lang.Signature;
|
||||
import org.aspectj.lang.annotation.Aspect;
|
||||
import org.aspectj.lang.annotation.Before;
|
||||
import org.aspectj.lang.annotation.Pointcut;
|
||||
import org.aspectj.lang.reflect.MethodSignature;
|
||||
import org.springframework.stereotype.Component;
|
||||
import com.querydsl.core.types.ExpressionUtils;
|
||||
import com.querydsl.core.types.Predicate;
|
||||
import com.ruoyi.common.annotation.DataScope;
|
||||
import com.ruoyi.common.core.domain.BaseEntity;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import com.ruoyi.framework.util.ShiroUtils;
|
||||
import com.ruoyi.system.domain.SysRole;
|
||||
import com.ruoyi.system.domain.SysUser;
|
||||
import com.ruoyi.system.service.ISysUserService;
|
||||
import org.aspectj.lang.JoinPoint;
|
||||
import org.aspectj.lang.Signature;
|
||||
import org.aspectj.lang.annotation.After;
|
||||
import org.aspectj.lang.annotation.Aspect;
|
||||
import org.aspectj.lang.annotation.Before;
|
||||
import org.aspectj.lang.annotation.Pointcut;
|
||||
import org.aspectj.lang.reflect.MethodSignature;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.persistence.EntityManager;
|
||||
import javax.persistence.PersistenceContext;
|
||||
import javax.persistence.criteria.CriteriaBuilder;
|
||||
import javax.persistence.criteria.Root;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* 数据过滤处理
|
||||
|
|
@ -24,35 +36,11 @@ import com.ruoyi.system.domain.SysUser;
|
|||
@Aspect
|
||||
@Component
|
||||
public class DataScopeAspect {
|
||||
/**
|
||||
* 全部数据权限
|
||||
*/
|
||||
public static final String DATA_SCOPE_ALL = "1";
|
||||
|
||||
/**
|
||||
* 自定数据权限
|
||||
*/
|
||||
public static final String DATA_SCOPE_CUSTOM = "2";
|
||||
|
||||
/**
|
||||
* 部门数据权限
|
||||
*/
|
||||
public static final String DATA_SCOPE_DEPT = "3";
|
||||
|
||||
/**
|
||||
* 部门及以下数据权限
|
||||
*/
|
||||
public static final String DATA_SCOPE_DEPT_AND_CHILD = "4";
|
||||
|
||||
/**
|
||||
* 仅本人数据权限
|
||||
*/
|
||||
public static final String DATA_SCOPE_SELF = "5";
|
||||
|
||||
/**
|
||||
* 数据权限过滤关键字
|
||||
*/
|
||||
public static final String DATA_SCOPE = "dataScope";
|
||||
@Autowired
|
||||
private ISysUserService userService;
|
||||
@PersistenceContext
|
||||
private EntityManager entityManager;
|
||||
|
||||
// 配置织入点
|
||||
@Pointcut("@annotation(com.ruoyi.common.annotation.DataScope)")
|
||||
|
|
@ -64,19 +52,25 @@ public class DataScopeAspect {
|
|||
handleDataScope(point);
|
||||
}
|
||||
|
||||
@After("dataScopePointCut()")
|
||||
public void doAfter(JoinPoint point) throws Throwable{
|
||||
DataScopeContextHolder.clear();
|
||||
}
|
||||
|
||||
protected void handleDataScope(final JoinPoint joinPoint) {
|
||||
// 获得注解
|
||||
SysUser currentUser = ShiroUtils.getSysUser();
|
||||
DataScope controllerDataScope = getAnnotationLog(joinPoint);
|
||||
|
||||
if (controllerDataScope == null) {
|
||||
return;
|
||||
}
|
||||
// 获取当前的用户
|
||||
SysUser currentUser = ShiroUtils.getSysUser();
|
||||
|
||||
if (currentUser != null) {
|
||||
// 如果是超级管理员,则不过滤数据
|
||||
if (!currentUser.isAdmin()) {
|
||||
dataScopeFilter(joinPoint, currentUser, controllerDataScope.deptAlias(),
|
||||
controllerDataScope.userAlias());
|
||||
dataScopeFilter(joinPoint, currentUser, controllerDataScope);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -86,40 +80,30 @@ public class DataScopeAspect {
|
|||
*
|
||||
* @param joinPoint 切点
|
||||
* @param user 用户
|
||||
* @param deptAlias 别名
|
||||
*/
|
||||
public static void dataScopeFilter(JoinPoint joinPoint, SysUser user, String deptAlias, String userAlias) {
|
||||
StringBuilder sqlString = new StringBuilder();
|
||||
private void dataScopeFilter(JoinPoint joinPoint, SysUser user, DataScope controllerDataScope) {
|
||||
user = userService.selectUserWithRolesAndPostsById(user.getUserId());
|
||||
|
||||
for (SysRole role : user.getRoles()) {
|
||||
String dataScope = role.getDataScope();
|
||||
if (DATA_SCOPE_ALL.equals(dataScope)) {
|
||||
sqlString = new StringBuilder();
|
||||
break;
|
||||
} else if (DATA_SCOPE_CUSTOM.equals(dataScope)) {
|
||||
sqlString.append(StringUtils.format(
|
||||
" OR {}.dept_id IN ( SELECT dept_id FROM sys_role_dept WHERE role_id = {} ) ", deptAlias,
|
||||
role.getRoleId()));
|
||||
} else if (DATA_SCOPE_DEPT.equals(dataScope)) {
|
||||
sqlString.append(StringUtils.format(" OR {}.dept_id = {} ", deptAlias, user.getDept().getDeptId()));
|
||||
} else if (DATA_SCOPE_DEPT_AND_CHILD.equals(dataScope)) {
|
||||
sqlString.append(StringUtils.format(
|
||||
" OR {}.dept_id IN ( SELECT dept_id FROM sys_dept WHERE dept_id = {} or find_in_set( {} , ancestors ) )",
|
||||
deptAlias, user.getDept().getDeptId(), user.getDept().getDeptId()));
|
||||
} else if (DATA_SCOPE_SELF.equals(dataScope)) {
|
||||
if (StringUtils.isNotBlank(userAlias)) {
|
||||
sqlString.append(StringUtils.format(" OR {}.user_id = {} ", userAlias, user.getUserId()));
|
||||
} else {
|
||||
// 数据权限为仅本人且没有userAlias别名不查询任何数据
|
||||
sqlString.append(" OR 1=0 ");
|
||||
}
|
||||
CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder();
|
||||
List<Predicate> predicates = new ArrayList<>();
|
||||
Set<SysRole> roles = user.getRoles();
|
||||
for(SysRole sysRole : roles){
|
||||
switch (sysRole.getDataScope()){
|
||||
case DATA_SCOPE_DEPT: //当前部门
|
||||
break;
|
||||
case DATA_SCOPE_SELF: //自己
|
||||
break;
|
||||
case DATA_SCOPE_CUSTOM: //自定义
|
||||
break;
|
||||
case DATA_SCOPE_DEPT_AND_CHILD: //子部门
|
||||
break;
|
||||
default:
|
||||
//无需过滤
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (StringUtils.isNotBlank(sqlString.toString())) {
|
||||
BaseEntity baseEntity = (BaseEntity) joinPoint.getArgs()[0];
|
||||
baseEntity.getParams().put(DATA_SCOPE, " AND (" + sqlString.substring(4) + ")");
|
||||
}
|
||||
DataScopeContextHolder.set(ExpressionUtils.anyOf(predicates));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -0,0 +1,20 @@
|
|||
package com.ruoyi.framework.aspectj;
|
||||
|
||||
import com.querydsl.core.types.Predicate;
|
||||
|
||||
public class DataScopeContextHolder {
|
||||
|
||||
private static ThreadLocal<Predicate> threadLocal = new ThreadLocal<>();
|
||||
|
||||
public static void set(Predicate predicate){
|
||||
threadLocal.set(predicate);
|
||||
}
|
||||
|
||||
public static void clear(){
|
||||
threadLocal.remove();
|
||||
}
|
||||
|
||||
public static Predicate get(){
|
||||
return threadLocal.get();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,60 @@
|
|||
package com.ruoyi.framework.aspectj;
|
||||
|
||||
import com.ruoyi.common.utils.spring.SpringUtils;
|
||||
import com.ruoyi.framework.util.ShiroUtils;
|
||||
import com.ruoyi.system.domain.SysRole;
|
||||
import com.ruoyi.system.domain.SysUser;
|
||||
import com.ruoyi.system.service.ISysUserService;
|
||||
import org.springframework.data.jpa.domain.Specification;
|
||||
|
||||
import javax.persistence.criteria.CriteriaBuilder;
|
||||
import javax.persistence.criteria.CriteriaQuery;
|
||||
import javax.persistence.criteria.Predicate;
|
||||
import javax.persistence.criteria.Root;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public abstract class MySpecification<T> implements Specification<T> {
|
||||
|
||||
@Override
|
||||
public Predicate toPredicate(Root<T> root, CriteriaQuery<?> query, CriteriaBuilder criteriaBuilder) {
|
||||
List<Predicate> predicates = new ArrayList<>();
|
||||
|
||||
//custom filter
|
||||
addPredicate(root, query, criteriaBuilder, predicates);
|
||||
|
||||
//datascope filter
|
||||
Predicate predicate = addDataScopeFilter(root, query, criteriaBuilder);
|
||||
predicates.add(predicate);
|
||||
|
||||
//条件之间是 and 关系
|
||||
return criteriaBuilder.and(predicates.toArray(new Predicate[predicates.size()]));
|
||||
}
|
||||
|
||||
public abstract void addPredicate(Root<T> root, CriteriaQuery<?> query, CriteriaBuilder criteriaBuilder, List<Predicate> predicates);
|
||||
|
||||
protected Predicate addDataScopeFilter(Root<T> root, CriteriaQuery<?> query, CriteriaBuilder criteriaBuilder){
|
||||
List<Predicate> predicates = new ArrayList<>();
|
||||
|
||||
ISysUserService userService = SpringUtils.getBean(ISysUserService.class);
|
||||
SysUser sysUser = userService.selectUserWithRolesAndPostsById(ShiroUtils.getUserId());
|
||||
|
||||
if(!sysUser.isAdmin()){
|
||||
for(SysRole sysRole : sysUser.getRoles()){
|
||||
switch (sysRole.getDataScope()){
|
||||
case DATA_SCOPE_DEPT_AND_CHILD:
|
||||
break;
|
||||
case DATA_SCOPE_CUSTOM:
|
||||
break;
|
||||
case DATA_SCOPE_SELF:
|
||||
break;
|
||||
case DATA_SCOPE_DEPT:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//条件之间是 or 关系
|
||||
return criteriaBuilder.or(predicates.toArray(new Predicate[predicates.size()]));
|
||||
}
|
||||
}
|
||||
|
|
@ -1,5 +1,6 @@
|
|||
package com.ruoyi.system.domain;
|
||||
|
||||
import com.ruoyi.common.annotation.DataScopes;
|
||||
import com.ruoyi.common.annotation.Excel;
|
||||
import com.ruoyi.common.annotation.Excel.ColumnType;
|
||||
import com.ruoyi.common.core.domain.BaseEntity;
|
||||
|
|
@ -54,7 +55,7 @@ public class SysRole extends BaseEntity {
|
|||
* 数据范围(1:所有数据权限;2:自定义数据权限;3:本部门数据权限;4:本部门及以下数据权限)
|
||||
*/
|
||||
@Excel(name = "数据范围", readConverterExp = "1=所有数据权限,2=自定义数据权限,3=本部门数据权限,4=本部门及以下数据权限")
|
||||
private String dataScope;
|
||||
private DataScopes dataScope;
|
||||
|
||||
/**
|
||||
* 角色状态(0正常 1停用)
|
||||
|
|
@ -111,11 +112,11 @@ public class SysRole extends BaseEntity {
|
|||
return roleId != null && 1L == roleId;
|
||||
}
|
||||
|
||||
public String getDataScope() {
|
||||
public DataScopes getDataScope() {
|
||||
return dataScope;
|
||||
}
|
||||
|
||||
public void setDataScope(String dataScope) {
|
||||
public void setDataScope(DataScopes dataScope) {
|
||||
this.dataScope = dataScope;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,23 @@
|
|||
package com.ruoyi.system.domain.converter;
|
||||
|
||||
import com.ruoyi.common.annotation.DataScopes;
|
||||
|
||||
import javax.persistence.AttributeConverter;
|
||||
import javax.persistence.Converter;
|
||||
import java.util.Arrays;
|
||||
|
||||
@Converter(autoApply = true)
|
||||
public class DataScopesConverter implements AttributeConverter<DataScopes, String> {
|
||||
@Override
|
||||
public String convertToDatabaseColumn(DataScopes attribute) {
|
||||
return attribute != null ? attribute.name() : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DataScopes convertToEntityAttribute(String dbData) {
|
||||
return Arrays.stream(DataScopes.values())
|
||||
.filter(dataScopes -> dataScopes.name().equals(dbData))
|
||||
.findFirst()
|
||||
.orElse(DataScopes.DATA_SCOPE_ALL);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,6 +1,7 @@
|
|||
package com.ruoyi.system.service;
|
||||
|
||||
import com.ruoyi.system.domain.SysRole;
|
||||
import com.ruoyi.system.domain.SysUser;
|
||||
import com.ruoyi.system.domain.SysUserRole;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
|
|
@ -18,9 +19,10 @@ public interface ISysRoleService {
|
|||
* 根据条件分页查询角色数据
|
||||
*
|
||||
* @param role 角色信息
|
||||
* @param user
|
||||
* @return 角色数据集合信息
|
||||
*/
|
||||
public Page<SysRole> selectRoleList(SysRole role, Pageable pageable);
|
||||
public Page<SysRole> selectRoleList(SysRole role, Pageable pageable, SysUser user);
|
||||
|
||||
/**
|
||||
* 根据用户ID查询角色
|
||||
|
|
|
|||
|
|
@ -1,10 +1,12 @@
|
|||
package com.ruoyi.system.service;
|
||||
|
||||
import com.ruoyi.system.domain.SysDept;
|
||||
import com.ruoyi.system.domain.SysUser;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* 用户 业务层
|
||||
|
|
@ -169,4 +171,6 @@ public interface ISysUserService {
|
|||
* @return 结果
|
||||
*/
|
||||
public void changeStatus(SysUser user);
|
||||
|
||||
Set<SysDept> getUserRoleDepts(Long userId);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,46 @@
|
|||
package com.ruoyi.system.service.base;
|
||||
|
||||
import com.querydsl.core.types.ExpressionUtils;
|
||||
import com.querydsl.core.types.Predicate;
|
||||
import com.querydsl.core.types.dsl.ListPath;
|
||||
import com.ruoyi.common.base.BaseService;
|
||||
import com.ruoyi.system.domain.QSysDept;
|
||||
import com.ruoyi.system.domain.SysDept;
|
||||
import com.ruoyi.system.service.ISysUserService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public class BusinessService extends BaseService {
|
||||
|
||||
@Autowired
|
||||
private ISysUserService userService;
|
||||
|
||||
/**
|
||||
* 过滤数据权限
|
||||
* @param path dept属性
|
||||
* @param userId 当前用户id
|
||||
* @return
|
||||
*/
|
||||
protected Predicate buildDataPermission(QSysDept path, Long userId){
|
||||
Set<SysDept> depts = userService.getUserRoleDepts(userId);
|
||||
List<Predicate> predicates = new ArrayList<>();
|
||||
predicates.add(ExpressionUtils.in(path, depts));
|
||||
return ExpressionUtils.allOf(predicates);
|
||||
}
|
||||
|
||||
/**
|
||||
* 过滤数据权限
|
||||
* @param path dept属性
|
||||
* @param userId 当前用户id
|
||||
* @return
|
||||
*/
|
||||
protected Predicate buildDataPermission(ListPath<SysDept, QSysDept> path, Long userId){
|
||||
Set<SysDept> depts = userService.getUserRoleDepts(userId);
|
||||
List<Predicate> predicates = new ArrayList<>();
|
||||
predicates.add(ExpressionUtils.in(path.any(), depts));
|
||||
return ExpressionUtils.allOf(predicates);
|
||||
}
|
||||
}
|
||||
|
|
@ -2,7 +2,7 @@ package com.ruoyi.system.service.impl;
|
|||
|
||||
import com.querydsl.core.types.ExpressionUtils;
|
||||
import com.querydsl.core.types.Predicate;
|
||||
import com.ruoyi.common.base.BaseService;
|
||||
import com.ruoyi.common.annotation.DataScope;
|
||||
import com.ruoyi.common.constant.UserConstants;
|
||||
import com.ruoyi.common.core.domain.BaseEntity;
|
||||
import com.ruoyi.common.core.text.Convert;
|
||||
|
|
@ -15,6 +15,7 @@ import com.ruoyi.system.domain.SysUserRole;
|
|||
import com.ruoyi.system.repository.SysRoleRepository;
|
||||
import com.ruoyi.system.repository.SysUserRepository;
|
||||
import com.ruoyi.system.service.ISysRoleService;
|
||||
import com.ruoyi.system.service.base.BusinessService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
|
|
@ -28,8 +29,9 @@ import java.util.*;
|
|||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
@DataScope(userFieldName = "user")
|
||||
@Service
|
||||
public class SysRoleServiceImpl extends BaseService implements ISysRoleService {
|
||||
public class SysRoleServiceImpl extends BusinessService implements ISysRoleService {
|
||||
|
||||
@Autowired
|
||||
private SysRoleRepository sysRoleRepository;
|
||||
|
|
@ -40,14 +42,15 @@ public class SysRoleServiceImpl extends BaseService implements ISysRoleService {
|
|||
* 根据条件分页查询角色数据
|
||||
*
|
||||
* @param role 角色信息
|
||||
* @param user
|
||||
* @return 角色数据集合信息
|
||||
*/
|
||||
@Override
|
||||
public Page<SysRole> selectRoleList(SysRole role, Pageable pageable) {
|
||||
return sysRoleRepository.findAll(getPredicate(role), pageable);
|
||||
public Page<SysRole> selectRoleList(SysRole role, Pageable pageable, SysUser user) {
|
||||
return sysRoleRepository.findAll(getPredicate(role, user), pageable);
|
||||
}
|
||||
|
||||
private Predicate getPredicate(SysRole role){
|
||||
public Predicate getPredicate(SysRole role, SysUser user){
|
||||
QSysRole qSysRole = QSysRole.sysRole;
|
||||
List<Predicate> predicates = new ArrayList<>();
|
||||
predicates.add(buildEqual(qSysRole.delFlag, BaseEntity.NOT_DELETED));
|
||||
|
|
@ -60,8 +63,8 @@ public class SysRoleServiceImpl extends BaseService implements ISysRoleService {
|
|||
if(StringUtils.isNotEmpty(role.getRoleKey())){
|
||||
predicates.add(buildLike(qSysRole.roleKey, role.getRoleKey()));
|
||||
}
|
||||
if(StringUtils.isNotEmpty(role.getDataScope())){
|
||||
predicates.add(buildEqual(qSysRole.dataScope, role.getDataScope()));
|
||||
if(role.getDataScope() != null){
|
||||
predicates.add(buildEqual(qSysRole.dataScope, role.getDataScope().name()));
|
||||
}
|
||||
if(role.getStartTime() != null){
|
||||
predicates.add(buildGreaterThanOrEqualTo(qSysRole.createTime, role.getStartTime()));
|
||||
|
|
@ -69,6 +72,7 @@ public class SysRoleServiceImpl extends BaseService implements ISysRoleService {
|
|||
if(role.getEndTime() != null){
|
||||
predicates.add(buildLessThanOrEqualTo(qSysRole.createTime, role.getEndTime()));
|
||||
}
|
||||
// predicates.add(buildDataPermission(qSysRole.depts, user.getUserId()));
|
||||
return ExpressionUtils.allOf(predicates);
|
||||
}
|
||||
|
||||
|
|
@ -108,7 +112,7 @@ public class SysRoleServiceImpl extends BaseService implements ISysRoleService {
|
|||
*/
|
||||
@Override
|
||||
public List<SysRole> selectRoleAll() {
|
||||
return sysRoleRepository.findAll(getPredicate(new SysRole()), Pageable.unpaged()).getContent();
|
||||
return sysRoleRepository.findAll(getPredicate(new SysRole(), new SysUser()), Pageable.unpaged()).getContent();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -9,8 +9,10 @@ import com.ruoyi.common.exception.BusinessException;
|
|||
import com.ruoyi.common.utils.StringUtils;
|
||||
import com.ruoyi.common.utils.security.Md5Utils;
|
||||
import com.ruoyi.system.domain.QSysUser;
|
||||
import com.ruoyi.system.domain.SysDept;
|
||||
import com.ruoyi.system.domain.SysRole;
|
||||
import com.ruoyi.system.domain.SysUser;
|
||||
import com.ruoyi.system.repository.SysRoleRepository;
|
||||
import com.ruoyi.system.repository.SysUserRepository;
|
||||
import com.ruoyi.system.service.ISysConfigService;
|
||||
import com.ruoyi.system.service.ISysUserService;
|
||||
|
|
@ -28,10 +30,7 @@ import javax.persistence.criteria.CriteriaBuilder;
|
|||
import javax.persistence.criteria.CriteriaQuery;
|
||||
import javax.persistence.criteria.Predicate;
|
||||
import javax.persistence.criteria.Root;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 用户 业务层处理
|
||||
|
|
@ -44,9 +43,10 @@ public class SysUserServiceImpl extends BaseService implements ISysUserService {
|
|||
|
||||
@Autowired
|
||||
private SysUserRepository sysUserRepository;
|
||||
|
||||
@Autowired
|
||||
private ISysConfigService configService;
|
||||
@Autowired
|
||||
private SysRoleRepository sysRoleRepository;
|
||||
|
||||
/**
|
||||
* 根据条件分页查询用户列表
|
||||
|
|
@ -414,4 +414,15 @@ public class SysUserServiceImpl extends BaseService implements ISysUserService {
|
|||
public void changeStatus(SysUser user) {
|
||||
sysUserRepository.changeStatus(user.getStatus(), user.getUserId());
|
||||
}
|
||||
|
||||
public Set<SysDept> getUserRoleDepts(Long userId){
|
||||
SysUser user = sysUserRepository.findSysUserByDelFlagAndUserId(BaseEntity.NOT_DELETED, userId);
|
||||
Set<SysDept> depts = new HashSet<>();
|
||||
Set<SysRole> roles = user.getRoles();
|
||||
for(SysRole sysRole : roles){
|
||||
sysRole = sysRoleRepository.findByRoleId(sysRole.getRoleId());
|
||||
depts.addAll(sysRole.getDepts());
|
||||
}
|
||||
return depts;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue