47 Commits
v2.2 ... v2.3

Author SHA1 Message Date
db8f960b0d 优化部分查询SQL 2018-08-06 11:45:26 +08:00
127b532825 若依 2.3 2018-08-05 12:49:07 +08:00
92fffea429 岗位名称编码唯一校验 2018-08-05 11:05:26 +08:00
32975b3ed7 支持多数据源 2018-08-06 09:00:12 +08:00
6d714b0008 Merge branch 'master' of https://gitee.com/y_project/RuoYi 2018-08-03 10:32:30 +08:00
adedb39132 404错误提示修正 2018-08-03 10:32:00 +08:00
fc862841ad 优化条件判断 2018-08-01 20:17:55 +08:00
f6798b90bf v1.0.2 2018-08-01 17:13:07 +08:00
468281ee06 若依环境使用手册v1.0.2 2018-08-01 17:11:57 +08:00
8467b7e62c TreeTable优化 2018-08-01 14:28:02 +08:00
336faf6feb 角色权限唯一校验 2018-08-01 13:17:11 +08:00
982ce06cde 完善导出权限 2018-08-01 11:42:13 +08:00
c7595fe5b6 样式优化 2018-08-01 10:12:34 +08:00
a647e22dd3 样式优化 2018-08-01 10:07:28 +08:00
8b4d3cecb4 退出方法修改 2018-07-30 17:45:25 +08:00
afea140046 提交角色禁用后可正常进入系统 2018-07-30 15:03:20 +08:00
f1bb10606b mybatis/system/MenuMapper.xml 2018-07-30 14:36:36 +08:00
95b5b12c4d 角色岗位禁用显示置灰 2018-07-30 10:31:40 +08:00
06e25ac4a3 角色岗位禁用显示置灰 2018-07-30 10:29:02 +08:00
7d74dfd0f4 删除多余js 2018-07-29 20:19:21 +08:00
f6f8c0b03a reset 2018-07-29 17:04:32 +08:00
2401c5552e !18 数据权限基础
Merge pull request !18 from yangzhengze/master
2018-07-29 15:48:31 +08:00
743caa2911 手机打开弹出层自适应 2018-07-28 20:42:00 +08:00
9d47a4c6cc 遗漏注释补充 2018-07-28 18:31:41 +08:00
6dc56c6e8d 代码生成新增 toString 2018-07-28 12:20:01 +08:00
470b234528 treetable 2018-07-28 12:10:04 +08:00
0047773f24 !17 更新treetable,之前的方案数据量大性能太差
Merge pull request !17 from Swifly/master
2018-07-27 23:34:01 +08:00
dbfcd39a7e 更新 bootstrap-treetable.css 2018-07-27 23:22:20 +08:00
28dd8a0dee 更新treetable,之前的方案数据量大性能太差 2018-07-27 23:16:59 +08:00
7d733d868c 查询优化 2018-07-27 21:56:08 +08:00
d5d7cd6592 优化下载文件 2018-07-27 21:02:50 +08:00
4d9c611a7e 优化下载文件 2018-07-27 21:02:30 +08:00
43bde8362b 部门删除校验条件修改 2018-07-26 17:47:14 +08:00
791c767aed 一些优化细节 2018-07-26 12:37:33 +08:00
f65728611a 下载数据加载遮罩层 2018-07-25 20:07:07 +08:00
67bd4d3141 inherit 2018-07-25 17:23:41 +08:00
f22af6d423 Merge pull request !15 from 诺墨/master 2018-07-24 22:39:38 +08:00
f081c89e73 字典数据条件修改 2018-07-24 22:11:04 +08:00
0fe4b96933 更正错别字 2018-07-24 21:59:53 +08:00
c42b3d8648 添加配置注释 2018-07-24 16:16:19 +08:00
9f8cb8759b format 2018-07-24 10:01:39 +08:00
cb7af9a547 Merge branch 'master' of https://gitee.com/y_project/RuoYi 2018-07-24 00:23:02 +08:00
49ef4086fa 优化代码中 条件 != “”的判断 2018-07-24 00:20:01 +08:00
19b8317cb3 代码生成insert后缀处理 2018-07-23 21:34:33 +08:00
ef5687b71c 修改字典同步修改数据 2018-07-23 20:34:01 +08:00
58b4a50fdb 修改密码更换方法 2018-07-23 17:35:56 +08:00
535f2fafc4 支持表格不分页 2018-07-23 15:33:28 +08:00
139 changed files with 1821 additions and 3017 deletions

View File

@ -4,7 +4,7 @@
性别男,若依是女儿的名字。
若依基于hplus和inspinia两套后台系统摸版开发。有需要可自行到群内下载。
若依基于hplus和inspinia两套后台系统模板开发。有需要可自行到群内下载。
http://www.zi-han.net/theme/hplus
@ -38,31 +38,27 @@ http://webapplayers.com/inspinia_admin-v2.7.1
<table>
<tr>
<td><img src="https://oscimg.oschina.net/oscnet/25b5e333768d013d45a990c152dbe4d9d6e.jpg"/></td>
<td><img src="https://oscimg.oschina.net/oscnet/55f92435662e6a799e9daac8a74fd46a1eb.jpg"/></td>
<td><img src="https://static.oschina.net/uploads/space/2018/0728/114553_jBTY_1438828.png"/></td>
</tr>
<tr>
<td><img src="https://oscimg.oschina.net/oscnet/e05d6184cde91f7bb74736a11727ac863fe.jpg"/></td>
<td><img src="https://oscimg.oschina.net/oscnet/2fc14293b0c7a2a938441bb89b3edde98c1.jpg"/></td>
<td><img src="https://static.oschina.net/uploads/space/2018/0728/114830_eIHp_1438828.png"/></td>
<td><img src="https://static.oschina.net/uploads/space/2018/0728/114854_Y5a2_1438828.png"/></td>
</tr>
<tr>
<td><img src="https://oscimg.oschina.net/oscnet/1ffdb33f4ae588dd77d7b29779154fd555e.jpg"/></td>
<td><img src="https://oscimg.oschina.net/oscnet/302762bb406c43ce7680637a793b1f67820.jpg"/></td>
<td><img src="https://static.oschina.net/uploads/space/2018/0728/114920_P8qv_1438828.png"/></td>
<td><img src="https://static.oschina.net/uploads/space/2018/0728/114946_O3jx_1438828.png"/></td>
</tr>
<tr>
<td><img src="https://oscimg.oschina.net/oscnet/c3eab05442a6ffe87fd63cb1d4855b11d39.jpg"/></td>
<td><img src="https://oscimg.oschina.net/oscnet/2b6483aa20459f9bfb9911d614ef8ac3c97.jpg"/></td>
<td><img src="https://static.oschina.net/uploads/space/2018/0728/115022_1Tnm_1438828.png"/></td>
<td><img src="https://static.oschina.net/uploads/space/2018/0728/115051_XvMW_1438828.png"/></td>
</tr>
<tr>
<td><img src="https://oscimg.oschina.net/oscnet/0aff434b32d6012dbf890c7f4603651c917.jpg"/></td>
<td><img src="https://oscimg.oschina.net/oscnet/1f1f079c084d60c41ebfdd964d32b956efa.jpg"/></td>
<td><img src="https://static.oschina.net/uploads/space/2018/0728/115117_9TZ3_1438828.png"/></td>
<td><img src="https://static.oschina.net/uploads/space/2018/0728/115130_a5xO_1438828.png"/></td>
</tr>
<tr>
<td><img src="https://oscimg.oschina.net/oscnet/3cc7a4a5885978c1799d874d7727cfcf7a0.jpg"/></td>
<td><img src="https://oscimg.oschina.net/oscnet/a323d288bf509b7180b1538fe2193d325b3.jpg"/></td>
</tr>
<tr>
<td><img src="https://oscimg.oschina.net/oscnet/09cd252f86ce338745de291a78b271313be.jpg"/></td>
<td><img src="https://oscimg.oschina.net/oscnet/10b12c7e673fee5ac3254f246354a4805b7.jpg"/></td>
<td><img src="https://static.oschina.net/uploads/space/2018/0728/115151_EuYC_1438828.png"/></td>
<td><img src="https://static.oschina.net/uploads/space/2018/0728/115212_QybT_1438828.png"/></td>
</tr>
</table>

10
pom.xml
View File

@ -5,7 +5,7 @@
<groupId>com.ruoyi</groupId>
<artifactId>RuoYi</artifactId>
<version>2.2.0</version>
<version>2.3.0</version>
<packaging>jar</packaging>
<name>RuoYi</name>
@ -114,10 +114,10 @@
<!--阿里数据库连接池 -->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid</artifactId>
<version>${druid.version}</version>
</dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid-spring-boot-starter</artifactId>
<version>${druid.version}</version>
</dependency>
<!--常用工具类 -->
<dependency>

View File

@ -67,6 +67,7 @@ create table sys_user (
insert into sys_user values(1, 106, 'admin', '若依', '00', 'ry@163.com', '15888888888', '1', '', '29c67a30398638269fe600f73a054934', '111111', '0', '0', '127.0.0.1', '2018-03-16 11-33-00', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '管理员');
insert into sys_user values(2, 108, 'ry', '若依', '00', 'ry@qq.com', '15666666666', '1', '', '8e6d98b90472783cc73c17047ddccf36', '222222', '0', '0', '127.0.0.1', '2018-03-16 11-33-00', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '测试员');
-- ----------------------------
-- 3、岗位信息表
-- ----------------------------
@ -173,62 +174,70 @@ insert into sys_menu values('1000', '用户查询', '100', '1', '#', 'F', '0',
insert into sys_menu values('1001', '用户新增', '100', '2', '#', 'F', '0', 'system:user:add', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
insert into sys_menu values('1002', '用户修改', '100', '3', '#', 'F', '0', 'system:user:edit', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
insert into sys_menu values('1003', '用户删除', '100', '4', '#', 'F', '0', 'system:user:remove', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
insert into sys_menu values('1004', '重置密码', '100', '5', '#', 'F', '0', 'system:user:resetPwd', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
insert into sys_menu values('1004', '用户导出', '100', '5', '#', 'F', '0', 'system:user:export', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
insert into sys_menu values('1005', '重置密码', '100', '5', '#', 'F', '0', 'system:user:resetPwd', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
-- 角色管理按钮
insert into sys_menu values('1005', '角色查询', '101', '1', '#', 'F', '0', 'system:role:list', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
insert into sys_menu values('1006', '角色新增', '101', '2', '#', 'F', '0', 'system:role:add', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
insert into sys_menu values('1007', '角色修改', '101', '3', '#', 'F', '0', 'system:role:edit', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
insert into sys_menu values('1008', '角色删除', '101', '4', '#', 'F', '0', 'system:role:remove', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
insert into sys_menu values('1006', '角色查询', '101', '1', '#', 'F', '0', 'system:role:list', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
insert into sys_menu values('1007', '角色新增', '101', '2', '#', 'F', '0', 'system:role:add', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
insert into sys_menu values('1008', '角色修改', '101', '3', '#', 'F', '0', 'system:role:edit', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
insert into sys_menu values('1009', '角色删除', '101', '4', '#', 'F', '0', 'system:role:remove', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
insert into sys_menu values('1010', '角色导出', '101', '4', '#', 'F', '0', 'system:role:export', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
-- 菜单管理按钮
insert into sys_menu values('1009', '菜单查询', '102', '1', '#', 'F', '0', 'system:menu:list', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
insert into sys_menu values('1010', '菜单新增', '102', '2', '#', 'F', '0', 'system:menu:add', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
insert into sys_menu values('1011', '菜单修改', '102', '3', '#', 'F', '0', 'system:menu:edit', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
insert into sys_menu values('1012', '菜单删除', '102', '4', '#', 'F', '0', 'system:menu:remove', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
insert into sys_menu values('1011', '菜单查询', '102', '1', '#', 'F', '0', 'system:menu:list', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
insert into sys_menu values('1012', '菜单新增', '102', '2', '#', 'F', '0', 'system:menu:add', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
insert into sys_menu values('1013', '菜单修改', '102', '3', '#', 'F', '0', 'system:menu:edit', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
insert into sys_menu values('1014', '菜单删除', '102', '4', '#', 'F', '0', 'system:menu:remove', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
-- 部门管理按钮
insert into sys_menu values('1013', '部门查询', '103', '1', '#', 'F', '0', 'system:dept:list', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
insert into sys_menu values('1014', '部门新增', '103', '2', '#', 'F', '0', 'system:dept:add', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
insert into sys_menu values('1015', '部门修改', '103', '3', '#', 'F', '0', 'system:dept:edit', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
insert into sys_menu values('1016', '部门删除', '103', '4', '#', 'F', '0', 'system:dept:remove', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
insert into sys_menu values('1015', '部门查询', '103', '1', '#', 'F', '0', 'system:dept:list', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
insert into sys_menu values('1016', '部门新增', '103', '2', '#', 'F', '0', 'system:dept:add', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
insert into sys_menu values('1017', '部门修改', '103', '3', '#', 'F', '0', 'system:dept:edit', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
insert into sys_menu values('1018', '部门删除', '103', '4', '#', 'F', '0', 'system:dept:remove', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
-- 岗位管理按钮
insert into sys_menu values('1017', '岗位查询', '104', '1', '#', 'F', '0', 'system:post:list', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
insert into sys_menu values('1018', '岗位新增', '104', '2', '#', 'F', '0', 'system:post:add', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
insert into sys_menu values('1019', '岗位修改', '104', '3', '#', 'F', '0', 'system:post:edit', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
insert into sys_menu values('1020', '岗位删除', '104', '4', '#', 'F', '0', 'system:post:remove', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
insert into sys_menu values('1019', '岗位查询', '104', '1', '#', 'F', '0', 'system:post:list', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
insert into sys_menu values('1020', '岗位新增', '104', '2', '#', 'F', '0', 'system:post:add', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
insert into sys_menu values('1021', '岗位修改', '104', '3', '#', 'F', '0', 'system:post:edit', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
insert into sys_menu values('1022', '岗位删除', '104', '4', '#', 'F', '0', 'system:post:remove', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
insert into sys_menu values('1023', '岗位导出', '104', '4', '#', 'F', '0', 'system:post:export', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
-- 字典管理按钮
insert into sys_menu values('1021', '字典查询', '105', '1', '#', 'F', '0', 'system:dict:list', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
insert into sys_menu values('1022', '字典新增', '105', '2', '#', 'F', '0', 'system:dict:add', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
insert into sys_menu values('1023', '字典修改', '105', '3', '#', 'F', '0', 'system:dict:edit', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
insert into sys_menu values('1024', '字典删除', '105', '4', '#', 'F', '0', 'system:dict:remove', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
insert into sys_menu values('1024', '字典查询', '105', '1', '#', 'F', '0', 'system:dict:list', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
insert into sys_menu values('1025', '字典新增', '105', '2', '#', 'F', '0', 'system:dict:add', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
insert into sys_menu values('1026', '字典修改', '105', '3', '#', 'F', '0', 'system:dict:edit', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
insert into sys_menu values('1027', '字典删除', '105', '4', '#', 'F', '0', 'system:dict:remove', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
insert into sys_menu values('1028', '字典导出', '105', '4', '#', 'F', '0', 'system:dict:export', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
-- 参数设置按钮
insert into sys_menu values('1025', '参数查询', '106', '1', '#', 'F', '0', 'system:config:list', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
insert into sys_menu values('1026', '参数新增', '106', '2', '#', 'F', '0', 'system:config:add', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
insert into sys_menu values('1027', '参数修改', '106', '3', '#', 'F', '0', 'system:config:edit', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
insert into sys_menu values('1028', '参数删除', '106', '4', '#', 'F', '0', 'system:config:remove', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
insert into sys_menu values('1029', '参数查询', '106', '1', '#', 'F', '0', 'system:config:list', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
insert into sys_menu values('1030', '参数新增', '106', '2', '#', 'F', '0', 'system:config:add', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
insert into sys_menu values('1031', '参数修改', '106', '3', '#', 'F', '0', 'system:config:edit', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
insert into sys_menu values('1032', '参数删除', '106', '4', '#', 'F', '0', 'system:config:remove', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
insert into sys_menu values('1033', '参数导出', '106', '4', '#', 'F', '0', 'system:config:export', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
-- 通知公告按钮
insert into sys_menu values('1029', '公告查询', '107', '1', '#', 'F', '0', 'system:notice:list', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
insert into sys_menu values('1030', '公告新增', '107', '2', '#', 'F', '0', 'system:notice:add', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
insert into sys_menu values('1031', '公告修改', '107', '3', '#', 'F', '0', 'system:notice:edit', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
insert into sys_menu values('1032', '公告删除', '107', '4', '#', 'F', '0', 'system:notice:remove', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
insert into sys_menu values('1034', '公告查询', '107', '1', '#', 'F', '0', 'system:notice:list', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
insert into sys_menu values('1035', '公告新增', '107', '2', '#', 'F', '0', 'system:notice:add', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
insert into sys_menu values('1036', '公告修改', '107', '3', '#', 'F', '0', 'system:notice:edit', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
insert into sys_menu values('1037', '公告删除', '107', '4', '#', 'F', '0', 'system:notice:remove', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
-- 操作日志按钮
insert into sys_menu values('1033', '操作查询', '500', '1', '#', 'F', '0', 'monitor:operlog:list', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
insert into sys_menu values('1034', '操作删除', '500', '2', '#', 'F', '0', 'monitor:operlog:remove', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
insert into sys_menu values('1035', '详细信息', '500', '3', '#', 'F', '0', 'monitor:operlog:detail', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
insert into sys_menu values('1038', '操作查询', '500', '1', '#', 'F', '0', 'monitor:operlog:list', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
insert into sys_menu values('1039', '操作删除', '500', '2', '#', 'F', '0', 'monitor:operlog:remove', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
insert into sys_menu values('1040', '详细信息', '500', '3', '#', 'F', '0', 'monitor:operlog:detail', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
insert into sys_menu values('1041', '日志导出', '500', '3', '#', 'F', '0', 'monitor:operlog:export', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
-- 登录日志按钮
insert into sys_menu values('1036', '登录查询', '501', '1', '#', 'F', '0', 'monitor:logininfor:list', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
insert into sys_menu values('1037', '登录删除', '501', '2', '#', 'F', '0', 'monitor:logininfor:remove', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
insert into sys_menu values('1042', '登录查询', '501', '1', '#', 'F', '0', 'monitor:logininfor:list', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
insert into sys_menu values('1043', '登录删除', '501', '2', '#', 'F', '0', 'monitor:logininfor:remove', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
insert into sys_menu values('1044', '日志导出', '501', '2', '#', 'F', '0', 'monitor:logininfor:export', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
-- 在线用户按钮
insert into sys_menu values('1038', '在线查询', '109', '1', '#', 'F', '0', 'monitor:online:list', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
insert into sys_menu values('1039', '批量强退', '109', '2', '#', 'F', '0', 'monitor:online:batchForceLogout', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
insert into sys_menu values('1040', '单条强退', '109', '3', '#', 'F', '0', 'monitor:online:forceLogout', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
insert into sys_menu values('1045', '在线查询', '109', '1', '#', 'F', '0', 'monitor:online:list', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
insert into sys_menu values('1046', '批量强退', '109', '2', '#', 'F', '0', 'monitor:online:batchForceLogout', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
insert into sys_menu values('1047', '单条强退', '109', '3', '#', 'F', '0', 'monitor:online:forceLogout', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
-- 定时任务按钮
insert into sys_menu values('1041', '任务查询', '110', '1', '#', 'F', '0', 'monitor:job:list', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
insert into sys_menu values('1042', '任务新增', '110', '2', '#', 'F', '0', 'monitor:job:add', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
insert into sys_menu values('1043', '任务修改', '110', '3', '#', 'F', '0', 'monitor:job:edit', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
insert into sys_menu values('1044', '任务删除', '110', '4', '#', 'F', '0', 'monitor:job:remove', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
insert into sys_menu values('1045', '状态修改', '110', '5', '#', 'F', '0', 'monitor:job:changeStatus', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
insert into sys_menu values('1048', '任务查询', '110', '1', '#', 'F', '0', 'monitor:job:list', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
insert into sys_menu values('1049', '任务新增', '110', '2', '#', 'F', '0', 'monitor:job:add', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
insert into sys_menu values('1050', '任务修改', '110', '3', '#', 'F', '0', 'monitor:job:edit', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
insert into sys_menu values('1051', '任务删除', '110', '4', '#', 'F', '0', 'monitor:job:remove', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
insert into sys_menu values('1052', '状态修改', '110', '5', '#', 'F', '0', 'monitor:job:changeStatus', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
insert into sys_menu values('1053', '任务导出', '110', '5', '#', 'F', '0', 'monitor:job:export', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
-- 代码生成按钮
insert into sys_menu values('1046', '生成查询', '113', '1', '#', 'F', '0', 'tool:gen:list', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
insert into sys_menu values('1047', '生成代码', '113', '2', '#', 'F', '0', 'tool:gen:code', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
insert into sys_menu values('1054', '生成查询', '113', '1', '#', 'F', '0', 'tool:gen:list', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
insert into sys_menu values('1055', '生成代码', '113', '2', '#', 'F', '0', 'tool:gen:code', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
-- ----------------------------
@ -329,6 +338,15 @@ insert into sys_role_menu values ('1', '1044');
insert into sys_role_menu values ('1', '1045');
insert into sys_role_menu values ('1', '1046');
insert into sys_role_menu values ('1', '1047');
insert into sys_role_menu values ('1', '1048');
insert into sys_role_menu values ('1', '1049');
insert into sys_role_menu values ('1', '1050');
insert into sys_role_menu values ('1', '1051');
insert into sys_role_menu values ('1', '1052');
insert into sys_role_menu values ('1', '1053');
insert into sys_role_menu values ('1', '1054');
insert into sys_role_menu values ('1', '1055');
-- ----------------------------
-- 8、用户与岗位关联表 用户1-N岗位
@ -400,6 +418,7 @@ insert into sys_dict_type values(7, '通知状态', 'sys_notice_status', '0',
insert into sys_dict_type values(8, '操作类型', 'sys_oper_type', '0', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '操作类型列表');
insert into sys_dict_type values(9, '系统状态', 'sys_common_status', '0', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '登录状态列表');
-- ----------------------------
-- 11、字典数据表
-- ----------------------------
@ -450,6 +469,7 @@ insert into sys_dict_data values(23, 8, '生成代码', '8', 'sys_oper_type',
insert into sys_dict_data values(24, 1, '成功', '0', 'sys_common_status', '', 'primary', 'N', '0', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '正常状态');
insert into sys_dict_data values(25, 2, '失败', '1', 'sys_common_status', '', 'danger', 'N', '0', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '停用状态');
-- ----------------------------
-- 12、参数配置表
-- ----------------------------
@ -571,7 +591,6 @@ create table sys_notice (
primary key (notice_id)
) engine=innodb auto_increment=10 default charset=utf8 comment = '通知公告表';
-- ----------------------------
-- 初始化-公告信息表数据
-- ----------------------------

View File

@ -3,15 +3,14 @@ package com.ruoyi;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
/**
* 启动程序
*
* @author ruoyi
*/
@SpringBootApplication
@EnableTransactionManagement
@SpringBootApplication(exclude = { DataSourceAutoConfiguration.class })
@MapperScan("com.ruoyi.project.*.*.mapper")
public class RuoYiApplication
{

View File

@ -4,7 +4,7 @@ import java.util.HashMap;
import java.util.Map;
/**
* 通用Map数据
* 通用数据库映射Map数据
*
* @author ruoyi
*/
@ -39,7 +39,7 @@ public class CommonMap
javaTypeMap.put("text", "String");
javaTypeMap.put("mediumtext", "String");
javaTypeMap.put("longtext", "String");
javaTypeMap.put("time", "Date");
javaTypeMap.put("time", "Date");
javaTypeMap.put("date", "Date");
javaTypeMap.put("datetime", "Date");
javaTypeMap.put("timestamp", "Date");

View File

@ -45,21 +45,21 @@ public class Constants
/**
* 当前记录起始索引
*/
public static String PAGENUM = "pageNum";
public static String PAGE_NUM = "pageNum";
/**
* 每页显示记录数
*/
public static String PAGESIZE = "pageSize";
public static String PAGE_SIZE = "pageSize";
/**
* 排序列
*/
public static String ORDERBYCOLUMN = "orderByColumn";
public static String ORDER_BY_COLUMN = "orderByColumn";
/**
* 排序的方向 "desc" 或者 "asc".
*/
public static String ISASC = "isAsc";
public static String IS_ASC = "isAsc";
}

View File

@ -0,0 +1,27 @@
package com.ruoyi.common.constant;
/**
* 权限通用常量
*
* @author ruoyi
*/
public class PermissionConstants
{
/** 新增权限 */
public static final String ADD_PERMISSION = "add";
/** 修改权限 */
public static final String EDIT_PERMISSION = "edit";
/** 删除权限 */
public static final String REMOVE_PERMISSION = "remove";
/** 导出权限 */
public static final String EXPORT_PERMISSION = "export";
/** 显示权限 */
public static final String VIEW_PERMISSION = "view";
/** 查询权限 */
public static final String LIST_PERMISSION = "list";
}

View File

@ -49,6 +49,18 @@ public class UserConstants
public final static String ROLE_NAME_UNIQUE = "0";
public final static String ROLE_NAME_NOT_UNIQUE = "1";
/** 岗位名称是否唯一的返回结果码 */
public final static String POST_NAME_UNIQUE = "0";
public final static String POST_NAME_NOT_UNIQUE = "1";
/** 角色权限是否唯一的返回结果码 */
public final static String ROLE_KEY_UNIQUE = "0";
public final static String ROLE_KEY_NOT_UNIQUE = "1";
/** 岗位编码是否唯一的返回结果码 */
public final static String POST_CODE_UNIQUE = "0";
public final static String POST_CODE_NOT_UNIQUE = "1";
/** 菜单名称是否唯一的返回结果码 */
public final static String MENU_NAME_UNIQUE = "0";
public final static String MENU_NAME_NOT_UNIQUE = "1";

View File

@ -19,8 +19,7 @@ public class InvalidExtensionException extends FileUploadException
public InvalidExtensionException(String[] allowedExtension, String extension, String filename)
{
super("filename : [" + filename + "], extension : [" + extension + "], allowed extension : ["
+ Arrays.toString(allowedExtension) + "]");
super("filename : [" + filename + "], extension : [" + extension + "], allowed extension : [" + Arrays.toString(allowedExtension) + "]");
this.allowedExtension = allowedExtension;
this.extension = extension;
this.filename = filename;

View File

@ -30,7 +30,7 @@ public class AddressUtils
}
catch (Exception e)
{
log.error("根据IP获取所在位置----------错误消息:" + e.getMessage());
log.error("获取地理位置异常:", e);
}
return address;
}

View File

@ -12,7 +12,7 @@ import com.ruoyi.common.support.StrFormatter;
*
* @author ruoyi
*/
public class StringUtils
public class StringUtils extends org.apache.commons.lang3.StringUtils
{
/** 空字符串 */
private static final String NULLSTR = "";

View File

@ -1,4 +1,4 @@
package com.ruoyi.common.utils;
package com.ruoyi.common.utils.file;
import java.io.File;
import java.io.IOException;
@ -16,16 +16,24 @@ import com.ruoyi.framework.config.RuoYiConfig;
public class FileUploadUtils
{
// 默认大小 50M
/**
* 默认大小 50M
*/
public static final long DEFAULT_MAX_SIZE = 52428800;
// 默认上传的地址
/**
* 默认上传的地址
*/
private static String defaultBaseDir = RuoYiConfig.getProfile();
// 默认的文件名最大长度
/**
* 默认的文件名最大长度
*/
public static final int DEFAULT_FILE_NAME_LENGTH = 200;
// 默认文件类型jpg
/**
* 默认文件类型jpg
*/
public static final String IMAGE_JPG_EXTENSION = ".jpg";
private static int counter = 0;

View File

@ -0,0 +1,91 @@
package com.ruoyi.common.utils.file;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.OutputStream;
/**
* 文件处理工具类
*
* @author ruoyi
*/
public class FileUtils
{
/**
* 输出指定文件的byte数组
*
* @param filename 文件
* @return
*/
public static void writeBytes(String filePath, OutputStream os) throws IOException
{
FileInputStream fis = null;
try
{
File file = new File(filePath);
if (!file.exists())
{
throw new FileNotFoundException(filePath);
}
fis = new FileInputStream(file);
byte[] b = new byte[1024];
int length;
while ((length = fis.read(b)) > 0)
{
os.write(b, 0, length);
}
}
catch (IOException e)
{
throw e;
}
finally
{
if (os != null)
{
try
{
os.close();
}
catch (IOException e1)
{
e1.printStackTrace();
}
}
if (fis != null)
{
try
{
fis.close();
}
catch (IOException e1)
{
e1.printStackTrace();
}
}
}
}
/**
* 删除文件
*
* @param filePath 文件
* @return
*/
public static boolean deleteFile(String filePath)
{
boolean flag = false;
File file = new File(filePath);
// 路径为文件且不为空则进行删除
if (file.isFile() && file.exists())
{
file.delete();
flag = true;
}
return flag;
}
}

View File

@ -1,7 +1,6 @@
package com.ruoyi.common.utils.http;
import java.io.BufferedReader;
import java.io.DataInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
@ -165,7 +164,6 @@ public class HttpUtils
return result.toString();
}
@SuppressWarnings("deprecation")
public static String sendSSLPost(String url, String param)
{
StringBuilder result = new StringBuilder();
@ -189,11 +187,10 @@ public class HttpUtils
conn.setHostnameVerifier(new TrustAnyHostnameVerifier());
conn.connect();
InputStream is = conn.getInputStream();
DataInputStream indata = new DataInputStream(is);
BufferedReader br = new BufferedReader(new InputStreamReader(is));
String ret = "";
while (ret != null)
while ((ret = br.readLine()) != null)
{
ret = indata.readLine();
if (ret != null && !ret.trim().equals(""))
{
result.append(new String(ret.getBytes("ISO-8859-1"), "utf-8"));
@ -201,7 +198,7 @@ public class HttpUtils
}
log.info("recv - {}", result);
conn.disconnect();
indata.close();
br.close();
}
catch (ConnectException e)
{

View File

@ -31,6 +31,8 @@ import org.apache.poi.ss.util.CellRangeAddressList;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.util.ResourceUtils;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.framework.aspectj.lang.annotation.Excel;
import com.ruoyi.framework.shiro.web.session.OnlineWebSessionManager;
import com.ruoyi.framework.web.domain.AjaxResult;
@ -58,28 +60,32 @@ public class ExcelUtil<T>
Workbook workbook = WorkbookFactory.create(input);
Sheet sheet = workbook.getSheet(sheetName);
if (!sheetName.trim().equals(""))
if (StringUtils.isNotEmpty(sheetName))
{
sheet = workbook.getSheet(sheetName); // 如果指定sheet名,则取指定sheet中的内容.
// 如果指定sheet名,则取指定sheet中的内容.
sheet = workbook.getSheet(sheetName);
}
if (sheet == null)
{
sheet = workbook.getSheetAt(0); // 如果传入的sheet名不存在则默认指向第1个sheet.
// 如果传入的sheet名不存在则默认指向第1个sheet.
sheet = workbook.getSheetAt(0);
}
int rows = sheet.getPhysicalNumberOfRows();
if (rows > 0)
{
// 有数据时才处理
Field[] allFields = clazz.getDeclaredFields(); // 得到类的所有field.
Map<Integer, Field> fieldsMap = new HashMap<Integer, Field>(); // 定义一个map用于存放列的序号和field.
// 有数据时才处理 得到类的所有field.
Field[] allFields = clazz.getDeclaredFields();
// 定义一个map用于存放列的序号和field.
Map<Integer, Field> fieldsMap = new HashMap<Integer, Field>();
for (int col = 0; col < allFields.length; col++)
{
Field field = allFields[col];
// 将有注解的field存放到map中.
if (field.isAnnotationPresent(Excel.class))
{
field.setAccessible(true);// 设置类的私有字段属性可访问.
// 设置类的私有字段属性可访问.
field.setAccessible(true);
fieldsMap.put(col, field);
}
}
@ -104,13 +110,15 @@ public class ExcelUtil<T>
}
String c = cell.getStringCellValue();
if (c.equals(""))
if (StringUtils.isEmpty(c))
{
continue;
}
entity = (entity == null ? clazz.newInstance() : entity);// 如果不存在实例则新建.
Field field = fieldsMap.get(j);// 从map中得到对应列的field.
// 如果不存在实例则新建.
entity = (entity == null ? clazz.newInstance() : entity);
// 从map中得到对应列的field.
Field field = fieldsMap.get(j);
// 取得类型,并根据对象类型设置值.
Class<?> fieldType = field.getType();
if (String.class == fieldType)
@ -179,7 +187,8 @@ public class ExcelUtil<T>
*/
public AjaxResult exportExcel(List<T> list, String sheetName)
{
Field[] allFields = clazz.getDeclaredFields();// 得到所有定义字段
// 得到所有定义字段
Field[] allFields = clazz.getDeclaredFields();
List<Field> fields = new ArrayList<Field>();
// 得到所有field并存放到一个list中.
for (Field field : allFields)
@ -190,32 +199,39 @@ public class ExcelUtil<T>
}
}
HSSFWorkbook workbook = new HSSFWorkbook();// 产生工作薄对象
// 产生工作薄对象
HSSFWorkbook workbook = new HSSFWorkbook();
// excel2003中每个sheet中最多有65536行
int sheetSize = 65536;
double sheetNo = Math.ceil(list.size() / sheetSize);// 取出一共有多少个sheet.
// 取出一共有多少个sheet.
double sheetNo = Math.ceil(list.size() / sheetSize);
for (int index = 0; index <= sheetNo; index++)
{
HSSFSheet sheet = workbook.createSheet();// 产生工作表对象
// 产生工作表对象
HSSFSheet sheet = workbook.createSheet();
if (sheetNo == 0)
{
workbook.setSheetName(index, sheetName);
}
else
{
workbook.setSheetName(index, sheetName + index);// 设置工作表的名称.
// 设置工作表的名称.
workbook.setSheetName(index, sheetName + index);
}
HSSFRow row;
HSSFCell cell; // 产生单元格
row = sheet.createRow(0); // 产生一行
// 产生一行
row = sheet.createRow(0);
// 写入各个字段的列头名称
for (int i = 0; i < fields.size(); i++)
{
Field field = fields.get(i);
Excel attr = field.getAnnotation(Excel.class);
cell = row.createCell(i); // 创建列
cell.setCellType(HSSFCell.CELL_TYPE_STRING); // 设置列中写入内容为String类型
// 创建列
cell = row.createCell(i);
// 设置列中写入内容为String类型
cell.setCellType(HSSFCell.CELL_TYPE_STRING);
HSSFCellStyle cellStyle = workbook.createCellStyle();
cellStyle.setAlignment(HSSFCellStyle.ALIGN_CENTER);
cellStyle.setVerticalAlignment(CellStyle.VERTICAL_CENTER);
@ -230,8 +246,10 @@ public class ExcelUtil<T>
else
{
HSSFFont font = workbook.createFont();
font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD); // 粗体显示
cellStyle.setFont(font); // 选择需要用到的字体格式
// 粗体显示
font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
// 选择需要用到的字体格式
cellStyle.setFont(font);
cellStyle.setFillForegroundColor(HSSFColor.LIGHT_YELLOW.index);
// 设置列宽
sheet.setColumnWidth(i, 3766);
@ -240,17 +258,20 @@ public class ExcelUtil<T>
cellStyle.setWrapText(true);
cell.setCellStyle(cellStyle);
cell.setCellValue(attr.name());// 写入列名
// 写入列名
cell.setCellValue(attr.name());
// 如果设置了提示信息则鼠标放上去提示.
if (!attr.prompt().trim().equals(""))
if (StringUtils.isNotEmpty(attr.prompt()))
{
setHSSFPrompt(sheet, "", attr.prompt(), 1, 100, i, i); // 这里默认设了2-101列提示.
// 这里默认设了2-101列提示.
setHSSFPrompt(sheet, "", attr.prompt(), 1, 100, i, i);
}
// 如果设置了combo属性则本列只能选择不能输入
if (attr.combo().length > 0)
{
setHSSFValidation(sheet, attr.combo(), 1, 100, i, i); // 这里默认设了2-101列只能选择不能输入.
// 这里默认设了2-101列只能选择不能输入.
setHSSFValidation(sheet, attr.combo(), 1, 100, i, i);
}
}
@ -263,18 +284,22 @@ public class ExcelUtil<T>
for (int i = startNo; i < endNo; i++)
{
row = sheet.createRow(i + 1 - startNo);
T vo = (T) list.get(i); // 得到导出对象.
// 得到导出对象.
T vo = (T) list.get(i);
for (int j = 0; j < fields.size(); j++)
{
Field field = fields.get(j); // 获得field.
field.setAccessible(true); // 设置实体类私有属性可访问
// 获得field.
Field field = fields.get(j);
// 设置实体类私有属性可访问
field.setAccessible(true);
Excel attr = field.getAnnotation(Excel.class);
try
{
// 根据Excel中设置情况决定是否导出,有些情况需要保持为空,希望用户填写这一列.
if (attr.isExport())
{
cell = row.createCell(j);// 创建cell
// 创建cell
cell = row.createCell(j);
cell.setCellStyle(cs);
try
{
@ -292,11 +317,13 @@ public class ExcelUtil<T>
cell.setCellType(HSSFCell.CELL_TYPE_STRING);
if (vo == null)
{
cell.setCellValue(""); // 如果数据存在就填入,不存在填入空格.
// 如果数据存在就填入,不存在填入空格.
cell.setCellValue("");
}
else
{
cell.setCellValue(field.get(vo) == null ? "" : String.valueOf(field.get(vo)));// 如果数据存在就填入,不存在填入空格.
// 如果数据存在就填入,不存在填入空格.
cell.setCellValue(field.get(vo) == null ? "" : String.valueOf(field.get(vo)));
}
}
@ -304,7 +331,7 @@ public class ExcelUtil<T>
}
catch (Exception e)
{
log.error("导出Excel失败{}", e);
log.error("导出Excel失败{}", e.getMessage());
}
}
}
@ -319,7 +346,7 @@ public class ExcelUtil<T>
}
catch (Exception e)
{
log.error("关闭flush失败{}", e);
log.error("关闭flush失败{}", e.getMessage());
return AjaxResult.error("导出Excel失败请联系网站管理员");
}
}
@ -329,18 +356,18 @@ public class ExcelUtil<T>
*
* @param col
*/
// public static int getExcelCol(String col)
// {
// col = col.toUpperCase();
// // 从-1开始计算,字母重1开始运算。这种总数下来算数正好相同。
// int count = -1;
// char[] cs = col.toCharArray();
// for (int i = 0; i < cs.length; i++)
// {
// count += (cs[i] - 64) * Math.pow(26, cs.length - 1 - i);
// }
// return count;
// }
// public static int getExcelCol(String col)
// {
// col = col.toUpperCase();
// // 从-1开始计算,字母重1开始运算。这种总数下来算数正好相同。
// int count = -1;
// char[] cs = col.toCharArray();
// for (int i = 0; i < cs.length; i++)
// {
// count += (cs[i] - 64) * Math.pow(26, cs.length - 1 - i);
// }
// return count;
// }
/**
* 设置单元格上提示
@ -362,9 +389,9 @@ public class ExcelUtil<T>
// 四个参数分别是:起始行、终止行、起始列、终止列
CellRangeAddressList regions = new CellRangeAddressList(firstRow, endRow, firstCol, endCol);
// 数据有效性对象
HSSFDataValidation data_validation_view = new HSSFDataValidation(regions, constraint);
data_validation_view.createPromptBox(promptTitle, promptContent);
sheet.addValidationData(data_validation_view);
HSSFDataValidation dataValidationView = new HSSFDataValidation(regions, constraint);
dataValidationView.createPromptBox(promptTitle, promptContent);
sheet.addValidationData(dataValidationView);
return sheet;
}
@ -387,8 +414,8 @@ public class ExcelUtil<T>
// 设置数据有效性加载在哪个单元格上,四个参数分别是:起始行、终止行、起始列、终止列
CellRangeAddressList regions = new CellRangeAddressList(firstRow, endRow, firstCol, endCol);
// 数据有效性对象
HSSFDataValidation data_validation_list = new HSSFDataValidation(regions, constraint);
sheet.addValidationData(data_validation_list);
HSSFDataValidation dataValidationList = new HSSFDataValidation(regions, constraint);
sheet.addValidationData(dataValidationList);
return sheet;
}

View File

@ -0,0 +1,46 @@
package com.ruoyi.common.utils.security;
import org.apache.commons.lang3.StringUtils;
import com.ruoyi.common.constant.PermissionConstants;
import com.ruoyi.common.utils.MessageUtils;
/**
* permission 工具类
*
* @author ruoyi
*/
public class PermissionUtils
{
/**
* 权限错误消息提醒
*
* @param errorMsg 错误信息
* @return
*/
public static String getMsg(String permissionsStr)
{
String permission = StringUtils.substringBetween(permissionsStr, "[", "]");
String msg = MessageUtils.message("no.view.permission", permission);
if (StringUtils.endsWithIgnoreCase(permission, PermissionConstants.ADD_PERMISSION))
{
msg = MessageUtils.message("no.create.permission", permission);
}
else if (StringUtils.endsWithIgnoreCase(permission, PermissionConstants.EDIT_PERMISSION))
{
msg = MessageUtils.message("no.update.permission", permission);
}
else if (StringUtils.endsWithIgnoreCase(permission, PermissionConstants.REMOVE_PERMISSION))
{
msg = MessageUtils.message("no.delete.permission", permission);
}
else if (StringUtils.endsWithIgnoreCase(permission, PermissionConstants.EXPORT_PERMISSION))
{
msg = MessageUtils.message("no.export.permission", permission);
}
else if (StringUtils.endsWithAny(permission, new String[] { PermissionConstants.VIEW_PERMISSION, PermissionConstants.LIST_PERMISSION }))
{
msg = MessageUtils.message("no.view.permission", permission);
}
return msg;
}
}

View File

@ -7,6 +7,7 @@ import org.apache.shiro.subject.PrincipalCollection;
import org.apache.shiro.subject.SimplePrincipalCollection;
import org.apache.shiro.subject.Subject;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.bean.BeanUtils;
import com.ruoyi.framework.shiro.realm.UserRealm;
import com.ruoyi.project.system.user.domain.User;
@ -36,8 +37,13 @@ public class ShiroUtils
public static User getUser()
{
User user = new User();
BeanUtils.copyBeanProp(user, getSubjct().getPrincipal());
User user = null;
Object obj = getSubjct().getPrincipal();
if (StringUtils.isNotNull(obj))
{
user = new User();
BeanUtils.copyBeanProp(user, obj);
}
return user;
}

View File

@ -0,0 +1,60 @@
package com.ruoyi.framework.aspectj;
import java.lang.reflect.Method;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.aspectj.lang.reflect.MethodSignature;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.framework.aspectj.lang.annotation.Ds;
import com.ruoyi.framework.datasource.DynamicDataSourceContextHolder;
/**
* 多数据源处理
*
* @author ruoyi
*/
@Aspect
@Order(1)
@Component
public class DsAspect
{
protected Logger logger = LoggerFactory.getLogger(getClass());
@Pointcut("@annotation(com.ruoyi.framework.aspectj.lang.annotation.Ds)")
public void dsPointCut()
{
}
@Around("dsPointCut()")
public Object around(ProceedingJoinPoint point) throws Throwable
{
MethodSignature signature = (MethodSignature) point.getSignature();
Method method = signature.getMethod();
if (method.isAnnotationPresent(Ds.class))
{
Ds dataSource = method.getAnnotation(Ds.class);
if (StringUtils.isNotNull(dataSource) && StringUtils.isNotEmpty(dataSource.name()))
{
DynamicDataSourceContextHolder.setDB(dataSource.name());
}
}
try
{
return point.proceed();
}
finally
{
DynamicDataSourceContextHolder.clearDB();
}
}
}

View File

@ -0,0 +1,23 @@
package com.ruoyi.framework.aspectj.lang.annotation;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import com.ruoyi.framework.aspectj.lang.constant.DataSourceName;
/**
* 自定义多数据源切换注解
*
* @author ruoyi
*/
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
public @interface Ds
{
/**
* 切换数据源值
*/
String name() default DataSourceName.MASTER;
}

View File

@ -6,7 +6,7 @@ import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* 自定义注解
* 自定义导出Excel数据注解
*
* @author ruoyi
*/

View File

@ -0,0 +1,16 @@
package com.ruoyi.framework.aspectj.lang.constant;
/**
* 多数据源别名
*
* @author ruoyi
*
*/
public class DataSourceName
{
/** 主库 */
public static final String MASTER = "master";
/** 从库 */
public static final String SLAVE = "slave";
}

View File

@ -1,161 +1,47 @@
package com.ruoyi.framework.config;
import java.sql.SQLException;
import java.util.HashMap;
import java.util.Map;
import javax.sql.DataSource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import com.alibaba.druid.pool.DruidDataSource;
import com.alibaba.druid.support.http.StatViewServlet;
import com.alibaba.druid.support.http.WebStatFilter;
import com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceBuilder;
import com.ruoyi.framework.aspectj.lang.constant.DataSourceName;
import com.ruoyi.framework.datasource.DynamicDataSource;
/**
* Druid数据库信息配置加载
* druid 配置多数据源
*
* @author ruoyi
*/
@Configuration
public class DruidConfig
{
private static final Logger log = LoggerFactory.getLogger(DruidConfig.class);
@Value("${spring.datasource.url}")
private String dbUrl;
@Value("${spring.datasource.username}")
private String username;
@Value("${spring.datasource.password}")
private String password;
@Value("${spring.datasource.driverClassName}")
private String driverClassName;
@Value("${spring.datasource.initialSize}")
private int initialSize;
@Value("${spring.datasource.minIdle}")
private int minIdle;
@Value("${spring.datasource.maxActive}")
private int maxActive;
@Value("${spring.datasource.maxWait}")
private int maxWait;
@Value("${spring.datasource.timeBetweenEvictionRunsMillis}")
private int timeBetweenEvictionRunsMillis;
@Value("${spring.datasource.minEvictableIdleTimeMillis}")
private int minEvictableIdleTimeMillis;
@Value("${spring.datasource.validationQuery}")
private String validationQuery;
@Value("${spring.datasource.testWhileIdle}")
private boolean testWhileIdle;
@Value("${spring.datasource.testOnBorrow}")
private boolean testOnBorrow;
@Value("${spring.datasource.testOnReturn}")
private boolean testOnReturn;
@Value("${spring.datasource.poolPreparedStatements}")
private boolean poolPreparedStatements;
@Value("${spring.datasource.maxPoolPreparedStatementPerConnectionSize}")
private int maxPoolPreparedStatementPerConnectionSize;
@Value("${spring.datasource.filters}")
private String filters;
@Value("{spring.datasource.connectionProperties}")
private String connectionProperties;
@Bean(initMethod = "init", destroyMethod = "close") /** 声明其为Bean实例 */
@Primary /** 在同样的DataSource中首先使用被标注的DataSource */
public DataSource dataSource()
@Bean
@ConfigurationProperties("spring.datasource.druid.master")
public DataSource masterDataSource()
{
DruidDataSource datasource = new DruidDataSource();
datasource.setUrl(this.dbUrl);
datasource.setUsername(username);
datasource.setPassword(password);
datasource.setDriverClassName(driverClassName);
/** configuration */
datasource.setInitialSize(initialSize);
datasource.setMinIdle(minIdle);
datasource.setMaxActive(maxActive);
datasource.setMaxWait(maxWait);
datasource.setTimeBetweenEvictionRunsMillis(timeBetweenEvictionRunsMillis);
datasource.setMinEvictableIdleTimeMillis(minEvictableIdleTimeMillis);
datasource.setValidationQuery(validationQuery);
datasource.setTestWhileIdle(testWhileIdle);
datasource.setTestOnBorrow(testOnBorrow);
datasource.setTestOnReturn(testOnReturn);
datasource.setPoolPreparedStatements(poolPreparedStatements);
datasource.setMaxPoolPreparedStatementPerConnectionSize(maxPoolPreparedStatementPerConnectionSize);
try
{
datasource.setFilters(filters);
}
catch (SQLException e)
{
log.error("druid configuration initialization filter", e);
}
datasource.setConnectionProperties(connectionProperties);
return datasource;
return DruidDataSourceBuilder.create().build();
}
/**
* 注册一个StatViewServlet 相当于在web.xml中声明了一个servlet
*/
@SuppressWarnings({ "rawtypes", "unchecked" })
@Bean
public ServletRegistrationBean druidServlet()
@ConfigurationProperties("spring.datasource.druid.slave")
@ConditionalOnProperty(prefix = "spring.datasource.druid.slave", name = "open", havingValue = "true")
public DataSource slaveDataSource()
{
ServletRegistrationBean reg = new ServletRegistrationBean();
reg.setServlet(new StatViewServlet());
reg.addUrlMappings("/monitor/druid/*");
/** 白名单 */
// reg.addInitParameter("allow", "10.211.61.45,127.0.0.1,123.207.20.136");
/** IP黑名单(共同存在时deny优先于allow) */
// reg.addInitParameter("deny", "10.211.61.4");
/** 是否能够重置数据 禁用HTML页面上的“Reset All”功能 */
reg.addInitParameter("resetEnable", "false");
return reg;
return DruidDataSourceBuilder.create().build();
}
/**
* 注册一个filterRegistrationBean 相当于在web.xml中声明了一个Filter
*/
@SuppressWarnings({ "rawtypes", "unchecked" })
@Bean
public FilterRegistrationBean filterRegistrationBean()
@Bean(name = "dynamicDataSource")
@Primary
public DynamicDataSource dataSource(DataSource masterDataSource, DataSource slaveDataSource)
{
FilterRegistrationBean filterRegistrationBean = new FilterRegistrationBean();
filterRegistrationBean.setFilter(new WebStatFilter());
/** 添加过滤规则. */
filterRegistrationBean.addUrlPatterns("/*");
/** 监控选项滤器 */
filterRegistrationBean.addInitParameter("DruidWebStatFilter", "/*");
/** 添加不需要忽略的格式信息. */
filterRegistrationBean.addInitParameter("exclusions", "*.js,*.gif,*.jpg,*.png,*.css,*.ico,/monitor/druid/*");
/** 配置profileEnable能够监控单个url调用的sql列表 */
filterRegistrationBean.addInitParameter("profileEnable", "true");
/** 当前的cookie的用户 */
filterRegistrationBean.addInitParameter("principalCookieName", "USER_COOKIE");
/** 当前的session的用户 */
filterRegistrationBean.addInitParameter("principalSessionName", "USER_SESSION");
return filterRegistrationBean;
Map<Object, Object> targetDataSources = new HashMap<>();
targetDataSources.put(DataSourceName.MASTER, masterDataSource);
targetDataSources.put(DataSourceName.SLAVE, slaveDataSource);
return new DynamicDataSource(masterDataSource, targetDataSources);
}
}

View File

@ -2,9 +2,7 @@ package com.ruoyi.framework.config;
import java.util.LinkedHashMap;
import java.util.Map;
import javax.servlet.Filter;
import org.apache.shiro.cache.ehcache.EhCacheManager;
import org.apache.shiro.codec.Base64;
import org.apache.shiro.mgt.SecurityManager;
@ -13,12 +11,10 @@ import org.apache.shiro.spring.web.ShiroFilterFactoryBean;
import org.apache.shiro.web.mgt.CookieRememberMeManager;
import org.apache.shiro.web.mgt.DefaultWebSecurityManager;
import org.apache.shiro.web.servlet.SimpleCookie;
import org.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreator;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.framework.shiro.realm.UserRealm;
import com.ruoyi.framework.shiro.session.OnlineSessionDAO;
@ -29,7 +25,6 @@ import com.ruoyi.framework.shiro.web.filter.online.OnlineSessionFilter;
import com.ruoyi.framework.shiro.web.filter.sync.SyncOnlineSessionFilter;
import com.ruoyi.framework.shiro.web.session.OnlineWebSessionManager;
import com.ruoyi.framework.shiro.web.session.SpringSessionValidationScheduler;
import at.pollux.thymeleaf.shiro.dialect.ShiroDialect;
/**
@ -336,17 +331,6 @@ public class ShiroConfig
return cookieRememberMeManager;
}
/**
* 开启Shiro代理
*/
@Bean
public DefaultAdvisorAutoProxyCreator defaultAdvisorAutoProxyCreator()
{
DefaultAdvisorAutoProxyCreator proxyCreator = new DefaultAdvisorAutoProxyCreator();
proxyCreator.setProxyTargetClass(true);
return proxyCreator;
}
/**
* thymeleaf模板引擎和shiro框架的整合
*/

View File

@ -0,0 +1,27 @@
package com.ruoyi.framework.datasource;
import java.util.Map;
import javax.sql.DataSource;
import org.springframework.jdbc.datasource.lookup.AbstractRoutingDataSource;
/**
* 动态数据源
*
* @author ruoyi
*/
public class DynamicDataSource extends AbstractRoutingDataSource
{
public DynamicDataSource(DataSource defaultTargetDataSource, Map<Object, Object> targetDataSources)
{
super.setDefaultTargetDataSource(defaultTargetDataSource);
super.setTargetDataSources(targetDataSources);
super.afterPropertiesSet();
}
@Override
protected Object determineCurrentLookupKey()
{
return DynamicDataSourceContextHolder.getDB();
}
}

View File

@ -0,0 +1,42 @@
package com.ruoyi.framework.datasource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* 当前线程数据源
*
* @author ruoyi
*/
public class DynamicDataSourceContextHolder
{
public static final Logger log = LoggerFactory.getLogger(DynamicDataSourceContextHolder.class);
private static final ThreadLocal<String> CONTEXT_HOLDER = new ThreadLocal<>();
/**
* 设置数据源名
*/
public static void setDB(String dbType)
{
log.info("切换到{}数据源", dbType);
CONTEXT_HOLDER.set(dbType);
}
/**
* 获取数据源名
*/
public static String getDB()
{
return CONTEXT_HOLDER.get();
}
/**
* 清理数据源名
*/
public static void clearDB()
{
CONTEXT_HOLDER.remove();
}
}

View File

@ -87,15 +87,5 @@ public class PasswordService
{
//System.out.println(new PasswordService().encryptPassword("admin", "admin123", "111111"));
//System.out.println(new PasswordService().encryptPassword("ry", "admin123", "222222"));
System.out.println(new PasswordService().encryptPassword("ly", "admin123", "123456"));
System.out.println(new PasswordService().encryptPassword("ce", "admin123", "123456"));
System.out.println(new PasswordService().encryptPassword("zs", "admin123", "123456"));
System.out.println(new PasswordService().encryptPassword("ls", "admin123", "123456"));
System.out.println(new PasswordService().encryptPassword("ww", "admin123", "123456"));
System.out.println(new PasswordService().encryptPassword("zl", "admin123", "123456"));
System.out.println(new PasswordService().encryptPassword("sq", "admin123", "123456"));
System.out.println(new PasswordService().encryptPassword("zb", "admin123", "123456"));
System.out.println(new PasswordService().encryptPassword("wj", "admin123", "123456"));
System.out.println(new PasswordService().encryptPassword("ys", "admin123", "123456"));
}
}

View File

@ -46,7 +46,7 @@ public class LogoutFilter extends org.apache.shiro.web.filter.authc.LogoutFilter
String redirectUrl = getRedirectUrl(request, response, subject);
try
{
User user = (User) ShiroUtils.getSubjct().getPrincipal();
User user = ShiroUtils.getUser();
if (StringUtils.isNotNull(user))
{
String loginName = user.getLoginName();
@ -64,7 +64,7 @@ public class LogoutFilter extends org.apache.shiro.web.filter.authc.LogoutFilter
}
catch (Exception e)
{
log.debug("Encountered session exception during logout. This can generally safely be ignored.", e);
log.error("Encountered session exception during logout. This can generally safely be ignored.", e);
}
return false;
}

View File

@ -121,9 +121,7 @@ public class SpringSessionValidationScheduler implements SessionValidationSchedu
{
if (log.isErrorEnabled())
{
log.error(
"Error starting the Spring Scheduler session validation job. Session validation may not occur.",
e);
log.error("Error starting the Spring Scheduler session validation job. Session validation may not occur.", e);
}
}
}

View File

@ -56,6 +56,7 @@ public class BaseController
protected TableDataInfo getDataTable(List<?> list)
{
TableDataInfo rspData = new TableDataInfo();
rspData.setCode(0);
rspData.setRows(list);
rspData.setTotal(new PageInfo(list).getTotal());
return rspData;

View File

@ -6,8 +6,8 @@ import org.slf4j.LoggerFactory;
import org.springframework.web.HttpRequestMethodNotSupportedException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;
import com.ruoyi.common.exception.DemoModeException;
import com.ruoyi.common.utils.security.PermissionUtils;
import com.ruoyi.framework.web.domain.AjaxResult;
/**
@ -27,7 +27,7 @@ public class DefaultExceptionHandler
public AjaxResult handleAuthorizationException(AuthorizationException e)
{
log.error(e.getMessage(), e);
return AjaxResult.error("您没有数据的权限,请联系管理员添加");
return AjaxResult.error(PermissionUtils.getMsg(e.getMessage()));
}
/**

View File

@ -15,6 +15,8 @@ public class TableDataInfo implements Serializable
private long total;
/** 列表数据 */
private List<?> rows;
/** 消息状态码 */
private int code;
/**
* 表格数据对象
@ -55,4 +57,13 @@ public class TableDataInfo implements Serializable
this.rows = rows;
}
public int getCode()
{
return code;
}
public void setCode(int code)
{
this.code = code;
}
}

View File

@ -16,10 +16,10 @@ public class TableSupport
public static PageDomain getPageDomain()
{
PageDomain pageDomain = new PageDomain();
pageDomain.setPageNum(ServletUtils.getParameterToInt(Constants.PAGENUM));
pageDomain.setPageSize(ServletUtils.getParameterToInt(Constants.PAGESIZE));
pageDomain.setOrderByColumn(ServletUtils.getParameter(Constants.ORDERBYCOLUMN));
pageDomain.setIsAsc(ServletUtils.getParameter(Constants.ISASC));
pageDomain.setPageNum(ServletUtils.getParameterToInt(Constants.PAGE_NUM));
pageDomain.setPageSize(ServletUtils.getParameterToInt(Constants.PAGE_SIZE));
pageDomain.setOrderByColumn(ServletUtils.getParameter(Constants.ORDER_BY_COLUMN));
pageDomain.setIsAsc(ServletUtils.getParameter(Constants.IS_ASC));
return pageDomain;
}

View File

@ -18,14 +18,7 @@ public class PermissionService
private boolean isPermittedOperator(String permission)
{
if (SecurityUtils.getSubject().isPermitted(permission))
{
return true;
}
else
{
return false;
}
return SecurityUtils.getSubject().isPermitted(permission);
}
}

View File

@ -1,10 +1,5 @@
package com.ruoyi.project.common;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import javax.servlet.http.HttpServletRequest;
@ -14,6 +9,7 @@ import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.util.ResourceUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import com.ruoyi.common.utils.file.FileUtils;
/**
* 通用请求处理
@ -29,8 +25,6 @@ public class CommonController
public void fileDownload(String fileName, Boolean delete, HttpServletResponse response, HttpServletRequest request)
{
String realFileName = System.currentTimeMillis() + fileName.substring(fileName.indexOf("_") + 1);
InputStream inputStream = null;
OutputStream os = null;
try
{
String filePath = ResourceUtils.getURL("classpath:").getPath() + "static/file/" + fileName;
@ -38,36 +32,16 @@ public class CommonController
response.setCharacterEncoding("utf-8");
response.setContentType("multipart/form-data");
response.setHeader("Content-Disposition", "attachment;fileName=" + setFileDownloadHeader(request, realFileName));
File file = new File(filePath);
inputStream = new FileInputStream(file);
os = response.getOutputStream();
byte[] b = new byte[1024];
int length;
while ((length = inputStream.read(b)) > 0)
FileUtils.writeBytes(filePath, response.getOutputStream());
if (delete)
{
os.write(b, 0, length);
}
if (delete && file.exists())
{
file.delete();
FileUtils.deleteFile(filePath);
}
}
catch (Exception e)
{
log.error("下载文件失败", e);
}
finally
{
try
{
os.close();
inputStream.close();
}
catch (IOException e)
{
log.error("close close fail ", e);
}
}
}
public String setFileDownloadHeader(HttpServletRequest request, String fileName) throws UnsupportedEncodingException

View File

@ -51,6 +51,7 @@ public class JobController extends BaseController
}
@Log(title = "定时任务", action = BusinessType.EXPORT)
@RequiresPermissions("monitor:job:export")
@PostMapping("/export")
@ResponseBody
public AjaxResult export(Job job) throws Exception

View File

@ -49,6 +49,7 @@ public class JobLogController extends BaseController
}
@Log(title = "调度日志", action = BusinessType.EXPORT)
@RequiresPermissions("monitor:job:export")
@PostMapping("/export")
@ResponseBody
public AjaxResult export(JobLog jobLog) throws Exception

View File

@ -54,7 +54,7 @@ public class ScheduleUtils
}
catch (SchedulerException e)
{
log.error(e.getMessage());
log.error("getCronTrigger 异常:", e);
}
return null;
}
@ -89,11 +89,11 @@ public class ScheduleUtils
}
catch (SchedulerException e)
{
log.error(e.getMessage());
log.error("createScheduleJob 异常:", e);
}
catch (TaskException e)
{
log.error(e.getMessage());
log.error("createScheduleJob 异常:", e);
}
}
@ -129,11 +129,11 @@ public class ScheduleUtils
}
catch (SchedulerException e)
{
log.error(e.getMessage());
log.error("SchedulerException 异常:", e);
}
catch (TaskException e)
{
log.error(e.getMessage());
log.error("SchedulerException 异常:", e);
}
}
@ -154,7 +154,7 @@ public class ScheduleUtils
}
catch (SchedulerException e)
{
log.error(e.getMessage());
log.error("run 异常:", e);
}
return rows;
}
@ -170,7 +170,7 @@ public class ScheduleUtils
}
catch (SchedulerException e)
{
log.error(e.getMessage());
log.error("pauseJob 异常:", e);
}
}
@ -185,7 +185,7 @@ public class ScheduleUtils
}
catch (SchedulerException e)
{
log.error(e.getMessage());
log.error("resumeJob 异常:", e);
}
}
@ -200,7 +200,7 @@ public class ScheduleUtils
}
catch (SchedulerException e)
{
log.error(e.getMessage());
log.error("deleteScheduleJob 异常:", e);
}
}

View File

@ -49,6 +49,7 @@ public class LogininforController extends BaseController
}
@Log(title = "登陆日志", action = BusinessType.EXPORT)
@RequiresPermissions("monitor:logininfor:export")
@PostMapping("/export")
@ResponseBody
public AjaxResult export(Logininfor logininfor) throws Exception

View File

@ -6,6 +6,7 @@ import org.apache.shiro.session.Session;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.framework.shiro.session.OnlineSessionDAO;
import com.ruoyi.project.monitor.online.domain.UserOnline;
import com.ruoyi.project.monitor.online.mapper.UserOnlineMapper;
@ -46,7 +47,7 @@ public class UserOnlineServiceImpl implements IUserOnlineService
public void deleteOnlineById(String sessionId)
{
UserOnline userOnline = selectOnlineById(sessionId);
if (userOnline != null)
if (StringUtils.isNotNull(userOnline))
{
userOnlineDao.deleteOnlineById(sessionId);
}
@ -64,7 +65,7 @@ public class UserOnlineServiceImpl implements IUserOnlineService
for (String sessionId : sessions)
{
UserOnline userOnline = selectOnlineById(sessionId);
if (userOnline != null)
if (StringUtils.isNotNull(userOnline))
{
userOnlineDao.deleteOnlineById(sessionId);
}

View File

@ -51,6 +51,7 @@ public class OperlogController extends BaseController
}
@Log(title = "操作日志", action = BusinessType.EXPORT)
@RequiresPermissions("monitor:operlog:export")
@PostMapping("/export")
@ResponseBody
public AjaxResult export(OperLog operLog) throws Exception

View File

@ -10,6 +10,7 @@ import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.constant.BusinessType;
@ -54,6 +55,7 @@ public class ConfigController extends BaseController
}
@Log(title = "参数管理", action = BusinessType.EXPORT)
@RequiresPermissions("system:config:export")
@PostMapping("/export")
@ResponseBody
public AjaxResult export(Config config) throws Exception
@ -97,7 +99,7 @@ public class ConfigController extends BaseController
@GetMapping("/edit/{configId}")
public String edit(@PathVariable("configId") Long configId, ModelMap mmap)
{
mmap.addAttribute("config", configService.selectConfigById(configId));
mmap.put("config", configService.selectConfigById(configId));
return prefix + "/edit";
}
@ -133,7 +135,7 @@ public class ConfigController extends BaseController
public String checkConfigKeyUnique(Config config)
{
String uniqueFlag = "0";
if (config != null)
if (StringUtils.isNotNull(config))
{
uniqueFlag = configService.checkConfigKeyUnique(config);
}

View File

@ -11,6 +11,7 @@ import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.constant.BusinessType;
import com.ruoyi.framework.web.controller.BaseController;
@ -120,7 +121,7 @@ public class DeptController extends BaseController
public String checkDeptNameUnique(Dept dept)
{
String uniqueFlag = "0";
if (dept != null)
if (StringUtils.isNotNull(dept))
{
uniqueFlag = deptService.checkDeptNameUnique(dept);
}

View File

@ -29,6 +29,7 @@ public interface DeptMapper
/**
* 查询部门管理数据
*
* @param dept 部门信息
* @return 部门信息集合
*/
public List<Dept> selectDeptList(Dept dept);

View File

@ -15,6 +15,7 @@ public interface IDeptService
/**
* 查询部门管理数据
*
* @param dept 部门信息
* @return 部门信息集合
*/
public List<Dept> selectDeptList(Dept dept);

View File

@ -51,6 +51,7 @@ public class DictDataController extends BaseController
}
@Log(title = "字典数据", action = BusinessType.EXPORT)
@RequiresPermissions("system:dict:export")
@PostMapping("/export")
@ResponseBody
public AjaxResult export(DictData dictData) throws Exception

View File

@ -10,6 +10,7 @@ import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.constant.BusinessType;
@ -51,6 +52,7 @@ public class DictTypeController extends BaseController
}
@Log(title = "字典类型", action = BusinessType.EXPORT)
@RequiresPermissions("system:dict:export")
@PostMapping("/export")
@ResponseBody
public AjaxResult export(DictType dictType) throws Exception
@ -146,7 +148,7 @@ public class DictTypeController extends BaseController
public String checkDictTypeUnique(DictType dictType)
{
String uniqueFlag = "0";
if (dictType != null)
if (StringUtils.isNotNull(dictType))
{
uniqueFlag = dictTypeService.checkDictTypeUnique(dictType);
}

View File

@ -87,4 +87,13 @@ public interface DictDataMapper
*/
public int updateDictData(DictData dictData);
/**
* 同步修改字典类型
*
* @param oldDictType 旧字典类型
* @param newDictType 新旧字典类型
* @return 结果
*/
public int updateDictDataType(@Param("oldDictType") String oldDictType, @Param("newDictType") String newDictType);
}

View File

@ -50,6 +50,7 @@ public class DictDataServiceImpl implements IDictDataService
* @param dictValue 字典键值
* @return 字典标签
*/
@Override
public String selectDictLabel(String dictType, String dictValue)
{
return dictDataMapper.selectDictLabel(dictType, dictValue);

View File

@ -117,6 +117,8 @@ public class DictTypeServiceImpl implements IDictTypeService
public int updateDictType(DictType dictType)
{
dictType.setUpdateBy(ShiroUtils.getLoginName());
DictType oldDict = dictTypeMapper.selectDictTypeById(dictType.getDictId());
dictDataMapper.updateDictDataType(oldDict.getDictType(), dictType.getDictType());
return dictTypeMapper.updateDictType(dictType);
}
@ -131,7 +133,7 @@ public class DictTypeServiceImpl implements IDictTypeService
{
Long dictId = StringUtils.isNull(dict.getDictId()) ? -1L : dict.getDictId();
DictType dictType = dictTypeMapper.checkDictTypeUnique(dict.getDictType());
if (StringUtils.isNotNull(dictType) && dictType.getDictId() != dictId)
if (StringUtils.isNotNull(dictType) && dictType.getDictId().longValue() != dictId.longValue())
{
return UserConstants.DICT_TYPE_NOT_UNIQUE;
}

View File

@ -46,6 +46,7 @@ public interface IDictTypeService
*
* @param ids 需要删除的数据
* @return 结果
* @throws Exception 异常
*/
public int deleteDictTypeByIds(String ids) throws Exception;

View File

@ -11,6 +11,7 @@ import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.constant.BusinessType;
import com.ruoyi.framework.web.controller.BaseController;
@ -142,7 +143,7 @@ public class MenuController extends BaseController
public String checkMenuNameUnique(Menu menu)
{
String uniqueFlag = "0";
if (menu != null)
if (StringUtils.isNotNull(menu))
{
uniqueFlag = menuService.checkMenuNameUnique(menu);
}

View File

@ -34,10 +34,11 @@ public interface MenuMapper
* @return 菜单列表
*/
public List<String> selectMenuTree(Long roleId);
/**
* 查询系统菜单列表
*
* @param menu 菜单信息
* @return 菜单列表
*/
public List<Menu> selectMenuList(Menu menu);
@ -64,7 +65,7 @@ public interface MenuMapper
* @return 菜单信息
*/
public Menu selectMenuById(Long menuId);
/**
* 查询菜单数量
*
@ -80,7 +81,7 @@ public interface MenuMapper
* @return 结果
*/
public int insertMenu(Menu menu);
/**
* 修改菜单信息
*
@ -88,7 +89,7 @@ public interface MenuMapper
* @return 结果
*/
public int updateMenu(Menu menu);
/**
* 校验菜单名称是否唯一
*

View File

@ -26,6 +26,7 @@ public interface IMenuService
/**
* 查询系统菜单列表
*
* @param menu 菜单信息
* @return 菜单列表
*/
public List<Menu> selectMenuList(Menu menu);

View File

@ -119,7 +119,6 @@ public class MenuServiceImpl implements IMenuService
/**
* 查询所有菜单
*
* @param role 角色对象
* @return 菜单列表
*/
@Override

View File

@ -1,6 +1,7 @@
package com.ruoyi.project.system.post.controller;
import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
@ -10,6 +11,8 @@ import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.constant.BusinessType;
@ -51,6 +54,7 @@ public class PostController extends BaseController
}
@Log(title = "岗位管理", action = BusinessType.EXPORT)
@RequiresPermissions("system:post:export")
@PostMapping("/export")
@ResponseBody
public AjaxResult export(Post post) throws Exception
@ -126,4 +130,34 @@ public class PostController extends BaseController
return toAjax(postService.updatePost(post));
}
/**
* 校验岗位名称
*/
@PostMapping("/checkPostNameUnique")
@ResponseBody
public String checkPostNameUnique(Post post)
{
String uniqueFlag = "0";
if (StringUtils.isNotNull(post))
{
uniqueFlag = postService.checkPostNameUnique(post);
}
return uniqueFlag;
}
/**
* 校验岗位编码
*/
@PostMapping("/checkPostCodeUnique")
@ResponseBody
public String checkPostCodeUnique(Post post)
{
String uniqueFlag = "0";
if (StringUtils.isNotNull(post))
{
uniqueFlag = postService.checkPostCodeUnique(post);
}
return uniqueFlag;
}
}

View File

@ -66,4 +66,20 @@ public interface PostMapper
*/
public int insertPost(Post post);
/**
* 校验岗位名称
*
* @param postName 岗位名称
* @return 结果
*/
public Post checkPostNameUnique(String postName);
/**
* 校验岗位编码
*
* @param postCode 岗位编码
* @return 结果
*/
public Post checkPostCodeUnique(String postCode);
}

View File

@ -45,6 +45,8 @@ public interface IPostService
* 批量删除岗位信息
*
* @param ids 需要删除的数据ID
* @return 结果
* @throws Exception 异常
*/
public int deletePostByIds(String ids) throws Exception;
@ -71,4 +73,20 @@ public interface IPostService
* @return 结果
*/
public int countUserPostById(Long postId);
/**
* 校验岗位名称
*
* @param post 岗位信息
* @return 结果
*/
public String checkPostNameUnique(Post post);
/**
* 校验岗位编码
*
* @param post 岗位信息
* @return 结果
*/
public String checkPostCodeUnique(Post post);
}

View File

@ -3,7 +3,9 @@ package com.ruoyi.project.system.post.service;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.common.constant.UserConstants;
import com.ruoyi.common.support.Convert;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.security.ShiroUtils;
import com.ruoyi.project.system.post.domain.Post;
import com.ruoyi.project.system.post.mapper.PostMapper;
@ -61,7 +63,7 @@ public class PostServiceImpl implements IPostService
{
for (Post userRole : userPosts)
{
if (post.getPostId() == userRole.getPostId())
if (post.getPostId().longValue() == userRole.getPostId().longValue())
{
post.setFlag(true);
break;
@ -142,4 +144,40 @@ public class PostServiceImpl implements IPostService
return userPostMapper.countUserPostById(postId);
}
/**
* 校验岗位名称是否唯一
*
* @param post 岗位信息
* @return 结果
*/
@Override
public String checkPostNameUnique(Post post)
{
Long postId = StringUtils.isNull(post.getPostId()) ? -1L : post.getPostId();
Post info = postMapper.checkPostNameUnique(post.getPostName());
if (StringUtils.isNotNull(info) && info.getPostId().longValue() != postId.longValue())
{
return UserConstants.POST_NAME_NOT_UNIQUE;
}
return UserConstants.POST_NAME_UNIQUE;
}
/**
* 校验岗位编码是否唯一
*
* @param post 岗位信息
* @return 结果
*/
@Override
public String checkPostCodeUnique(Post post)
{
Long postId = StringUtils.isNull(post.getPostId()) ? -1L : post.getPostId();
Post info = postMapper.checkPostCodeUnique(post.getPostCode());
if (StringUtils.isNotNull(info) && info.getPostId().longValue() != postId.longValue())
{
return UserConstants.POST_CODE_NOT_UNIQUE;
}
return UserConstants.POST_CODE_UNIQUE;
}
}

View File

@ -11,6 +11,7 @@ import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.constant.BusinessType;
@ -53,6 +54,7 @@ public class RoleController extends BaseController
}
@Log(title = "角色管理", action = BusinessType.EXPORT)
@RequiresPermissions("system:role:export")
@PostMapping("/export")
@ResponseBody
public AjaxResult export(Role role) throws Exception
@ -139,12 +141,27 @@ public class RoleController extends BaseController
public String checkRoleNameUnique(Role role)
{
String uniqueFlag = "0";
if (role != null)
if (StringUtils.isNotNull(role))
{
uniqueFlag = roleService.checkRoleNameUnique(role);
}
return uniqueFlag;
}
/**
* 校验角色权限
*/
@PostMapping("/checkRoleKeyUnique")
@ResponseBody
public String checkRoleKeyUnique(Role role)
{
String uniqueFlag = "0";
if (StringUtils.isNotNull(role))
{
uniqueFlag = roleService.checkRoleKeyUnique(role);
}
return uniqueFlag;
}
/**
* 选择菜单树

View File

@ -81,5 +81,13 @@ public interface RoleMapper
* @return 角色信息
*/
public Role checkRoleNameUnique(String roleName);
/**
* 校验角色权限是否唯一
*
* @param roleKey 角色权限
* @return 角色信息
*/
public Role checkRoleKeyUnique(String roleKey);
}

View File

@ -63,6 +63,8 @@ public interface IRoleService
* 批量删除角色用户信息
*
* @param ids 需要删除的数据ID
* @return 结果
* @throws Exception 异常
*/
public int deleteRoleByIds(String ids) throws Exception;
@ -89,6 +91,14 @@ public interface IRoleService
* @return 结果
*/
public String checkRoleNameUnique(Role role);
/**
* 校验角色权限是否唯一
*
* @param role 角色信息
* @return 结果
*/
public String checkRoleKeyUnique(Role role);
/**
* 通过角色ID查询角色使用数量

View File

@ -1,240 +1,258 @@
package com.ruoyi.project.system.role.service;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.common.constant.UserConstants;
import com.ruoyi.common.support.Convert;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.security.ShiroUtils;
import com.ruoyi.project.system.role.domain.Role;
import com.ruoyi.project.system.role.domain.RoleMenu;
import com.ruoyi.project.system.role.mapper.RoleMapper;
import com.ruoyi.project.system.role.mapper.RoleMenuMapper;
import com.ruoyi.project.system.user.mapper.UserRoleMapper;
/**
* 角色 业务层处理
*
* @author ruoyi
*/
@Service
public class RoleServiceImpl implements IRoleService
{
@Autowired
private RoleMapper roleMapper;
@Autowired
private RoleMenuMapper roleMenuMapper;
@Autowired
private UserRoleMapper userRoleMapper;
/**
* 根据条件分页查询角色数据
*
* @param role 角色信息
* @return 角色数据集合信息
*/
@Override
public List<Role> selectRoleList(Role role)
{
return roleMapper.selectRoleList(role);
}
/**
* 根据用户ID查询权限
*
* @param userId 用户ID
* @return 权限列表
*/
@Override
public Set<String> selectRoleKeys(Long userId)
{
List<Role> perms = roleMapper.selectRolesByUserId(userId);
Set<String> permsSet = new HashSet<>();
for (Role perm : perms)
{
if (StringUtils.isNotNull(perms))
{
permsSet.addAll(Arrays.asList(perm.getRoleKey().trim().split(",")));
}
}
return permsSet;
}
/**
* 根据用户ID查询角色
*
* @param userId 用户ID
* @return 角色列表
*/
@Override
public List<Role> selectRolesByUserId(Long userId)
{
List<Role> userRoles = roleMapper.selectRolesByUserId(userId);
List<Role> roles = roleMapper.selectRolesAll();
for (Role role : roles)
{
for (Role userRole : userRoles)
{
if (role.getRoleId() == userRole.getRoleId())
{
role.setFlag(true);
break;
}
}
}
return roles;
}
/**
* 查询所有角色
*
* @return 角色列表
*/
@Override
public List<Role> selectRoleAll()
{
return roleMapper.selectRolesAll();
}
/**
* 通过角色ID查询角色
*
* @param roleId 角色ID
* @return 角色对象信息
*/
@Override
public Role selectRoleById(Long roleId)
{
return roleMapper.selectRoleById(roleId);
}
/**
* 通过角色ID删除角色
*
* @param roleId 角色ID
* @return 结果
*/
@Override
public boolean deleteRoleById(Long roleId)
{
return roleMapper.deleteRoleById(roleId) > 0 ? true : false;
}
/**
* 批量删除角色信息
*
* @param ids 需要删除的数据ID
* @throws Exception
*/
@Override
public int deleteRoleByIds(String ids) throws Exception
{
Long[] roleIds = Convert.toLongArray(ids);
for (Long roleId : roleIds)
{
Role role = selectRoleById(roleId);
if (countUserRoleByRoleId(roleId) > 0)
{
throw new Exception(String.format("%1$s已分配,不能删除", role.getRoleName()));
}
}
return roleMapper.deleteRoleByIds(roleIds);
}
/**
* 新增保存角色信息
*
* @param role 角色信息
* @return 结果
*/
@Override
public int insertRole(Role role)
{
role.setCreateBy(ShiroUtils.getLoginName());
// 新增角色信息
roleMapper.insertRole(role);
ShiroUtils.clearCachedAuthorizationInfo();
return insertRoleMenu(role);
}
/**
* 修改保存角色信息
*
* @param role 角色信息
* @return 结果
*/
@Override
public int updateRole(Role role)
{
role.setUpdateBy(ShiroUtils.getLoginName());
// 修改角色信息
roleMapper.updateRole(role);
// 删除角色与菜单关联
roleMenuMapper.deleteRoleMenuByRoleId(role.getRoleId());
ShiroUtils.clearCachedAuthorizationInfo();
return insertRoleMenu(role);
}
/**
* 新增角色菜单信息
*
* @param user 角色对象
*/
public int insertRoleMenu(Role role)
{
int rows = 1;
// 新增用户与角色管理
List<RoleMenu> list = new ArrayList<RoleMenu>();
for (Long menuId : role.getMenuIds())
{
RoleMenu rm = new RoleMenu();
rm.setRoleId(role.getRoleId());
rm.setMenuId(menuId);
list.add(rm);
}
if (list.size() > 0)
{
rows = roleMenuMapper.batchRoleMenu(list);
}
return rows;
}
/**
* 校验角色名称是否唯一
*
* @param role 角色信息
* @return 结果
*/
@Override
public String checkRoleNameUnique(Role role)
{
Long roleId = StringUtils.isNull(role.getRoleId()) ? -1L : role.getRoleId();
Role info = roleMapper.checkRoleNameUnique(role.getRoleName());
if (StringUtils.isNotNull(info) && info.getRoleId().longValue() != roleId.longValue())
{
return UserConstants.ROLE_NAME_NOT_UNIQUE;
}
return UserConstants.ROLE_NAME_UNIQUE;
}
/**
* 通过角色ID查询角色使用数量
*
* @param roleId 角色ID
* @return 结果
*/
@Override
public int countUserRoleByRoleId(Long roleId)
{
return userRoleMapper.countUserRoleByRoleId(roleId);
}
}
package com.ruoyi.project.system.role.service;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.common.constant.UserConstants;
import com.ruoyi.common.support.Convert;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.security.ShiroUtils;
import com.ruoyi.project.system.role.domain.Role;
import com.ruoyi.project.system.role.domain.RoleMenu;
import com.ruoyi.project.system.role.mapper.RoleMapper;
import com.ruoyi.project.system.role.mapper.RoleMenuMapper;
import com.ruoyi.project.system.user.mapper.UserRoleMapper;
/**
* 角色 业务层处理
*
* @author ruoyi
*/
@Service
public class RoleServiceImpl implements IRoleService
{
@Autowired
private RoleMapper roleMapper;
@Autowired
private RoleMenuMapper roleMenuMapper;
@Autowired
private UserRoleMapper userRoleMapper;
/**
* 根据条件分页查询角色数据
*
* @param role 角色信息
* @return 角色数据集合信息
*/
@Override
public List<Role> selectRoleList(Role role)
{
return roleMapper.selectRoleList(role);
}
/**
* 根据用户ID查询权限
*
* @param userId 用户ID
* @return 权限列表
*/
@Override
public Set<String> selectRoleKeys(Long userId)
{
List<Role> perms = roleMapper.selectRolesByUserId(userId);
Set<String> permsSet = new HashSet<>();
for (Role perm : perms)
{
if (StringUtils.isNotNull(perms))
{
permsSet.addAll(Arrays.asList(perm.getRoleKey().trim().split(",")));
}
}
return permsSet;
}
/**
* 根据用户ID查询角色
*
* @param userId 用户ID
* @return 角色列表
*/
@Override
public List<Role> selectRolesByUserId(Long userId)
{
List<Role> userRoles = roleMapper.selectRolesByUserId(userId);
List<Role> roles = roleMapper.selectRolesAll();
for (Role role : roles)
{
for (Role userRole : userRoles)
{
if (role.getRoleId().longValue() == userRole.getRoleId().longValue())
{
role.setFlag(true);
break;
}
}
}
return roles;
}
/**
* 查询所有角色
*
* @return 角色列表
*/
@Override
public List<Role> selectRoleAll()
{
return roleMapper.selectRolesAll();
}
/**
* 通过角色ID查询角色
*
* @param roleId 角色ID
* @return 角色对象信息
*/
@Override
public Role selectRoleById(Long roleId)
{
return roleMapper.selectRoleById(roleId);
}
/**
* 通过角色ID删除角色
*
* @param roleId 角色ID
* @return 结果
*/
@Override
public boolean deleteRoleById(Long roleId)
{
return roleMapper.deleteRoleById(roleId) > 0 ? true : false;
}
/**
* 批量删除角色信息
*
* @param ids 需要删除的数据ID
* @throws Exception
*/
@Override
public int deleteRoleByIds(String ids) throws Exception
{
Long[] roleIds = Convert.toLongArray(ids);
for (Long roleId : roleIds)
{
Role role = selectRoleById(roleId);
if (countUserRoleByRoleId(roleId) > 0)
{
throw new Exception(String.format("%1$s已分配,不能删除", role.getRoleName()));
}
}
return roleMapper.deleteRoleByIds(roleIds);
}
/**
* 新增保存角色信息
*
* @param role 角色信息
* @return 结果
*/
@Override
public int insertRole(Role role)
{
role.setCreateBy(ShiroUtils.getLoginName());
// 新增角色信息
roleMapper.insertRole(role);
ShiroUtils.clearCachedAuthorizationInfo();
return insertRoleMenu(role);
}
/**
* 修改保存角色信息
*
* @param role 角色信息
* @return 结果
*/
@Override
public int updateRole(Role role)
{
role.setUpdateBy(ShiroUtils.getLoginName());
// 修改角色信息
roleMapper.updateRole(role);
// 删除角色与菜单关联
roleMenuMapper.deleteRoleMenuByRoleId(role.getRoleId());
ShiroUtils.clearCachedAuthorizationInfo();
return insertRoleMenu(role);
}
/**
* 新增角色菜单信息
*
* @param role 角色对象
*/
public int insertRoleMenu(Role role)
{
int rows = 1;
// 新增用户与角色管理
List<RoleMenu> list = new ArrayList<RoleMenu>();
for (Long menuId : role.getMenuIds())
{
RoleMenu rm = new RoleMenu();
rm.setRoleId(role.getRoleId());
rm.setMenuId(menuId);
list.add(rm);
}
if (list.size() > 0)
{
rows = roleMenuMapper.batchRoleMenu(list);
}
return rows;
}
/**
* 校验角色名称是否唯一
*
* @param role 角色信息
* @return 结果
*/
@Override
public String checkRoleNameUnique(Role role)
{
Long roleId = StringUtils.isNull(role.getRoleId()) ? -1L : role.getRoleId();
Role info = roleMapper.checkRoleNameUnique(role.getRoleName());
if (StringUtils.isNotNull(info) && info.getRoleId().longValue() != roleId.longValue())
{
return UserConstants.ROLE_NAME_NOT_UNIQUE;
}
return UserConstants.ROLE_NAME_UNIQUE;
}
/**
* 校验角色权限是否唯一
*
* @param role 角色信息
* @return 结果
*/
@Override
public String checkRoleKeyUnique(Role role)
{
Long roleId = StringUtils.isNull(role.getRoleId()) ? -1L : role.getRoleId();
Role info = roleMapper.checkRoleKeyUnique(role.getRoleKey());
if (StringUtils.isNotNull(info) && info.getRoleId().longValue() != roleId.longValue())
{
return UserConstants.ROLE_KEY_NOT_UNIQUE;
}
return UserConstants.ROLE_KEY_UNIQUE;
}
/**
* 通过角色ID查询角色使用数量
*
* @param roleId 角色ID
* @return 结果
*/
@Override
public int countUserRoleByRoleId(Long roleId)
{
return userRoleMapper.countUserRoleByRoleId(roleId);
}
}

View File

@ -28,7 +28,7 @@ public class LoginController extends BaseController
public String login(HttpServletRequest request, HttpServletResponse response)
{
// 如果是Ajax请求返回Json字符串。
if (ServletUtils.isAjaxRequest((HttpServletRequest) request))
if (ServletUtils.isAjaxRequest(request))
{
return ServletUtils.renderString(response, "{\"code\":\"1\",\"msg\":\"未登录或登录超时。请重新登录\"}");
}

View File

@ -13,7 +13,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;
import com.ruoyi.common.utils.FileUploadUtils;
import com.ruoyi.common.utils.file.FileUploadUtils;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.constant.BusinessType;
import com.ruoyi.framework.web.controller.BaseController;
@ -149,7 +149,7 @@ public class ProfileController extends BaseController
}
catch (Exception e)
{
log.error("updateAvatar failed!", e);
log.error("修改头像失败!", e);
return error(e.getMessage());
}
}

View File

@ -61,6 +61,7 @@ public class UserController extends BaseController
}
@Log(title = "用户管理", action = BusinessType.EXPORT)
@RequiresPermissions("system:user:export")
@PostMapping("/export")
@ResponseBody
public AjaxResult export(User user) throws Exception
@ -176,7 +177,7 @@ public class UserController extends BaseController
public String checkLoginNameUnique(User user)
{
String uniqueFlag = "0";
if (user != null)
if (StringUtils.isNotNull(user))
{
uniqueFlag = userService.checkLoginNameUnique(user.getLoginName());
}
@ -191,7 +192,7 @@ public class UserController extends BaseController
public String checkPhoneUnique(User user)
{
String uniqueFlag = "0";
if (user != null)
if (StringUtils.isNotNull(user))
{
uniqueFlag = userService.checkPhoneUnique(user);
}
@ -206,7 +207,7 @@ public class UserController extends BaseController
public String checkEmailUnique(User user)
{
String uniqueFlag = "0";
if (user != null)
if (StringUtils.isNotNull(user))
{
uniqueFlag = userService.checkEmailUnique(user);
}

View File

@ -63,6 +63,8 @@ public interface IUserService
* 批量删除用户信息
*
* @param ids 需要删除的数据ID
* @return 结果
* @throws Exception 异常
*/
public int deleteUserByIds(String ids) throws Exception;

View File

@ -209,7 +209,7 @@ public class UserServiceImpl implements IUserService
{
user.randomSalt();
user.setPassword(passwordService.encryptPassword(user.getLoginName(), user.getPassword(), user.getSalt()));
return updateUser(user);
return updateUserInfo(user);
}
/**

View File

@ -19,13 +19,13 @@ import com.ruoyi.project.tool.gen.domain.TableInfo;
public class GenUtils
{
/** 项目空间路径 */
private static final String projectPath = "main/java/com/ruoyi/project";
private static final String PROJECT_PATH = "main/java/com/ruoyi/project";
/** mybatis空间路径 */
private static final String myBatisPath = "main/resources/mybatis";
private static final String MYBATIS_PATH = "main/resources/mybatis";
/** html空间路径 */
private static final String templatesPath = "main/resources/templates";
private static final String TEMPLATES_PATH = "main/resources/templates";
/**
* 设置列信息
@ -119,9 +119,9 @@ public class GenUtils
String classname = table.getClassname();
// 大写类名
String className = table.getClassName();
String javaPath = projectPath + "/" + moduleName + "/";
String mybatisPath = myBatisPath + "/" + moduleName + "/" + className;
String htmlPath = templatesPath + "/" + moduleName + "/" + classname;
String javaPath = PROJECT_PATH + "/" + moduleName + "/";
String mybatisPath = MYBATIS_PATH + "/" + moduleName + "/" + className;
String htmlPath = TEMPLATES_PATH + "/" + moduleName + "/" + classname;
if (StringUtils.isNotEmpty(classname))
{

View File

@ -1,32 +1,45 @@
#dubbo配置
#数据源配置
spring:
datasource:
type: com.alibaba.druid.pool.DruidDataSource
driverClassName: com.mysql.jdbc.Driver
#url: jdbc:mysql://10.213.24.45:3306/ry?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true
url: jdbc:mysql://localhost:3306/ry?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true
username: root
password: password
# 初始化大小,最小,最大
initialSize: 1
minIdle: 3
maxActive: 20
# 配置获取连接等待超时的时间
maxWait: 60000
# 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒
timeBetweenEvictionRunsMillis: 60000
# 配置一个连接在池中最小生存的时间,单位是毫秒
minEvictableIdleTimeMillis: 30000
validationQuery: select 'x'
testWhileIdle: true
testOnBorrow: false
testOnReturn: false
# 打开PSCache并且指定每个连接上PSCache的大小
poolPreparedStatements: true
maxPoolPreparedStatementPerConnectionSize: 20
# 配置监控统计拦截的filters去掉后监控界面sql无法统计'wall'用于防火墙
filters: stat,wall,slf4j
# 通过connectProperties属性来打开mergeSql功能慢SQL记录
connectionProperties: druid.stat.mergeSql=true;druid.stat.slowSqlMillis=5000
# 合并多个DruidDataSource的监控数据
#useGlobalDataSourceStat: true
datasource:
type: com.alibaba.druid.pool.DruidDataSource
driverClassName: com.mysql.jdbc.Driver
druid:
master: #主库
url: jdbc:mysql://localhost:3306/ry?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true
username: root
password: password
#slave: #从库
# open: true
# url: jdbc:mysql://localhost:3306/ry?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true
# username: root
# password: password
# 初始连接数
initial-size: 10
# 最大连接池数量
max-active: 100
# 最小连接池数量
min-idle: 10
# 配置获取连接等待超时的时间
max-wait: 60000
# 打开PSCache并且指定每个连接上PSCache的大小
pool-prepared-statements: true
max-pool-prepared-statement-per-connection-size: 20
# 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒
timeBetweenEvictionRunsMillis: 60000
# 配置一个连接在池中最小生存的时间,单位是毫秒
min-evictable-idle-time-millis: 300000
validation-query: SELECT 1 FROM DUAL
test-while-idle: true
test-on-borrow: false
test-on-return: false
stat-view-servlet:
enabled: true
url-pattern: /monitor/druid/*
filter:
stat:
log-slow-sql: true
slow-sql-millis: 1000
merge-sql: false
wall:
config:
multi-statement-allow: true

View File

@ -1,10 +1,13 @@
# 项目名称、版本、版权年份
# 项目相关配置
ruoyi:
#名称
name: RuoYi
version: 2.2.0
#版本
version: 2.3.0
#版权年份
copyrightYear: 2018
#头像上传路径
profile: D:/profile/
#开发环境配置
server:
#端口
@ -41,7 +44,6 @@ spring:
multipart:
max-file-size: 30MB
max-request-size: 30MB
devtools:
restart:
#禁用devtools模块的热部署功能

View File

@ -23,47 +23,5 @@
statistics="true">
</cache>
<!-- 系统用户缓存 没必要过期 -->
<cache name="sys-userCache"
maxEntriesLocalHeap="10000"
overflowToDisk="false"
eternal="false"
diskPersistent="false"
timeToLiveSeconds="0"
timeToIdleSeconds="0"
statistics="true"/>
<!-- 系统用户授权缓存 没必要过期 -->
<cache name="sys-authCache"
maxEntriesLocalHeap="10000"
overflowToDisk="false"
eternal="false"
diskPersistent="false"
timeToLiveSeconds="0"
timeToIdleSeconds="0"
memoryStoreEvictionPolicy="LRU"
statistics="true"/>
<!-- 菜单缓存 没必要过期 -->
<cache name="sys-menuCache"
maxEntriesLocalHeap="10000"
overflowToDisk="false"
eternal="false"
diskPersistent="false"
timeToLiveSeconds="0"
timeToIdleSeconds="0"
statistics="true"/>
<!-- shiro 会话缓存 不需要序列化到磁盘 此处我们放到db中了 此处cache没必要过期 因为我们存放到db了 -->
<cache name="shiro-activeSessionCache"
maxEntriesLocalHeap="10000"
overflowToDisk="false"
eternal="false"
diskPersistent="false"
timeToLiveSeconds="0"
timeToIdleSeconds="0"
statistics="true"/>
</ehcache>

View File

@ -33,4 +33,5 @@ no.permission=您没有数据的权限,请联系管理员添加权限 [{0}]
no.create.permission=您没有创建数据的权限,请联系管理员添加权限 [{0}]
no.update.permission=您没有修改数据的权限,请联系管理员添加权限 [{0}]
no.delete.permission=您没有删除数据的权限,请联系管理员添加权限 [{0}]
no.export.permission=您没有导出数据的权限,请联系管理员添加权限 [{0}]
no.view.permission=您没有查看数据的权限,请联系管理员添加权限 [{0}]

View File

@ -73,11 +73,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
update_time = sysdate()
</set>
where 1=1
<if test="jobId != null">and job_id = #{jobId}</if>
where job_id = #{jobId}
</update>
<insert id="insertJob" parameterType="Post" useGeneratedKeys="true" keyProperty="jobId">
<insert id="insertJob" parameterType="Job" useGeneratedKeys="true" keyProperty="jobId">
insert into sys_job(
<if test="jobId != null and jobId != 0">job_id,</if>
<if test="jobName != null and jobName != ''">job_name,</if>

View File

@ -22,7 +22,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</insert>
<select id="selectLogininforList" parameterType="Logininfor" resultMap="LogininforResult">
select * from sys_logininfor
select info_id,login_name,ipaddr,login_location,browser,os,status,msg,login_time from sys_logininfor
<where>
<if test="ipaddr != null and ipaddr != ''">
AND ipaddr like concat('%', #{ipaddr}, '%')

View File

@ -26,9 +26,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="status" column="status" />
</resultMap>
<select id="selectOnlineById" parameterType="String" resultMap="UserOnlineResult">
select *
<sql id="selectOnlineVo">
select sessionId,login_name,dept_name,ipaddr,login_location,browser,os,status,status,start_timestsamp,last_access_time,expire_time
from sys_user_online
</sql>
<select id="selectOnlineById" parameterType="String" resultMap="UserOnlineResult">
<include refid="selectOnlineVo"/>
where sessionid = #{sessionid}
</select>
@ -42,7 +46,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</delete>
<select id="selectUserOnlineList" parameterType="UserOnline" resultMap="UserOnlineResult">
select * from sys_user_online
<include refid="selectOnlineVo"/>
<where>
<if test="ipaddr != null and ipaddr != ''">
AND ipaddr like concat('%', #{ipaddr}, '%')
@ -54,7 +58,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</select>
<select id="selectOnlineByExpired" parameterType="String" resultMap="UserOnlineResult">
SELECT * FROM sys_user_online o
<include refid="selectOnlineVo"/> o
WHERE o.last_access_time <![CDATA[ <= ]]> #{lastAccessTime} ORDER BY o.last_access_time ASC
</select>

View File

@ -21,13 +21,20 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="operTime" column="oper_time" />
</resultMap>
<sql id="selectOperLogVo">
select
oper_id, title, action, method, channel, oper_name, dept_name, oper_url, oper_ip,oper_location,oper_param,status,error_msg,oper_time
from
sys_oper_log
</sql>
<insert id="insertOperlog" parameterType="OperLog">
insert into sys_oper_log(title, action, method, channel, oper_name, dept_name, oper_url, oper_ip, oper_location, oper_param, status, error_msg, oper_time)
values (#{title}, #{action}, #{method}, #{channel}, #{operName}, #{deptName}, #{operUrl}, #{operIp}, #{operLocation}, #{operParam}, #{status}, #{errorMsg}, sysdate())
</insert>
<select id="selectOperLogList" parameterType="OperLog" resultMap="OperLogResult">
select * from sys_oper_log
<include refid="selectOperLogVo"/>
<where>
<if test="title != null and title != ''">
AND title like concat('%', #{title}, '%')
@ -55,8 +62,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</delete>
<select id="selectOperLogById" parameterType="Long" resultMap="OperLogResult">
select *
from sys_oper_log
<include refid="selectOperLogVo"/>
where oper_id = #{operId}
</select>

View File

@ -41,11 +41,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</select>
<select id="checkDeptExistUser" parameterType="Long" resultType="int">
select count(*) from sys_user where dept_id = #{deptId}
select count(1) from sys_user where dept_id = #{deptId} and del_flag = '0'
</select>
<select id="selectDeptCount" parameterType="Dept" resultType="int">
select count(*) from sys_dept
select count(1) from sys_dept
<where>
<if test="deptId != null and deptId != 0"> and dept_id = #{deptId} </if>
<if test="parentId != null and parentId != 0"> and parent_id = #{parentId} </if>
@ -103,8 +103,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
update_time = sysdate()
</set>
where 1=1
<if test="deptId != null and deptId != ''">and dept_id = #{deptId}</if>
where dept_id = #{deptId}
</update>
<delete id="deleteDeptById" parameterType="Long">

View File

@ -28,7 +28,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<include refid="selectDictDataVo"/>
<where>
<if test="dictType != null and dictType != ''">
AND dict_type like concat('%', #{dictType}, '%')
AND dict_type = #{dictType}
</if>
<if test="dictLabel != null and dictLabel != ''">
AND dict_label like concat('%', #{dictLabel}, '%')
@ -55,7 +55,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</select>
<select id="countDictDataByType" resultType="Integer">
select count(*) from sys_dict_data where dict_type=#{dictType}
select count(1) from sys_dict_data where dict_type=#{dictType}
</select>
<delete id="deleteDictDataById" parameterType="Long">
@ -84,8 +84,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
update_time = sysdate()
</set>
where 1=1
<if test="dictCode != null and dictCode != ''">and dict_code = #{dictCode}</if>
where dict_code = #{dictCode}
</update>
<update id="updateDictDataType" parameterType="String">
update sys_dict_data set dict_type = #{newDictType} where dict_type = #{oldDictType}
</update>
<insert id="insertDictData" parameterType="DictData">

View File

@ -75,8 +75,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
update_time = sysdate()
</set>
where 1=1
<if test="dictId != null and dictId != ''">and dict_id = #{dictId}</if>
where dict_id = #{dictId}
</update>
<insert id="insertDictType" parameterType="DictType">

View File

@ -31,7 +31,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
from sys_menu m
left join sys_role_menu rm on m.menu_id = rm.menu_id
left join sys_user_role ur on rm.role_id = ur.role_id
where ur.user_id = #{userId} and m.menu_type in ('M', 'C') and m.visible = 0
LEFT JOIN sys_role ro on ur.role_id = ro.role_id
where ur.user_id = #{userId} and m.menu_type in ('M', 'C') and m.visible = 0 AND ro.status = 0
order by m.order_num
</select>
@ -79,7 +80,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</select>
<select id="selectCountMenuByParentId" resultType="Integer">
select count(*) from sys_menu where parent_id=#{menuId}
select count(1) from sys_menu where parent_id=#{menuId}
</select>
<select id="checkMenuNameUnique" parameterType="String" resultMap="MenuResult">
@ -102,8 +103,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
update_time = sysdate()
</set>
where 1=1
<if test="menuId != null and menuId != ''">and menu_id = #{menuId}</if>
where menu_id = #{menuId}
</update>
<insert id="insertMenu" parameterType="Menu">

View File

@ -53,6 +53,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
where post_id = #{postId}
</select>
<select id="checkPostNameUnique" parameterType="String" resultMap="PostResult">
<include refid="selectPostVo"/>
where post_name=#{postName}
</select>
<select id="checkPostCodeUnique" parameterType="String" resultMap="PostResult">
<include refid="selectPostVo"/>
where post_code=#{postCode}
</select>
<delete id="deletePostByIds" parameterType="Long">
delete from sys_post where post_id in
<foreach collection="array" item="postId" open="(" separator="," close=")">
@ -71,8 +81,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
update_time = sysdate()
</set>
where 1=1
<if test="postId != null">and post_id = #{postId}</if>
where post_id = #{postId}
</update>
<insert id="insertPost" parameterType="Post" useGeneratedKeys="true" keyProperty="postId">

View File

@ -64,6 +64,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
where role_name=#{roleName}
</select>
<select id="checkRoleKeyUnique" parameterType="String" resultMap="RoleResult">
<include refid="selectRoleVo"/>
where role_key=#{roleKey}
</select>
<delete id="deleteRoleById" parameterType="Long">
delete from sys_role where role_id = #{roleId}
</delete>
@ -86,8 +91,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
update_time = sysdate()
</set>
where 1=1
<if test="roleId != null">and role_id = #{roleId}</if>
where role_id = #{roleId}
</update>
<insert id="insertRole" parameterType="Role" useGeneratedKeys="true" keyProperty="roleId">

View File

@ -14,7 +14,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</delete>
<select id="selectCountRoleMenuByMenuId" resultType="Integer">
select count(*) from sys_role_menu where menu_id=#{menuId}
select count(1) from sys_role_menu where menu_id=#{menuId}
</select>
<delete id="deleteRoleMenu" parameterType="Long">

View File

@ -83,7 +83,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</select>
<select id="checkLoginNameUnique" parameterType="String" resultType="int">
select count(*) from sys_user where login_name=#{loginName}
select count(1) from sys_user where login_name=#{loginName}
</select>
<select id="checkPhoneUnique" parameterType="String" resultMap="UserResult">
@ -129,8 +129,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="remark != null and remark != ''">remark = #{remark},</if>
update_time = sysdate()
</set>
where 1=1
<if test="userId != null and userId != ''">and user_id = #{userId}</if>
where user_id = #{userId}
</update>
<insert id="insertUser" parameterType="User" useGeneratedKeys="true" keyProperty="userId">

View File

@ -14,7 +14,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</delete>
<select id="countUserPostById" resultType="Integer">
select count(*) from sys_user_post where post_id=#{postId}
select count(1) from sys_user_post where post_id=#{postId}
</select>
<delete id="deleteUserPost" parameterType="Long">

View File

@ -14,7 +14,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</delete>
<select id="countUserRoleByRoleId" resultType="Integer">
select count(*) from sys_user_role where role_id=#{roleId}
select count(1) from sys_user_role where role_id=#{roleId}
</select>
<delete id="deleteUserRole" parameterType="Long">

View File

@ -0,0 +1,10 @@
.bootstrap-tree-table .treetable-indent {width:16px; height: 16px; display: inline-block; position: relative;}
.bootstrap-tree-table .treetable-expander {width:16px; height: 16px; display: inline-block; position: relative; cursor: pointer;}
.bootstrap-tree-table .treetable-selected{background: #f5f5f5 !important;}
.bootstrap-tree-table .treetable-table{border:0 !important;margin-bottom:0}
.bootstrap-tree-table .treetable-table tbody {display:block;height:auto;overflow-y:auto;}
.bootstrap-tree-table .treetable-table thead, .treetable-table tbody tr {display:table;width:100%;table-layout:fixed;}
.bootstrap-tree-table .treetable-thead th{line-height:40px;border: 0 !important;background:#f3f3f4 !important;border-radius: 4px;border-left:0px solid #e7eaec !important;border-bottom:2px solid #e7eaec !important;text-align: center;}
.bootstrap-tree-table .treetable-thead tr :first-child{border-left:0 !important}
.bootstrap-tree-table .treetable-tbody td{border: 0 !important;border-left:0px solid #e7eaec !important;border-bottom:1px solid #e7eaec !important;overflow: hidden; white-space: nowrap; text-overflow: ellipsis;}
.bootstrap-tree-table .treetable-tbody tr :first-child{border-left:0 !important}

View File

@ -0,0 +1,323 @@
/**
* bootstrapTreeTable
*
* @author swifly
*/
(function($) {
"use strict";
$.fn.bootstrapTreeTable = function(options, param) {
var allData = null;//用于存放格式化后的数据
// 如果是调用方法
if (typeof options == 'string') {
return $.fn.bootstrapTreeTable.methods[options](this, param);
}
// 如果是初始化组件
options = $.extend({}, $.fn.bootstrapTreeTable.defaults, options || {});
// 是否有radio或checkbox
var hasSelectItem = false;
var target = $(this);
// 在外层包装一下div样式用的bootstrap-table的
var _main_div = $("<div class='bootstrap-tree-table fixed-table-container'></div>");
target.before(_main_div);
_main_div.append(target);
target.addClass("table table-hover treetable-table");
if (options.striped) {
target.addClass('table-striped');
}
// 工具条在外层包装一下div样式用的bootstrap-table的
if(options.toolbar){
var _tool_div = $("<div class='fixed-table-toolbar'></div>");
var _tool_left_div = $("<div class='bs-bars pull-left'></div>");
_tool_left_div.append($(options.toolbar));
_tool_div.append(_tool_left_div);
_main_div.before(_tool_div);
}
// 格式化数据,优化性能
target.formatData=function(data){
var _root = options.rootCodeValue?options.rootCodeValue:null
$.each(data, function(index, item) {
// 添加一个默认属性,用来判断当前节点有没有被显示
item.isShow = false;
// 这里兼容几种常见Root节点写法
// 默认的几种判断
var _defaultRootFlag = item[options.parentCode] == '0'
|| item[options.parentCode] == 0
|| item[options.parentCode] == null
|| item[options.parentCode] == '';
if (!item[options.parentCode] || (_root?(item[options.parentCode] == options.rootCodeValue):_defaultRootFlag)){
if(!allData["_root_"]){allData["_root_"]=[];}
allData["_root_"].push(item);
}else{
if(!allData["_n_"+item[options.parentCode]]){allData["_n_"+item[options.parentCode]]=[];}
allData["_n_"+item[options.parentCode]].push(item);
}
});
data=null;//回收
}
// 得到根节点
target.getRootNodes = function() {
return allData["_root_"];
};
// 递归获取子节点并且设置子节点
target.handleNode = function(parentNode, lv, row_id, p_id, tbody) {
var _ls = allData["_n_"+parentNode[options.code]];
var tr = target.renderRow(parentNode,_ls?true:false,lv,row_id,p_id);
tbody.append(tr);
if(_ls){
$.each(_ls, function(i, item) {
var _row_id = row_id+"_"+i
target.handleNode(item, (lv + 1), _row_id,row_id, tbody)
});
}
};
// 绘制行
target.renderRow = function(item,isP,lv,row_id,p_id){
// 标记已显示
item.isShow = true;
var tr = $('<tr id="'+row_id+'" pid="'+p_id+'"></tr>');
var _icon = options.expanderCollapsedClass;
if(options.expandAll){
tr.css("display","table");
_icon = options.expanderExpandedClass;
}else if(options.expandFirst&&lv<=1){
tr.css("display","table");
_icon=(lv==0)?options.expanderExpandedClass:options.expanderCollapsedClass;
}else{
tr.css("display","none");
_icon = options.expanderCollapsedClass;
}
$.each(options.columns, function(index, column) {
// 判断有没有选择列
if(column.field=='selectItem'){
hasSelectItem = true;
var td = $('<td style="text-align:center;width:36px"></td>');
if(column.radio){
var _ipt = $('<input name="select_item" type="radio" value="'+item[options.id]+'"></input>');
td.append(_ipt);
}
if(column.checkbox){
var _ipt = $('<input name="select_item" type="checkbox" value="'+item[options.id]+'"></input>');
td.append(_ipt);
}
tr.append(td);
}else{
var td = $('<td title="'+item[column.field]+'" name="'+column.field+'" style="text-align:'+column.align+';'+((column.width)?('width:'+column.width):'')+'"></td>');
// 增加formatter渲染
if (column.formatter) {
td = $('<td style="text-align:'+column.align+';'+((column.width)?('width:'+column.width):'')+'"></td>');
td.html(column.formatter.call(this, item[column.field], item, index));
} else {
td.text(item[column.field]);
}
if(options.expandColumn==index){
if(!isP){
td.prepend('<span class="treetable-expander"></span>')
}else{
td.prepend('<span class="treetable-expander '+_icon+'"></span>')
}
for (var int = 0; int < (lv-1); int++) {
td.prepend('<span class="treetable-indent"></span>')
}
}
tr.append(td);
}
});
return tr;
}
// 加载数据
target.load = function(parms){
// 加载数据前先清空
allData = {};
// 加载数据前先清空
target.html("");
// 构造表头
var thr = $('<tr></tr>');
$.each(options.columns, function(i, item) {
var th = null;
// 判断有没有选择列
if(i==0 && item.field=='selectItem'){
hasSelectItem = true;
th = $('<th style="width:36px"></th>');
}else{
th = $('<th style="'+((item.width)?('width:'+item.width):'')+'"></th>');
}
th.text(item.title);
thr.append(th);
});
var thead = $('<thead class="treetable-thead"></thead>');
thead.append(thr);
target.append(thead);
// 构造表体
var tbody = $('<tbody class="treetable-tbody"></tbody>');
target.append(tbody);
// 添加加载loading
var _loading = '<tr><td colspan="'+options.columns.length+'"><div style="display: block;text-align: center;">正在努力地加载数据中,请稍候……</div></td></tr>'
tbody.html(_loading);
// 默认高度
if(options.height){
tbody.css("height",options.height);
}
$.ajax({
type : options.type,
url : options.url,
data : parms?parms:options.ajaxParams,
dataType : "JSON",
success : function(data, textStatus, jqXHR) {
// 加载完数据先清空
tbody.html("");
if(!data||data.length<=0){
var _empty = '<tr><td colspan="'+options.columns.length+'"><div style="display: block;text-align: center;">没有找到匹配的记录</div></td></tr>'
tbody.html(_empty);
return;
}
// 格式化数据
target.formatData(data);
// 开始绘制
var rootNode = target.getRootNodes();
if(rootNode){
$.each(rootNode, function(i, item) {
var _row_id = "row_id_"+i
target.handleNode(item, 1, _row_id,"row_root", tbody);
});
}
// 下边的操作主要是为了查询时让一些没有根节点的节点显示
$.each(data, function(i, item) {
if(!item.isShow){
var tr = target.renderRow(item,false,1);
tbody.append(tr);
}
});
target.append(tbody);
//动态设置表头宽度
thead.css("width", tbody.children(":first").css("width"));
// 行点击选中事件
target.find("tbody").find("tr").click(function(){
if(hasSelectItem){
var _ipt = $(this).find("input[name='select_item']");
if(_ipt.attr("type")=="radio"){
_ipt.prop('checked',true);
target.find("tbody").find("tr").removeClass("treetable-selected");
$(this).addClass("treetable-selected");
}else{
if(_ipt.prop('checked')){
_ipt.prop('checked',false);
$(this).removeClass("treetable-selected");
}else{
_ipt.prop('checked',true);
$(this).addClass("treetable-selected");
}
}
}
});
// 小图标点击事件--展开缩起
target.find("tbody").find("tr").find(".treetable-expander").click(function(){
var _flag = $(this).hasClass(options.expanderExpandedClass);
var tr = $(this).parent().parent();
var row_id = tr.attr("id");
if(_flag){
var _ls = target.find("tbody").find("tr[id^='"+row_id+"_']");//下所有
if(_ls&&_ls.length>0){
$.each(_ls, function(index, item) {
$(item).css("display","none");
var _icon = $(item).children().eq(options.expandColumn).find(".treetable-expander");
if(_icon.hasClass(options.expanderExpandedClass)){
_icon.removeClass(options.expanderExpandedClass)
_icon.addClass(options.expanderCollapsedClass)
}
});
}
$(this).removeClass(options.expanderExpandedClass)
$(this).addClass(options.expanderCollapsedClass)
}else{
var _ls = target.find("tbody").find("tr[pid='"+row_id+"']");//下一级
if(_ls&&_ls.length>0){
$.each(_ls, function(index, item) {
$(item).css("display","table");
});
}
$(this).removeClass(options.expanderCollapsedClass)
$(this).addClass(options.expanderExpandedClass)
}
});
},
error:function(xhr,textStatus){
var _errorMsg = '<tr><td colspan="'+options.columns.length+'"><div style="display: block;text-align: center;">'+xhr.responseText+'</div></td></tr>'
tbody.html(_errorMsg);
debugger;
},
});
}
if (options.url) {
target.load();
} else {
// 也可以通过defaults里面的data属性通过传递一个数据集合进来对组件进行初始化....有兴趣可以自己实现,思路和上述类似
}
return target;
};
// 组件方法封装........
$.fn.bootstrapTreeTable.methods = {
// 返回选中记录的id返回的id由配置中的id属性指定
// 为了兼容bootstrap-table的写法统一返回数组这里只返回了指定的id
getSelections : function(target, data) {
// 所有被选中的记录input
var _ipt = target.find("tbody").find("tr").find("input[name='select_item']:checked");
var chk_value =[];
// 如果是radio
if(_ipt.attr("type")=="radio"){
var _data = {id:_ipt.val()};
var _tds = _ipt.parent().parent().find("td");
_tds.each(function(_i,_item){
if(_i!=0){
_data[$(_item).attr("name")]=$(_item).attr("title");
}
});
chk_value.push(_data);
}else{
_ipt.each(function(_i,_item){
var _data = {id:$(_item).val()};
var _tds = $(_item).parent().parent().find("td");
_tds.each(function(_ii,_iitem){
if(_ii!=0){
_data[$(_iitem).attr("name")]=$(_iitem).attr("title");
}
});
chk_value.push(_data);
});
}
return chk_value;
},
// 刷新记录
refresh : function(target, parms) {
if(parms){
target.load(parms);
}else{
target.load();
}
},
// 组件的其他方法也可以进行类似封装........
};
$.fn.bootstrapTreeTable.defaults = {
id : 'id',// 选取记录返回的值
code : 'id',// 用于设置父子关系
parentCode : 'parentId',// 用于设置父子关系
rootCodeValue: null,//设置根节点code值----可指定根节点默认为null,"",0,"0"
data : [], // 构造table的数据集合
type : "GET", // 请求数据的ajax类型
url : null, // 请求数据的ajax的url
ajaxParams : {}, // 请求数据的ajax的data属性
expandColumn : 0,// 在哪一列上面显示展开按钮
expandAll : false, // 是否全部展开
expandFirst : true, // 是否默认第一级展开--expandAll为false时生效
striped : false, // 是否各行渐变色
columns : [],
toolbar: '#toolbar',//顶部工具条
height: 0,
expanderExpandedClass : 'glyphicon glyphicon-chevron-down',// 展开的按钮的图标
expanderCollapsedClass : 'glyphicon glyphicon-chevron-right'// 缩起的按钮的图标
};
})(jQuery);

View File

@ -125,4 +125,3 @@ a.upload-img:hover{
}
.tc{text-align:center;}
/*www.jq22.com*/

View File

@ -1,7 +1,3 @@
/**
* Created by ezgoing on 14/9/2014.
*/
"use strict";
(function (factory) {
if (typeof define === 'function' && define.amd) {
@ -137,5 +133,3 @@
return new cropbox(options, this);
};
}));
/*www.jq22.com*/

View File

@ -1,16 +0,0 @@
.treegrid-indent {width:16px; height: 16px; display: inline-block; position: relative;}
.treegrid-expander {width:16px; height: 16px; display: inline-block; position: relative; cursor: pointer;}
.treegrid-expander-expanded{background-image: url(img/collapse.png); }
.treegrid-expander-collapsed{background-image: url(img/expand.png);}
.treegrid-selected{background: #f5f5f5 !important;}
.treegrid-table{border:0 !important;margin-bottom:0}
.treegrid-table tbody {display:block;height:auto;overflow-y:auto;}
.treegrid-table thead, .treegrid-table tbody tr {display:table;width:100%;table-layout:fixed;}
.treegrid-thead th{line-height:40px;border: 0 !important;background:#f3f3f4 !important;border-radius: 4px;border-left:0px solid #e7eaec !important;border-bottom:2px solid #e7eaec !important;text-align: center;}
.treegrid-thead tr :first-child{border-left:0 !important}
.treegrid-tbody td{border: 0 !important;border-left:0px solid #e7eaec !important;border-bottom:1px solid #e7eaec !important;overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;}
.treegrid-tbody tr :first-child{border-left:0 !important}

View File

@ -1,258 +0,0 @@
(function($) {
"use strict";
$.fn.bootstrapTreeTable = function(options, param) {
// 如果是调用方法
if (typeof options == 'string') {
return $.fn.bootstrapTreeTable.methods[options](this, param);
}
// 如果是初始化组件
options = $.extend({}, $.fn.bootstrapTreeTable.defaults, options || {});
// 是否有radio或checkbox
var hasSelectItem = false;
var target = $(this);
// 在外层包装一下div样式用的bootstrap-table的
var _main_div = $("<div class='fixed-table-container'></div>");
target.before(_main_div);
_main_div.append(target);
target.addClass("table table-hover treegrid-table");
if (options.striped) {
target.addClass('table-striped');
}
// 工具条在外层包装一下div样式用的bootstrap-table的
if(options.toolbar){
var _tool_div = $("<div class='fixed-table-toolbar'></div>");
var _tool_left_div = $("<div class='bs-bars pull-left'></div>");
_tool_left_div.append($(options.toolbar));
_tool_div.append(_tool_left_div);
_main_div.before(_tool_div);
}
// 得到根节点
target.getRootNodes = function(data) {
// 指定Root节点值
var _root = options.rootCodeValue?options.rootCodeValue:null
var result = [];
$.each(data, function(index, item) {
// 这里兼容几种常见Root节点写法
// 默认的几种判断
var _defaultRootFlag = item[options.parentCode] == '0'
|| item[options.parentCode] == 0
|| item[options.parentCode] == null
|| item[options.parentCode] == '';
if (!item[options.parentCode] || (_root?(item[options.parentCode] == options.rootCodeValue):_defaultRootFlag)){
result.push(item);
}
// 添加一个默认属性,用来判断当前节点有没有被显示
item.isShow = false;
});
return result;
};
var j = 0;
// 递归获取子节点并且设置子节点
target.getChildNodes = function(data, parentNode, parentIndex, tbody) {
$.each(data, function(i, item) {
if (item[options.parentCode] == parentNode[options.code]) {
var tr = $('<tr></tr>');
var nowParentIndex = (parentIndex + (j++) + 1);
tr.addClass('treegrid-' + nowParentIndex);
tr.addClass('treegrid-parent-' + parentIndex);
target.renderRow(tr,item);
item.isShow = true;
tbody.append(tr);
target.getChildNodes(data, item, nowParentIndex, tbody)
}
});
};
// 绘制行
target.renderRow = function(tr,item){
$.each(options.columns, function(index, column) {
// 判断有没有选择列
if(index==0&&column.field=='selectItem'){
hasSelectItem = true;
var td = $('<td style="text-align:center;width:36px"></td>');
if(column.radio){
var _ipt = $('<input name="select_item" type="radio" value="'+item[options.id]+'"></input>');
td.append(_ipt);
}
if(column.checkbox){
var _ipt = $('<input name="select_item" type="checkbox" value="'+item[options.id]+'"></input>');
td.append(_ipt);
}
tr.append(td);
}else{
var td = $('<td style="text-align:'+column.align+';'+((column.width)?('width:'+column.width):'')+'"></td>');
// 增加formatter渲染
if (column.formatter) {
td.html(column.formatter.call(this, item, index));
} else {
td.text(item[column.field]);
}
tr.append(td);
}
});
}
// 加载数据
target.load = function(parms){
// 加载数据前先清空
target.html("");
// 构造表头
var thr = $('<tr></tr>');
$.each(options.columns, function(i, item) {
var th = null;
// 判断有没有选择列
if(i==0&&item.field=='selectItem'){
hasSelectItem = true;
th = $('<th style="text-align:'+item.valign+';width:36px"></th>');
}else{
th = $('<th style="text-align:'+item.valign+';padding:10px;'+((item.width)?('width:'+item.width):'')+'"></th>');
}
th.text(item.title);
thr.append(th);
});
var thead = $('<thead class="treegrid-thead"></thead>');
thead.append(thr);
target.append(thead);
// 构造表体
var tbody = $('<tbody class="treegrid-tbody"></tbody>');
target.append(tbody);
// 添加加载loading
var _loading = '<tr><td colspan="'+options.columns.length+'"><div style="display: block;text-align: center;">正在努力地加载数据中,请稍候……</div></td></tr>'
tbody.html(_loading);
// 默认高度
if(options.height){
tbody.css("height",options.height);
}
$.ajax({
type : options.type,
url : options.url,
data : parms?parms:options.ajaxParams,
dataType : "JSON",
success : function(data, textStatus, jqXHR) {
// 加载完数据先清空
tbody.html("");
if(!data||data.length<=0){
var _empty = '<tr><td colspan="'+options.columns.length+'"><div style="display: block;text-align: center;">没有记录</div></td></tr>'
tbody.html(_empty);
return;
}
var rootNode = target.getRootNodes(data);
$.each(rootNode, function(i, item) {
var tr = $('<tr></tr>');
tr.addClass('treegrid-' + (j + "_" + i));
target.renderRow(tr,item);
item.isShow = true;
tbody.append(tr);
target.getChildNodes(data, item, (j + "_" + i), tbody);
});
// 下边的操作主要是为了查询时让一些没有根节点的节点显示
$.each(data, function(i, item) {
if(!item.isShow){
var tr = $('<tr></tr>');
tr.addClass('treegrid-' + (j + "_" + i));
target.renderRow(tr,item);
tbody.append(tr);
}
});
target.append(tbody);
// 初始化treegrid
target.treegrid({
treeColumn: options.expandColumn?options.expandColumn:(hasSelectItem?1:0),//如果有radio或checkbox默认第二列层级显示当前是在用户未设置的提前下
expanderExpandedClass : options.expanderExpandedClass,
expanderCollapsedClass : options.expanderCollapsedClass
});
if (!options.expandAll) {
target.treegrid('collapseAll');
}
//动态设置表头宽度
//thead.css("width", tbody.children(":first").css("width"));
// 行点击选中事件
target.find("tbody").find("tr").click(function(){
if(hasSelectItem){
var _ipt = $(this).find("input[name='select_item']");
if(_ipt.attr("type")=="radio"){
_ipt.prop('checked',true);
target.find("tbody").find("tr").removeClass("treegrid-selected");
$(this).addClass("treegrid-selected");
}else{
if(_ipt.prop('checked')){
_ipt.prop('checked',false);
$(this).removeClass("treegrid-selected");
}else{
_ipt.prop('checked',true);
$(this).addClass("treegrid-selected");
}
}
}
});
},
error:function(xhr,textStatus){
var _errorMsg = '<tr><td colspan="'+options.columns.length+'"><div style="display: block;text-align: center;">'+xhr.responseText+'</div></td></tr>'
tbody.html(_errorMsg);
debugger;
},
});
}
if (options.url) {
target.load();
} else {
// 也可以通过defaults里面的data属性通过传递一个数据集合进来对组件进行初始化....有兴趣可以自己实现,思路和上述类似
}
return target;
};
// 组件方法封装........
$.fn.bootstrapTreeTable.methods = {
// 返回选中记录的id返回的id由配置中的id属性指定
// 为了兼容bootstrap-table的写法统一返回数组这里只返回了指定的id
getSelections : function(target, data) {
// 所有被选中的记录input
var _ipt = target.find("tbody").find("tr").find("input[name='select_item']:checked");
var chk_value =[];
// 如果是radio
if(_ipt.attr("type")=="radio"){
chk_value.push({id:_ipt.val()});
}else{
_ipt.each(function(_i,_item){
chk_value.push({id:$(_item).val()});
});
}
return chk_value;
},
// 刷新记录
refresh : function(target, parms) {
if(parms){
target.load(parms);
}else{
target.load();
}
},
// 重置表格视图
resetHeight : function(target, height) {
target.find("tbody").css("height", height + 'px');
}
// 组件的其他方法也可以进行类似封装........
};
$.fn.bootstrapTreeTable.defaults = {
id : 'menuId',// 选取记录返回的值
code : 'menuId',// 用于设置父子关系
parentCode : 'parentId',// 用于设置父子关系
rootCodeValue: null,//设置根节点code值----可指定根节点默认为null,"",0,"0"
data : [], // 构造table的数据集合
type : "GET", // 请求数据的ajax类型
url : null, // 请求数据的ajax的url
ajaxParams : {}, // 请求数据的ajax的data属性
expandColumn : null,// 在哪一列上面显示展开按钮
expandAll : true, // 是否全部展开
striped : false, // 是否各行渐变色
columns : [],
toolbar: '#toolbar',//顶部工具条
height: 0,
expanderExpandedClass : 'glyphicon glyphicon-chevron-down',// 展开的按钮的图标
expanderCollapsedClass : 'glyphicon glyphicon-chevron-right'// 缩起的按钮的图标
};
})(jQuery);

View File

@ -1,619 +0,0 @@
/*
* jQuery treegrid Plugin 0.2.0
* https://github.com/maxazan/jquery-treegrid
*
* Copyright 2013, Pomazan Max
* Licensed under the MIT licenses.
*/
(function($) {
var methods = {
/**
* Initialize tree
*
* @param {Object} options
* @returns {Object[]}
*/
initTree: function(options) {
var settings = $.extend({}, this.treegrid.defaults, options);
return this.each(function() {
var $this = $(this);
$this.treegrid('setTreeContainer', $(this));
$this.treegrid('setSettings', settings);
settings.getRootNodes.apply(this, [$(this)]).treegrid('initNode', settings);
});
},
/**
* Initialize node
*
* @param {Object} settings
* @returns {Object[]}
*/
initNode: function(settings) {
return this.each(function() {
var $this = $(this);
$this.treegrid('setTreeContainer', settings.getTreeGridContainer.apply(this));
$this.treegrid('getChildNodes').treegrid('initNode', settings);
$this.treegrid('initExpander').treegrid('initIndent').treegrid('initEvents').treegrid('initState').treegrid("initSettingsEvents");
});
},
/**
* Initialize node events
*
* @returns {Node}
*/
initEvents: function() {
var $this = $(this);
//Save state on change
$this.on("change", function() {
var $this = $(this);
$this.treegrid('render');
if ($this.treegrid('getSetting', 'saveState')) {
$this.treegrid('saveState');
}
});
//Default behavior on collapse
$this.on("collapse", function() {
var $this = $(this);
$this.removeClass('treegrid-expanded');
$this.addClass('treegrid-collapsed');
});
//Default behavior on expand
$this.on("expand", function() {
var $this = $(this);
$this.removeClass('treegrid-collapsed');
$this.addClass('treegrid-expanded');
});
return $this;
},
/**
* Initialize events from settings
*
* @returns {Node}
*/
initSettingsEvents: function() {
var $this = $(this);
//Save state on change
$this.on("change", function() {
var $this = $(this);
if (typeof ($this.treegrid('getSetting', 'onChange')) === "function") {
$this.treegrid('getSetting', 'onChange').apply($this);
}
});
//Default behavior on collapse
$this.on("collapse", function() {
var $this = $(this);
if (typeof ($this.treegrid('getSetting', 'onCollapse')) === "function") {
$this.treegrid('getSetting', 'onCollapse').apply($this);
}
});
//Default behavior on expand
$this.on("expand", function() {
var $this = $(this);
if (typeof ($this.treegrid('getSetting', 'onExpand')) === "function") {
$this.treegrid('getSetting', 'onExpand').apply($this);
}
});
return $this;
},
/**
* Initialize expander for node
*
* @returns {Node}
*/
initExpander: function() {
var $this = $(this);
var cell = $this.find('td').get($this.treegrid('getSetting', 'treeColumn'));
var tpl = $this.treegrid('getSetting', 'expanderTemplate');
var expander = $this.treegrid('getSetting', 'getExpander').apply(this);
if (expander) {
expander.remove();
}
$(tpl).prependTo(cell).click(function() {
$($(this).closest('tr')).treegrid('toggle');
});
return $this;
},
/**
* Initialize indent for node
*
* @returns {Node}
*/
initIndent: function() {
var $this = $(this);
$this.find('.treegrid-indent').remove();
for (var i = 0; i < $(this).treegrid('getDepth'); i++) {
$($this.treegrid('getSetting', 'indentTemplate')).insertBefore($this.find('.treegrid-expander'));
}
return $this;
},
/**
* Initialise state of node
*
* @returns {Node}
*/
initState: function() {
var $this = $(this);
if ($this.treegrid('getSetting', 'saveState') && !$this.treegrid('isFirstInit')) {
$this.treegrid('restoreState');
} else {
if ($this.treegrid('getSetting', 'initialState') === "expanded") {
$this.treegrid('expand');
} else {
$this.treegrid('collapse');
}
}
return $this;
},
/**
* Return true if this tree was never been initialised
*
* @returns {Boolean}
*/
isFirstInit: function() {
var tree = $(this).treegrid('getTreeContainer');
if (tree.data('first_init') === undefined) {
tree.data('first_init', $.cookie(tree.treegrid('getSetting', 'saveStateName')) === undefined);
}
return tree.data('first_init');
},
/**
* Save state of current node
*
* @returns {Node}
*/
saveState: function() {
var $this = $(this);
if ($this.treegrid('getSetting', 'saveStateMethod') === 'cookie') {
var stateArrayString = $.cookie($this.treegrid('getSetting', 'saveStateName')) || '';
var stateArray = (stateArrayString === '' ? [] : stateArrayString.split(','));
var nodeId = $this.treegrid('getNodeId');
if ($this.treegrid('isExpanded')) {
if ($.inArray(nodeId, stateArray) === -1) {
stateArray.push(nodeId);
}
} else if ($this.treegrid('isCollapsed')) {
if ($.inArray(nodeId, stateArray) !== -1) {
stateArray.splice($.inArray(nodeId, stateArray), 1);
}
}
$.cookie($this.treegrid('getSetting', 'saveStateName'), stateArray.join(','));
}
return $this;
},
/**
* Restore state of current node.
*
* @returns {Node}
*/
restoreState: function() {
var $this = $(this);
if ($this.treegrid('getSetting', 'saveStateMethod') === 'cookie') {
var stateArray = $.cookie($this.treegrid('getSetting', 'saveStateName')).split(',');
if ($.inArray($this.treegrid('getNodeId'), stateArray) !== -1) {
$this.treegrid('expand');
} else {
$this.treegrid('collapse');
}
}
return $this;
},
/**
* Method return setting by name
*
* @param {type} name
* @returns {unresolved}
*/
getSetting: function(name) {
if (!$(this).treegrid('getTreeContainer')) {
return null;
}
return $(this).treegrid('getTreeContainer').data('settings')[name];
},
/**
* Add new settings
*
* @param {Object} settings
*/
setSettings: function(settings) {
$(this).treegrid('getTreeContainer').data('settings', settings);
},
/**
* Return tree container
*
* @returns {HtmlElement}
*/
getTreeContainer: function() {
return $(this).data('treegrid');
},
/**
* Set tree container
*
* @param {HtmlE;ement} container
*/
setTreeContainer: function(container) {
return $(this).data('treegrid', container);
},
/**
* Method return all root nodes of tree.
*
* Start init all child nodes from it.
*
* @returns {Array}
*/
getRootNodes: function() {
return $(this).treegrid('getSetting', 'getRootNodes').apply(this, [$(this).treegrid('getTreeContainer')]);
},
/**
* Method return all nodes of tree.
*
* @returns {Array}
*/
getAllNodes: function() {
return $(this).treegrid('getSetting', 'getAllNodes').apply(this, [$(this).treegrid('getTreeContainer')]);
},
/**
* Mthod return true if element is Node
*
* @returns {String}
*/
isNode: function() {
return $(this).treegrid('getNodeId') !== null;
},
/**
* Mthod return id of node
*
* @returns {String}
*/
getNodeId: function() {
if ($(this).treegrid('getSetting', 'getNodeId') === null) {
return null;
} else {
return $(this).treegrid('getSetting', 'getNodeId').apply(this);
}
},
/**
* Method return parent id of node or null if root node
*
* @returns {String}
*/
getParentNodeId: function() {
return $(this).treegrid('getSetting', 'getParentNodeId').apply(this);
},
/**
* Method return parent node or null if root node
*
* @returns {Object[]}
*/
getParentNode: function() {
if ($(this).treegrid('getParentNodeId') === null) {
return null;
} else {
return $(this).treegrid('getSetting', 'getNodeById').apply(this, [$(this).treegrid('getParentNodeId'), $(this).treegrid('getTreeContainer')]);
}
},
/**
* Method return array of child nodes or null if node is leaf
*
* @returns {Object[]}
*/
getChildNodes: function() {
return $(this).treegrid('getSetting', 'getChildNodes').apply(this, [$(this).treegrid('getNodeId'), $(this).treegrid('getTreeContainer')]);
},
/**
* Method return depth of tree.
*
* This method is needs for calculate indent
*
* @returns {Number}
*/
getDepth: function() {
if ($(this).treegrid('getParentNode') === null) {
return 0;
}
return $(this).treegrid('getParentNode').treegrid('getDepth') + 1;
},
/**
* Method return true if node is root
*
* @returns {Boolean}
*/
isRoot: function() {
return $(this).treegrid('getDepth') === 0;
},
/**
* Method return true if node has no child nodes
*
* @returns {Boolean}
*/
isLeaf: function() {
return $(this).treegrid('getChildNodes').length === 0;
},
/**
* Method return true if node last in branch
*
* @returns {Boolean}
*/
isLast: function() {
if ($(this).treegrid('isNode')) {
var parentNode = $(this).treegrid('getParentNode');
if (parentNode === null) {
if ($(this).treegrid('getNodeId') === $(this).treegrid('getRootNodes').last().treegrid('getNodeId')) {
return true;
}
} else {
if ($(this).treegrid('getNodeId') === parentNode.treegrid('getChildNodes').last().treegrid('getNodeId')) {
return true;
}
}
}
return false;
},
/**
* Method return true if node first in branch
*
* @returns {Boolean}
*/
isFirst: function() {
if ($(this).treegrid('isNode')) {
var parentNode = $(this).treegrid('getParentNode');
if (parentNode === null) {
if ($(this).treegrid('getNodeId') === $(this).treegrid('getRootNodes').first().treegrid('getNodeId')) {
return true;
}
} else {
if ($(this).treegrid('getNodeId') === parentNode.treegrid('getChildNodes').first().treegrid('getNodeId')) {
return true;
}
}
}
return false;
},
/**
* Return true if node expanded
*
* @returns {Boolean}
*/
isExpanded: function() {
return $(this).hasClass('treegrid-expanded');
},
/**
* Return true if node collapsed
*
* @returns {Boolean}
*/
isCollapsed: function() {
return $(this).hasClass('treegrid-collapsed');
},
/**
* Return true if at least one of parent node is collapsed
*
* @returns {Boolean}
*/
isOneOfParentsCollapsed: function() {
var $this = $(this);
if ($this.treegrid('isRoot')) {
return false;
} else {
if ($this.treegrid('getParentNode').treegrid('isCollapsed')) {
return true;
} else {
return $this.treegrid('getParentNode').treegrid('isOneOfParentsCollapsed');
}
}
},
/**
* Expand node
*
* @returns {Node}
*/
expand: function() {
return $(this).each(function() {
var $this = $(this);
if (!$this.treegrid('isLeaf') && !$this.treegrid("isExpanded")) {
$this.trigger("expand");
$this.trigger("change");
}
});
},
/**
* Expand all nodes
*
* @returns {Node}
*/
expandAll: function() {
var $this = $(this);
$this.treegrid('getRootNodes').treegrid('expandRecursive');
return $this;
},
/**
* Expand current node and all child nodes begin from current
*
* @returns {Node}
*/
expandRecursive: function() {
return $(this).each(function() {
var $this = $(this);
$this.treegrid('expand');
if (!$this.treegrid('isLeaf')) {
$this.treegrid('getChildNodes').treegrid('expandRecursive');
}
});
},
/**
* Collapse node
*
* @returns {Node}
*/
collapse: function() {
return $(this).each(function() {
var $this = $(this);
if (!$this.treegrid('isLeaf') && !$this.treegrid("isCollapsed")) {
$this.trigger("collapse");
$this.trigger("change");
}
});
},
/**
* Collapse all nodes
*
* @returns {Node}
*/
collapseAll: function() {
var $this = $(this);
$this.treegrid('getRootNodes').treegrid('collapseRecursive');
return $this;
},
/**
* Collapse current node and all child nodes begin from current
*
* @returns {Node}
*/
collapseRecursive: function() {
return $(this).each(function() {
var $this = $(this);
$this.treegrid('collapse');
if (!$this.treegrid('isLeaf')) {
$this.treegrid('getChildNodes').treegrid('collapseRecursive');
}
});
},
/**
* Expand if collapsed, Collapse if expanded
*
* @returns {Node}
*/
toggle: function() {
var $this = $(this);
if ($this.treegrid('isExpanded')) {
$this.treegrid('collapse');
} else {
$this.treegrid('expand');
}
return $this;
},
/**
* Rendering node
*
* @returns {Node}
*/
render: function() {
return $(this).each(function() {
var $this = $(this);
if ($this.treegrid('isOneOfParentsCollapsed')) {
$this.hide();
} else {
$this.show();
}
if (!$this.treegrid('isLeaf')) {
$this.treegrid('renderExpander');
$this.treegrid('getChildNodes').treegrid('render');
}
});
},
/**
* Rendering expander depends on node state
*
* @returns {Node}
*/
renderExpander: function() {
return $(this).each(function() {
var $this = $(this);
var expander = $this.treegrid('getSetting', 'getExpander').apply(this);
if (expander) {
if (!$this.treegrid('isCollapsed')) {
expander.removeClass($this.treegrid('getSetting', 'expanderCollapsedClass'));
expander.addClass($this.treegrid('getSetting', 'expanderExpandedClass'));
} else {
expander.removeClass($this.treegrid('getSetting', 'expanderExpandedClass'));
expander.addClass($this.treegrid('getSetting', 'expanderCollapsedClass'));
}
} else {
$this.treegrid('initExpander');
$this.treegrid('renderExpander');
}
});
}
};
$.fn.treegrid = function(method) {
if (methods[method]) {
return methods[ method ].apply(this, Array.prototype.slice.call(arguments, 1));
} else if (typeof method === 'object' || !method) {
return methods.initTree.apply(this, arguments);
} else {
$.error('Method with name ' + method + ' does not exists for jQuery.treegrid');
}
};
/**
* Plugin's default options
*/
$.fn.treegrid.defaults = {
initialState: 'expanded',
saveState: false,
saveStateMethod: 'cookie',
saveStateName: 'tree-grid-state',
expanderTemplate: '<span class="treegrid-expander"></span>',
indentTemplate: '<span class="treegrid-indent"></span>',
expanderExpandedClass: 'treegrid-expander-expanded',
expanderCollapsedClass: 'treegrid-expander-collapsed',
treeColumn: 0,
getExpander: function() {
return $(this).find('.treegrid-expander');
},
getNodeId: function() {
var template = /treegrid-([A-Za-z0-9_-]+)/;
if (template.test($(this).attr('class'))) {
return template.exec($(this).attr('class'))[1];
}
return null;
},
getParentNodeId: function() {
var template = /treegrid-parent-([A-Za-z0-9_-]+)/;
if (template.test($(this).attr('class'))) {
return template.exec($(this).attr('class'))[1];
}
return null;
},
getNodeById: function(id, treegridContainer) {
var templateClass = "treegrid-" + id;
return treegridContainer.find('tr.' + templateClass);
},
getChildNodes: function(id, treegridContainer) {
var templateClass = "treegrid-parent-" + id;
return treegridContainer.find('tr.' + templateClass);
},
getTreeGridContainer: function() {
return $(this).closest('table');
},
getRootNodes: function(treegridContainer) {
var result = $.grep(treegridContainer.find('tr'), function(element) {
var classNames = $(element).attr('class');
var templateClass = /treegrid-([A-Za-z0-9_-]+)/;
var templateParentClass = /treegrid-parent-([A-Za-z0-9_-]+)/;
return templateClass.test(classNames) && !templateParentClass.test(classNames);
});
return $(result);
},
getAllNodes: function(treegridContainer) {
var result = $.grep(treegridContainer.find('tr'), function(element) {
var classNames = $(element).attr('class');
var templateClass = /treegrid-([A-Za-z0-9_-]+)/;
return templateClass.test(classNames);
});
return $(result);
},
//Events
onCollapse: null,
onExpand: null,
onChange: null
};
})(jQuery);

File diff suppressed because one or more lines are too long

Binary file not shown.

Before

Width:  |  Height:  |  Size: 216 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 421 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 45 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 381 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.4 KiB

Some files were not shown because too many files have changed in this diff Show More