389 Commits

Author SHA1 Message Date
6353f4ff09 若依 3.8.1 2021-12-31 00:00:06 +08:00
bb1af390a7 升级log4j2到2.17.1,防止漏洞风险 2021-12-30 14:41:25 +08:00
f65cd6245d 防重复提交标识组合(key + url + header) 2021-12-30 14:14:40 +08:00
530b2a51d5 修改单词拼写错误 2021-12-30 14:13:38 +08:00
d51e7cbb51 用户管理部门查询选择节点后分页参数初始 2021-12-29 11:04:09 +08:00
f244fe1855 !395 fix https://gitee.com/y_project/RuoYi-Vue/issues/I4O5WD
Merge pull request !395 from 马小法/master
2021-12-29 02:14:26 +00:00
1294f68265 fix https://gitee.com/y_project/RuoYi-Vue/issues/I4O5WD 2021-12-27 15:33:22 +08:00
0e771a6c1b 升级spring-boot到最新版本2.5.8 2021-12-27 12:38:59 +08:00
e4df0c6da1 优化代码生成字典组重复问题 2021-12-24 14:51:33 +08:00
7b23b6db6f 升级oshi到最新版本v5.8.6 2021-12-24 12:00:29 +08:00
be412faf6c 升级fastjson到最新版1.2.79 2021-12-21 13:32:40 +08:00
fd3a699ad8 SQL工具类新增检查关键字方法 2021-12-21 13:32:28 +08:00
c28aa299bd 新增使用Gzip解压缩静态文件地址 2021-12-20 14:25:52 +08:00
a028b566ed 集成compression-webpack-plugin插件实现打包Gzip压缩 2021-12-20 09:46:17 +08:00
ca2405c104 升级log4j2到安全版本,防止漏洞风险 2021-12-19 19:56:53 +08:00
e5647793ce 路由支持单独配置菜单或角色权限 2021-12-18 16:48:31 +08:00
903b5aebca 新增图片预览组件 2021-12-18 12:23:59 +08:00
7492dcc9e6 请求分页方法设置成通用方便灵活调用 2021-12-18 12:22:41 +08:00
8978012f9d 修复打包后字体图标偶现的乱码问题 2021-12-17 11:36:15 +08:00
7cf4a5da87 !391 修改重置表单bug
Merge pull request !391 from 18297093310/jieoschina-master-patch-51652
2021-12-17 03:17:16 +00:00
47b67331d4 修改重置表单bug 2021-12-17 03:06:25 +00:00
6e14601c7c 修复版本差异导致的懒加载报错问题 2021-12-16 16:34:20 +08:00
fef7ead0d5 新增Vue3前端代码生成模板 2021-12-16 09:51:11 +08:00
06aef0587a 用户导入提示溢出则显示滚动条 2021-12-16 09:50:26 +08:00
bf7c259cdd !390 fix: cron组件中周回显bug
Merge pull request !390 from fuzui/fix_week_echo_in_cron_component
2021-12-16 01:45:14 +00:00
43d76e5990 fix: cron组件中周回显bug 2021-12-16 02:18:48 +08:00
d365a52cd6 自定义xss校验注解实现 2021-12-15 10:50:10 +08:00
e1c7115d8c 升级log4j2到安全版本,防止漏洞风险 2021-12-14 12:09:57 +08:00
bb4d75aff0 升级log4j2到安全版本,防止漏洞风险 2021-12-14 10:33:25 +08:00
2743785aaf 修复多参数逗号分隔的问题 2021-12-13 10:11:34 +08:00
2a235917dc 优化下载解析blob异常提示 2021-12-10 10:03:25 +08:00
44ce6774dc 代码生成预览支持复制内容 2021-12-09 09:57:02 +08:00
b911d7f78f 自定义文字复制剪贴指令 2021-12-09 09:56:11 +08:00
4644176e26 升级clipboard到最新版本2.0.8 2021-12-09 09:52:44 +08:00
850b98337b 修正用户分配角色属性错误 2021-12-06 20:58:10 +08:00
7f2921f26b !382 update 优化查询用户的角色组、岗位组代码
Merge pull request !382 from 疯狂的狮子Li/update
2021-12-06 12:35:59 +00:00
836017f2b9 !381 fix 修复主键溢出问题 将查询返回类型改为 Long
Merge pull request !381 from 疯狂的狮子Li/fix
2021-12-06 12:34:52 +00:00
4de4763baf update 优化查询用户的角色组、岗位组代码 2021-12-06 18:32:51 +08:00
965ebd0f03 fix 修复主键溢出问题 将查询返回类型改为 Long 2021-12-03 11:11:43 +08:00
2c3f1c28e5 tomcat update 2021-12-02 16:31:51 +08:00
6bfae2652f 若依 3.8.0 2021-12-01 08:53:11 +08:00
9bc730866f 🎉 RuoYi-Vue3(Vue3 Element Plus Vite)版本 2021-11-30 11:15:33 +08:00
a2d3f987c0 优化代码 2021-11-30 11:15:17 +08:00
bf4ac3ad7a !378 fix: crontab组件bug
Merge pull request !378 from fuzui/fix_cron_tool
2021-11-30 03:03:08 +00:00
f28a91969a fix: crontab组件中规范数据范围、冗余代码去除以及部分通配符说明 2021-11-30 02:08:08 +08:00
ca285f5e53 fix: crontab组件周显示及计算bug 2021-11-30 00:22:23 +08:00
34f2552cad fix: crontab组件互斥bug 2021-11-30 00:17:12 +08:00
89e7cb19b9 注册成功提示类型success 2021-11-26 18:11:57 +08:00
ea71c9b214 !376 camelCase中应该转换下划线,而不是横杠
Merge pull request !376 from khejing/master
2021-11-26 10:07:58 +00:00
e5fd1f76db camelCase中应该是下划线,而不是横杠 2021-11-26 08:26:45 +00:00
664192da0b 升级velocity到最新版本2.3(语法升级) 2021-11-25 15:18:02 +08:00
9fc3e220a7 防止修改用户个人信息接口修改用户名 2021-11-25 14:00:27 +08:00
64f6a69d9a 修复代码生成复选框字典遗漏问题 2021-11-25 13:54:49 +08:00
16734b1d88 升级velocity到最新版本2.3 2021-11-24 15:03:04 +08:00
31106c91fb 修复使用 this.$options.data 报错问题 2021-11-24 15:00:51 +08:00
026a427103 优化前端代码 2021-11-24 14:47:24 +08:00
bafb1372a7 !375 删除代码生成中冗余的导出方法
Merge pull request !375 from fuzui/delete_redundancy_gen_export_function
2021-11-24 00:39:07 +00:00
b4f032fab4 删除代码生成中冗余的导出方法 2021-11-24 02:48:35 +08:00
4f194aa101 升级js-cookie到最新版本3.0.1 2021-11-22 18:07:33 +08:00
ef4bfde4a8 优化提示信息 2021-11-22 18:06:44 +08:00
421593c0ba 添加新群号:101539465 2021-11-20 12:09:53 +08:00
91ad85aec1 添加新群号:264312783 2021-11-19 15:20:54 +08:00
d1eacc1d1c 新增tab对象简化页签操作 2021-11-19 14:53:40 +08:00
e41dd8a0f1 !370 fix 修复关闭 xss 功能导致可重复读 RepeatableFilter 失效
Merge pull request !370 from 疯狂的狮子Li/master
2021-11-19 06:53:16 +00:00
9a7bb81cd0 fix 修复关闭 xss 功能导致可重复读 RepeatableFilter 失效 2021-11-19 13:01:30 +08:00
fcf606acde 升级jsencrypt到最新版本3.2.1 2021-11-18 17:50:49 +08:00
084907eeca !369 代码生成模板缺少事务
Merge pull request !369 from lihy2021/N/A
2021-11-18 09:47:35 +00:00
8de93d35ed 代码生成模板缺少事务 2021-11-17 07:56:24 +00:00
cedd2d1daf 优化导出数据操作 2021-11-17 11:57:17 +08:00
2ab96587ef 任务参数忽略双引号中的逗号 2021-11-16 16:05:15 +08:00
cb9c0e79eb 升级core-js到最新版本3.19.1 2021-11-16 14:15:17 +08:00
96d2b2d6b8 !368 【轻量级 PR】: 统一全局配置文件
Merge pull request !368 from XTvLi/master
2021-11-16 05:43:07 +00:00
b00171366f 统一全局配置内容, 删除临时调用配置文件 2021-11-10 18:17:43 +08:00
4e817a1109 升级axios到最新版本0.24.0 2021-11-10 11:14:50 +08:00
d185d4e4cc 增加sendGet无参请求方法 2021-11-10 11:13:27 +08:00
bbbe83b737 添加新群号:101539465 2021-11-02 14:40:21 +08:00
cc4c52c998 任务屏蔽违规字符 2021-11-01 15:03:06 +08:00
bd09e5b11c 修复字符串无法被反转义问题 2021-11-01 15:02:47 +08:00
181f62c15e 回显数据字典键值修正 2021-11-01 14:40:00 +08:00
3ae5ec92a5 登录/验证码请求headers不设置token 2021-11-01 13:29:27 +08:00
2fe919b6ce !361 优化一些布尔判断语法
Merge pull request !361 from 清溪先生/master
2021-11-01 05:28:59 +00:00
13c770b6be 优化一些布尔判断语法 2021-10-27 19:03:29 +08:00
2eb55528ec 升级spring-boot到最新版本2.5.6 2021-10-27 16:23:35 +08:00
839f631d6b 添加Jaxb依赖,防止jdk8以上出现的兼容错误 2021-10-27 16:22:57 +08:00
8faae71157 !359 update ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java.
Merge pull request !359 from Remenber_Ray/N/A
2021-10-27 07:37:19 +00:00
b87e0fa124 !358 update ruoyi-common/src/main/java/com/ruoyi/common/core/redis/RedisCache.java.
Merge pull request !358 from 雪丛/N/A
2021-10-27 07:34:47 +00:00
b6596d021b 替换自定义验证注解 2021-10-26 17:22:20 +08:00
0628dc9b2f update ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java. 2021-10-26 08:02:48 +00:00
790aa0d24b update ruoyi-common/src/main/java/com/ruoyi/common/core/redis/RedisCache.java.
增加删除Hash中的数据
2021-10-26 01:42:12 +00:00
8a7dcf8a80 修正错别字 2021-10-25 10:26:00 +08:00
0c30ffa11f !354 update ruoyi-common/src/main/java/com/ruoyi/common/utils/Threads.java.
Merge pull request !354 from Remenber_Ray/N/A
2021-10-25 01:55:51 +00:00
0904bf6446 !355 fix 跨域访问之后 下载无法获取 download-filename
Merge pull request !355 from 疯狂的狮子Li/master
2021-10-25 01:55:23 +00:00
4583787759 fix 跨域访问之后 下载无法获取 download-filename 2021-10-24 17:13:04 +08:00
17550a5f4b update ruoyi-common/src/main/java/com/ruoyi/common/utils/Threads.java.
修复描述错误
2021-10-24 02:34:25 +00:00
a4558c32b2 解析blob响应是否登录失效 2021-10-23 10:23:32 +08:00
ef4fef3d56 update ry.sh. 2021-10-23 10:21:02 +08:00
3dbbc6a223 AjaxResult重写put方法,以方便链式调用 2021-10-22 16:23:08 +08:00
d3696f5223 !347 update ruoyi-common/src/main/java/com/ruoyi/common/core/domain/AjaxResult.java.
Merge pull request !347 from abbfun/N/A
2021-10-22 08:19:00 +00:00
2d7d137abd update ruoyi-common/src/main/java/com/ruoyi/common/core/domain/AjaxResult.java.
AjaxResult链式调用
2021-10-22 03:09:54 +00:00
c2a179e9dd 新增认证对象简化权限验证 2021-10-20 11:21:11 +08:00
519ea854d5 生产环境使用路由懒加载提升页面响应速度 2021-10-15 17:57:46 +08:00
e66d0e4f74 角色列表返回类型保持一致 2021-10-15 17:56:57 +08:00
e7afea4cb7 升级oshi到最新版本v5.8.2 2021-10-14 16:20:18 +08:00
6d6271d6c9 修复五级以上菜单404问题 2021-10-14 16:19:46 +08:00
eb4376b649 Excel导入支持@Excels注解 2021-10-10 14:30:08 +08:00
b1e5ebab8f 升级spring-boot-mybatis到最新版2.2.0 2021-10-10 11:26:50 +08:00
8bd6296721 升级pagehelper到最新版1.4.0 2021-10-10 11:25:37 +08:00
ae5c68368b 升级SpringBoot到最新版本2.5.5 2021-10-10 11:24:16 +08:00
4fdb0f48ec 同步element2.15.6表格样式 2021-10-10 11:23:04 +08:00
c4207f640b 使用JSONField忽略字段 2021-10-10 11:21:46 +08:00
f6e477b4f5 升级druid到最新版1.2.8 2021-10-10 09:44:14 +08:00
7ae47b50b8 导入模板添加默认参数 2021-10-09 12:22:55 +08:00
0b14155a75 增加 sendGet 无参判断 2021-10-09 12:22:54 +08:00
f1fed76273 升级element-ui到最新版本2.15.6 2021-10-09 12:22:48 +08:00
48813161f6 设置mybatis默认的执行器 2021-10-04 10:27:38 +08:00
a006904724 fix 2021-09-30 03:18:41 +00:00
5477ce3c39 修正swagger没有指定dataTypeClass导致启动出现warn日志 2021-09-29 19:51:48 +08:00
25f50d74c5 升级sass-loader到最新版本10.1.1 2021-09-27 18:54:43 +08:00
266f4d6806 升级dart-sass到版本1.32.13 2021-09-27 18:54:10 +08:00
ded99502ae 新增通用方法简化下载使用 2021-09-27 10:38:29 +08:00
02b95f95a8 升级file-saver到最新版本2.0.5 2021-09-27 10:36:43 +08:00
2a6d2d733e 升级dart-sass到最新版本1.42.1 2021-09-27 10:32:03 +08:00
30c89b33fe Excel注解支持导入导出标题信息 2021-09-26 09:03:01 +08:00
7479ff4b06 修复xss过滤后格式出现的异常 2021-09-25 17:12:37 +08:00
821f40882f !332 fix 自动生成代码漏掉 this.#[[$modal]]#.msgError
Merge pull request !332 from 疯狂的狮子Li/N/A
2021-09-24 06:50:50 +00:00
02ce9868a7 fix 自动生成代码漏掉 this.#[[$modal]]#.msgError 2021-09-24 05:41:55 +00:00
a8f2ff4531 !331 update 代码生成编辑页面 拼写错误修正
Merge pull request !331 from 疯狂的狮子Li/master
2021-09-24 02:07:44 +00:00
eaa3baab3c update 代码生成编辑页面 拼写错误修正 2021-09-24 10:06:23 +08:00
6480282826 升级fastjson到最新版1.2.78 2021-09-24 09:28:46 +08:00
6197ad5090 !330 优化 记录登录信息,移除不必要的修改
Merge pull request !330 from lihy2021/N/A
2021-09-24 01:27:57 +00:00
b477e40d3c 优化 记录登录信息,移除不必要的修改 2021-09-24 00:41:43 +00:00
f8cc7ce328 限流返回类型转换数值型的格式 2021-09-23 19:15:33 +08:00
1a5881b1d0 修正服务监控磁盘变量 2021-09-23 19:09:22 +08:00
fa124aeb8b 新增通用方法简化模态/缓存使用 2021-09-23 09:57:29 +08:00
258335cc65 新增通用方法简化模态/缓存使用 2021-09-23 09:38:16 +08:00
3b42abef44 Excel注解支持自定义数据处理器 2021-09-22 09:03:01 +08:00
26f0737c60 防重提交注解支持配置间隔时间/提示消息 2021-09-20 19:09:25 +08:00
ac94242875 reset dataSourceAspect 2021-09-20 19:08:50 +08:00
54bfa627f0 防止Excel导入图片可能出现的异常 2021-09-20 19:04:57 +08:00
36c058188a 防止记录日志转换出现的异常 2021-09-20 19:04:40 +08:00
a292cccb63 代码生成点击预览重置激活tab 2021-09-18 18:58:03 +08:00
5ccd9877b4 !325 update 优化aop语法 使用spring自动注入注解 基于注解拦截的aop注解不可能为空
Merge pull request !325 from 疯狂的狮子Li/master
2021-09-18 10:47:06 +00:00
7108ec41b5 !322 Cron表达式生成器关闭时销毁,避免再次打开时存在上一次修改的数据
Merge pull request !322 from muyi/master
2021-09-18 10:43:59 +00:00
5188d56b4a !321 修复 全局限流key会多出一个"-" 将其移动到IP后面 去除多余的空格
Merge pull request !321 from 疯狂的狮子Li/N/A
2021-09-18 10:41:03 +00:00
8f7ed66544 update 优化aop语法 使用spring自动注入注解 基于注解拦截的aop注解不可能为空 2021-09-18 18:20:21 +08:00
yjb
aaae404b2a Cron表达式生成器关闭时销毁,避免再次打开时存在上一次修改的数据 2021-09-17 19:14:41 +08:00
f3a8b4625f 修复 全局限流key会多出一个"-" 将其移动到IP后面 去除多余的空格 2021-09-17 09:32:43 +00:00
12ab8b03d9 使用vue-data-dict,简化数据字典使用 2021-09-17 15:36:54 +08:00
23270c60bc 日志注解新增是否保存响应参数 2021-09-16 16:03:49 +08:00
2cb6709323 !318 修复后端主子表代码模板方法名生成错误问题
Merge pull request !318 from 稚屿/N/A
2021-09-16 07:48:08 +00:00
917bc03a43 !316 禁用DictTag中el-tag渐变动画
Merge pull request !316 from 马小法/master
2021-09-16 07:34:34 +00:00
dbe3446b63 修复后端主子表代码模板方法名生成错误问题 2021-09-14 13:53:32 +00:00
b84e7013d2 禁用el-tag组件的渐变动画 2021-09-14 15:15:22 +08:00
db193a46e8 若依 3.7.0 2021-09-13 09:36:38 +08:00
04c340627d 修复多图组件验证失败被删除问题 2021-09-10 11:06:25 +08:00
15abd4d053 优化提示 2021-09-08 11:26:08 +08:00
a7376b36f8 !312 修复代码生成页面数据编辑保存之后总是跳转第一页的问题
Merge pull request !312 from 稚屿/master
2021-09-08 03:19:59 +00:00
d2b61762b7 修复代码生成页面数据编辑保存之后总是跳转第一页的问题 2021-09-08 11:18:35 +08:00
a5e38f6f99 菜单管理支持配置路由参数 2021-09-08 09:28:23 +08:00
4988b585f8 !309 修正单词拼写错误
Merge pull request !309 from 稚屿/master
2021-09-07 08:16:58 +00:00
b35f708c07 修正单词拼写错误 2021-09-05 21:36:33 +08:00
0e6150720c 页签新增关闭左侧 2021-09-05 13:27:58 +08:00
44adf03d2c 页签右键按钮添加图标 2021-09-05 13:26:45 +08:00
9ae5edaa74 菜单&部门新增展开/折叠功能 2021-09-04 12:10:33 +08:00
14c6c796e8 新增暗色菜单风格主题 2021-09-04 12:09:55 +08:00
5d72f9d224 修复保存配置主题颜色失效问题 2021-09-03 16:50:48 +08:00
e49f0cebf1 自定义弹层溢出滚动样式 2021-09-03 13:27:03 +08:00
6361e4efdc 定时任务支持在线生成cron表达式 2021-09-03 09:54:07 +08:00
cfa86bd4fe !308 代码生成: 导入表时查询 新创建表的优先排序在前面
Merge pull request !308 from xiaoshitou/N/A
2021-09-03 01:39:40 +00:00
a56bc47a81 代码生成: 导入表时查询 新创建表的优先排序在前面 2021-09-02 20:01:25 +00:00
a15bfdfb46 防止表格最后页最后项删除变成暂无数据 2021-09-02 10:55:10 +08:00
ee823b8326 防止表格最后页最后项删除变成暂无数据 2021-09-02 10:19:04 +08:00
57178e72a4 !304 修改数据字典样式回显
Merge pull request !304 from 马小法/master
2021-09-01 01:20:59 +00:00
b8317a562c !303 修改非管理员登录时,获取菜单报错sql
Merge pull request !303 from Gold_Fish/master
2021-08-30 08:59:55 +00:00
8040ad8c03 修改数据字典回显 2021-08-30 16:53:16 +08:00
c628aa5be8 修改代码生成字典回显样式 2021-08-30 16:49:30 +08:00
b036e78d85 修改根据userId获取菜单sql 2021-08-30 02:42:49 +00:00
4e8c6fb7c0 修复字典组件值为整形不显示问题 2021-08-29 15:57:01 +08:00
134835c870 验证码默认20s超时 2021-08-29 15:56:46 +08:00
5ade90debf !299 XssHttpServletRequestWrapper中增加available方法
Merge pull request !299 from Ming/master
2021-08-29 07:36:57 +00:00
bb0aeb39e3 !298 修复带utc日期格式 yyyy-MM-dd'T'HH:mm:ss.SSS 在safari浏览器中无法正确格式化的问题
Merge pull request !298 from wjtc8/N/A
2021-08-29 07:35:06 +00:00
098c650655 update ruoyi-common/src/main/java/com/ruoyi/common/filter/XssHttpServletRequestWrapper.java.
增加available方法于XssHttpServletRequestWrapper
2021-08-24 08:42:56 +00:00
e52092c6d4 修改时检查用户数据权限范围 2021-08-24 16:00:39 +08:00
89911e7caf 修复带utc日期格式 yyyy-MM-dd'T'HH:mm:ss.SSS 在safari浏览器中无法正确格式化的问题 2021-08-24 05:51:00 +00:00
0fc266fe80 定时任务对检查异常进行事务回滚 2021-08-24 11:12:11 +08:00
d1ef19f08a 自定义可拖动弹窗高度指令 2021-08-20 17:57:44 +08:00
e6e10308ff 自定义可拖动弹窗宽度指令 2021-08-20 17:45:25 +08:00
cb5ee9c8a1 补充定时任务表字段注释 2021-08-20 11:04:15 +08:00
1e37f0430b 定时任务屏蔽ldap远程调用 2021-08-19 15:26:22 +08:00
295173258c !295 update 优化 使用权限工具 获取用户信息
Merge pull request !295 from 疯狂的狮子Li/update
2021-08-19 06:55:13 +00:00
fec90d0487 !294 update ruoyi-ui/src/layout/index.vue.
Merge pull request !294 from aasdd/N/A
2021-08-19 06:49:06 +00:00
aead560227 update 优化 使用权限工具 获取用户信息 2021-08-19 11:13:59 +08:00
8133c60ab3 update ruoyi-ui/src/layout/index.vue.
删掉此处代码,使右边栏动画生效。现在是没有动画的
2021-08-18 09:29:22 +00:00
5c155f5f11 支持自定义注解实现接口限流 2021-08-17 14:08:18 +08:00
03cf98d3c9 优化异常信息 2021-08-16 16:25:25 +08:00
6f51f729ba !289 添加日期范围支持重复添加多组日期范围,请求参数中对象的属性为null、undefined不进行拼接
Merge pull request !289 from wangzhaoqiang/master
2021-08-16 08:23:27 +00:00
57b159eb98 添加日期范围支持重复添加多组日期范围,请求参数中对象的属性为null、undefined不进行拼接 2021-08-16 14:48:34 +08:00
08da6834a5 !288 修正方法名单词拼写错误
Merge pull request !288 from 稚屿/N/A
2021-08-16 02:36:36 +00:00
268468fb47 !287 更新到【默认首页使用keep-alive缓存】后报错
Merge pull request !287 from wangzhaoqiang/master
2021-08-16 02:36:29 +00:00
333e19339c 修正方法名单词拼写错误 2021-08-15 10:26:05 +00:00
7b6ccd9b22 解决登录后浏览器后台Breadcrumb组件报错 2021-08-14 20:16:48 +08:00
5d6f134609 多图上传组件移除多余的api地址 2021-08-13 15:15:35 +08:00
f02743bde5 代码生成主子表多选行数据 2021-08-13 14:50:35 +08:00
3003bb0f50 Excel注解图片导入兼容xls 2021-08-13 10:56:35 +08:00
5139265d32 默认首页使用keep-alive缓存 2021-08-13 10:10:29 +08:00
8a67af6c26 !285 修复角色分配用户页面接收参数与传递参数类型不一致导致的错误
Merge pull request !285 from 稚屿/N/A
2021-08-13 01:55:58 +00:00
8e4802505e !284 添加SysConfigservice,SysDictTypeService的实现方法遗漏的@Override注解
Merge pull request !284 from Old丶x/master
2021-08-13 01:55:52 +00:00
8ee641c1bc 修复角色分配用户页面接收参数与传递参数类型不一致导致的错误 2021-08-13 01:08:00 +00:00
779508989f 添加加载字典数据,清空字典数据,重置字典数据方法上遗漏的@Override注解 2021-08-12 17:30:31 +08:00
d9e805a6a5 添加获取验证码方法上遗漏的@Override注解 2021-08-12 17:19:56 +08:00
7be17ea89a Excel注解支持Image图片导入 2021-08-11 10:13:34 +08:00
1f07641d9b update bin 2021-08-11 10:11:13 +08:00
c0f4f805d0 !281 补全注册用户方法上遗漏的@Override注解
Merge pull request !281 from 稚屿/N/A
2021-08-11 02:08:58 +00:00
b84224d7ba 补全注册用户方法上遗漏的@Override注解 2021-08-08 14:08:52 +00:00
98a143f1fe 添加新群号:101456076 2021-08-08 19:50:50 +08:00
3243428009 优化用户不能删除自己 2021-08-08 19:12:52 +08:00
7736097f6b 提取通用方法到基类控制器 2021-08-08 19:12:12 +08:00
fc60c003c3 升级element-ui到最新版本2.15.5 2021-08-06 14:31:39 +08:00
68ae4df2dc 升级commons.io到最新版本v2.11.0 2021-07-31 17:52:06 +08:00
de33e6ecc8 优化代码生成模板 2021-07-30 22:18:20 +08:00
a1cc346aca 优化代码生成模板 2021-07-30 21:50:47 +08:00
5397e345ca 新增是否开启用户注册功能 2021-07-30 21:23:35 +08:00
8ed7916b61 定时任务屏蔽http(s)远程调用 2021-07-30 11:28:46 +08:00
2de5cc52d1 启用父部门状态排除顶级节点 2021-07-30 11:28:04 +08:00
f6bc28000e 防止错误token导致的解析异常 2021-07-29 17:32:55 +08:00
6b5dd4d2be 优化XSS跨站脚本过滤 2021-07-28 16:04:59 +08:00
e6becb9337 BLOB下载时清除URL对象引用 2021-07-28 13:13:28 +08:00
8da55fb72a 添加新群号:101456076 2021-07-28 09:51:19 +08:00
6a5c86541a 跳转路由高亮相对应的菜单栏 2021-07-27 11:54:20 +08:00
3803ac78e2 升级oshi到最新版本v5.8.0 2021-07-27 11:53:59 +08:00
4095a1b6ee !275 fix Issue #I42GRW 任意账户越权漏洞
Merge pull request !275 from lagXkjy/master
2021-07-27 02:08:04 +00:00
3347ca4d74 fix:Issue #I42GRW 修复任意账户越权漏洞 2021-07-27 09:33:12 +08:00
9b1883988b 升级element-ui到最新版本2.15.3 2021-07-26 09:50:58 +08:00
49c8a007cc 修复定时任务日志执行状态显示 2021-07-26 09:50:33 +08:00
64f6d28441 角色&菜单新增字段属性提示信息 2021-07-25 20:08:55 +08:00
c26d87c677 内链设置meta信息 2021-07-25 20:05:18 +08:00
97ae0eb7c7 密码框新增显示切换密码图标 2021-07-25 19:13:56 +08:00
6c1cccd031 导入用户样式调整 2021-07-25 19:08:00 +08:00
856d1ceba8 顶部菜单样式调整 2021-07-25 19:06:57 +08:00
60673b3b64 去除默认分页合理化参数 2021-07-25 10:35:37 +08:00
0a516e3001 更多操作按钮添加权限控制 2021-07-25 10:20:52 +08:00
bb87f35797 富文本新增上传文件大小限制 2021-07-25 08:57:01 +08:00
c43f9bc3c2 顶部菜单排除隐藏的默认路由 2021-07-24 18:20:55 +08:00
46b43b1bd9 !269 code=401时request方法没有返回Promise.reject 修复
Merge pull request !269 from 严俊东/N/A
2021-07-24 02:48:01 +00:00
8dbda47174 !268 修正方法名单词拼写错误
Merge pull request !268 from 稚屿/N/A
2021-07-23 11:34:30 +00:00
cdace51197 code=401时request方法没有返回Promise.reject 修复 2021-07-20 04:49:22 +00:00
c24fc4282c 修正方法名单词拼写错误 2021-07-20 00:54:50 +00:00
b616a2f2e7 定时任务新增更多操作 2021-07-15 17:35:33 +08:00
60abdf1dbc 升级oshi到最新版本v5.7.5 2021-07-14 09:53:26 +08:00
7b894da43c 参数管理支持配置验证码开关 2021-07-13 10:30:40 +08:00
c8b66f9b04 删除富文本video事件 2021-07-13 10:28:55 +08:00
25d9edd5c9 !259 图片上传 - 多图时无法删除相应图片修复
Merge pull request !259 from 严俊东/N/A
2021-07-13 02:26:10 +00:00
77a21d098f 图片上传 - 多图时无法删除相应图片修复 2021-07-12 03:01:50 +00:00
170cfb356c 若依 3.6.0 2021-07-12 08:42:11 +08:00
5879c2484a 菜单路由配置支持内链访问 2021-07-11 16:31:10 +08:00
c02dad2ca3 默认访问首页新增提示语 2021-07-11 15:28:11 +08:00
1bfa14e3c6 富文本默认上传返回url类型 2021-07-10 12:17:32 +08:00
5dec58e7f5 自定义弹窗拖拽指令 2021-07-09 17:12:29 +08:00
8321f92d2c 全局注册通用组件 2021-07-09 17:09:57 +08:00
da1095e298 授权用户添加访问权限 2021-07-09 17:08:30 +08:00
f56da498ab ImageUpload组件支持多图片上传 2021-07-08 19:17:09 +08:00
e259093e01 文件上传组件添加数量限制属性 2021-07-08 15:49:04 +08:00
e963a86b15 富文本编辑组件添加类型属性 2021-07-08 15:48:11 +08:00
e447fb806b FileUpload组件支持多文件上传 2021-07-08 12:36:02 +08:00
90c41d498c 角色管理新增分配用户功能 2021-07-05 14:54:09 +08:00
ce6bea4ba0 限制超级管理员不允许操作 2021-07-05 09:57:15 +08:00
9c7901f526 用户管理新增分配角色功能 2021-07-01 18:01:36 +08:00
04f5a93aa8 升级pagehelper到最新版1.3.1 2021-06-25 17:25:49 +08:00
751ca90690 !251 修复日志列表取消字段排序时的报错问题
Merge pull request !251 from 稚屿/N/A
2021-06-25 09:23:45 +00:00
1dfeae6a03 修复日志列表取消字段排序时的报错问题 2021-06-24 00:27:37 +00:00
1ed60c79c0 用户信息长度校验限制 2021-06-22 20:45:19 +08:00
aee1e53140 全局挂载字典标签组件 2021-06-22 20:44:40 +08:00
253e2b2de1 增加字典标签样式回显 2021-06-22 14:24:26 +08:00
b1413f021e 增加字典标签样式回显 2021-06-22 14:04:14 +08:00
60c22b6a43 update ry.sh. 2021-06-17 21:29:00 +08:00
3f05ed6ffa 封装iframe组件 2021-06-17 20:17:42 +08:00
090ad5323a 日志列表支持排序操作 2021-06-17 12:30:43 +08:00
3e90fd010d 升级commons.fileupload到最新版本v1.4 2021-06-16 09:53:00 +08:00
462862ba65 升级commons.io到最新版本v2.10.0 2021-06-16 09:52:38 +08:00
7601a72faf 升级element-ui到最新版本2.15.2 2021-06-15 10:26:19 +08:00
7ab14ff293 定时任务屏蔽rmi远程调用 2021-06-15 10:26:02 +08:00
200106df39 升级oshi到最新版本v5.7.4 2021-06-11 10:29:14 +08:00
ea66e20282 修复用户搜索分页变量错误 2021-06-10 22:36:22 +08:00
a209b39552 分页组件新增pagerCount属性 2021-06-10 22:29:13 +08:00
557672ba9f 系统布局配置支持动态标题开关 2021-06-10 18:05:27 +08:00
a3116cd27d 优化部门父级启用状态 2021-06-10 15:34:38 +08:00
2ace3257f9 升级swagger到最新版本v3.0.0 2021-06-09 20:07:36 +08:00
c16ee7fc2c 升级swagger到最新版本v3.0.0 2021-06-08 16:34:36 +08:00
fd33fe869d 修复导出角色数据范围翻译缺少仅本人 2021-06-08 16:27:24 +08:00
b7446f8d0f 富文本工具栏配置视频 2021-06-03 13:26:09 +08:00
19924cd184 修复关闭confirm提示框控制台报错问题 2021-06-03 13:24:29 +08:00
85470a1549 修复表单构建选择下拉选择控制台报错问题 2021-06-02 20:43:34 +08:00
2a604c0548 !237 同步菜单新增、修改界面“功能权限”maxlength为100(保持与数据库字段长度一致),避免因超过50后不能录入问题
Merge pull request !237 from 老李/origin
2021-06-02 20:40:09 +08:00
b7f3c68eca 优化图片工具类读取文件 2021-06-02 11:45:40 +08:00
edd2981076 调整用户测试接口swagger注解 2021-06-02 11:45:30 +08:00
c105a63c8b 添加bat脚本执行应用 2021-05-31 12:16:27 +08:00
01fef0b9e1 同步菜单新增、修改界面“功能权限”maxlength为100(保持与数据库字段长度一致),避免因超过50后不能录入问题 2021-05-31 10:31:50 +08:00
af9cfb40a4 优化参数&字典缓存操作 2021-05-27 17:38:44 +08:00
6fa3bfe051 修复两处存在SQL注入漏洞问题 2021-05-27 17:38:27 +08:00
5e64a93d11 若依 3.5.0 2021-05-25 09:37:55 +08:00
4aabf5d8be Redis设置HashKey序列化 2021-05-24 15:10:55 +08:00
cf6254a8d5 用户登录后记录最后登录IP&时间 2021-05-24 14:21:29 +08:00
883cff5de9 新增IE浏览器版本过低提示页面 2021-05-24 14:15:41 +08:00
7e79c4f249 生成vue模板导出按钮点击后添加遮罩 2021-05-24 11:34:03 +08:00
504638eb41 !234 【轻量级 PR】:删去两处冗余代码
Merge pull request !234 from xivLi/master
2021-05-24 11:30:21 +08:00
2adac4a899 升级fastjson到最新版1.2.76 2021-05-24 11:25:17 +08:00
56a943bf48 升级druid到最新版本v1.2.6 2021-05-24 11:24:54 +08:00
77ebca264a 修复请求形参未传值记录日志异常问题 2021-05-23 19:22:30 +08:00
7b94ae3a9a xss校验json条件优化 2021-05-23 19:20:36 +08:00
bd1edc6dcc !233 修正方法名单词拼写错误
Merge pull request !233 from lyqwer/N/A
2021-05-23 17:15:18 +08:00
09d166e97d !231 修正注释
Merge pull request !231 from 刘立伟/N/A
2021-05-23 17:14:52 +08:00
f3e5d908d6 quartz模块下 domain包中的 SysJob类不需要实现Serializable接口 2021-05-22 16:05:12 +08:00
9651a7d7fc 删去utils.uuid下 IdUtils类中 多余的import(同包下的UUID类) 2021-05-22 15:52:19 +08:00
b2914cbcb1 修正方法名单词拼写错误 2021-05-21 17:24:48 +08:00
d0a4d6b111 修正注释 2021-05-18 10:21:48 +08:00
b431703262 导出按钮点击之后添加遮罩 2021-05-17 15:37:58 +08:00
99726be9ac 修正导入表权限标识 2021-05-11 14:26:20 +08:00
32f333a00e 删除操作日志记录日志 2021-05-11 14:25:39 +08:00
be5c19b764 树级结构更新子节点使用replaceFirst 2021-05-11 14:25:25 +08:00
dd384e4a31 上传媒体类型添加视频格式 2021-05-11 14:25:08 +08:00
bdde195e2b !225 【bug修复】文件上传时出现java.nio.file.FileAlreadyExistsException
Merge pull request !225 from CANYON/master
2021-05-11 14:19:53 +08:00
14ea071306 修复文件上传时java.nio.file.FileAlreadyExistsException 2021-05-08 15:31:16 +08:00
50034301ac 添加新群号:201396349 2021-05-06 20:40:25 +08:00
85ed712c50 !222 update ruoyi-ui/src/assets/styles/element-ui.scss.
Merge pull request !222 from leizhuogogo/N/A
2021-05-06 20:39:36 +08:00
f67d682345 !221 update ruoyi-common/src/main/java/com/ruoyi/common/utils/Arith.java.
Merge pull request !221 from phper08/N/A
2021-05-06 20:39:26 +08:00
3f1427eef9 update ruoyi-ui/src/assets/styles/element-ui.scss. 2021-05-06 17:50:28 +08:00
7d0f5e94ef update ruoyi-common/src/main/java/com/ruoyi/common/utils/Arith.java. 2021-05-03 13:18:33 +08:00
62081aebb9 修复开启TopNav后,左侧打开外链问题 2021-04-21 16:34:44 +08:00
3f07632cd4 修复一级菜单包屑显示重复问题 2021-04-21 15:14:36 +08:00
2c94587263 优化ExcelUtil空值处理 2021-04-21 09:53:14 +08:00
2575c17f47 主题颜色保存配置 2021-04-19 16:59:56 +08:00
b6f13c546b 过滤BindingResult对象,防止异常 2021-04-18 21:54:53 +08:00
e60a69b670 兼容顶部栏一级菜单内部跳转 2021-04-18 18:33:13 +08:00
cb18eec802 修正模板字符编码 2021-04-18 15:45:49 +08:00
bef080c60a 升级mybatis到最新版3.5.6 阻止远程代码执行漏洞 2021-04-18 15:45:37 +08:00
de73cf300b 优化树表代码生成模板 2021-04-15 10:39:09 +08:00
cbcee86d2c 优化树表代码生成模板 2021-04-15 10:37:22 +08:00
cc50224d90 固定顶部导航栏&窗口大小改变实时更新栏数 2021-04-14 11:01:16 +08:00
ff09e1cf55 数据监控默认地址修改 2021-04-13 18:15:11 +08:00
fe2ccbdc1b 优化代码生成导出模板名称 2021-04-13 14:49:42 +08:00
c8df1f5e1f 布局设置支持保存&重置配置 2021-04-13 09:47:28 +08:00
e71c00e6fa 富文本编辑器支持自定义上传地址 2021-04-13 09:38:32 +08:00
dcb9839596 !209 导出 Excel 工作表的名称 由 ${businessName} 更改为 ${functionName}
Merge pull request !209 from lihy2021/N/A
2021-04-13 09:36:49 +08:00
f13b6d92d2 !205 富文本编辑器自定义上传地址
Merge pull request !205 from hechieh/N/A
2021-04-13 09:36:42 +08:00
6595c68df1 导出 Excel 工作表的名称 由 ${businessName} 更改为 ${functionName} 2021-04-12 14:52:14 +08:00
5a2a0c09b6 优化主子表代码生成 2021-04-12 13:26:54 +08:00
9aac65ff32 新增菜单导航显示风格TopNav(false为左侧导航菜单,true为顶部导航菜单) 2021-04-12 09:54:08 +08:00
5f2350569a 页签新增关闭右侧 2021-04-10 21:15:45 +08:00
ccf05b697d 富文本编辑器自定义上传地址 2021-04-10 17:08:49 +08:00
6810243ab7 修复树表数据显示不全&加载慢问题 2021-04-09 08:31:13 +08:00
b56b8846d9 修改主题后mini类型按钮无效问题 2021-04-08 13:54:48 +08:00
8e1e4cd8fe 通用下载完成后删除节点 2021-04-08 13:46:22 +08:00
9fa5c79713 !200 update ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysMenuServiceImpl.java.
Merge pull request !200 from yvan7123/N/A
2021-04-08 13:42:30 +08:00
40a72c2b7e !199 规范命名、用户角色单个逻辑删除、去除多余代码
Merge pull request !199 from fuzui/some_problems
2021-04-08 13:40:28 +08:00
6fe9a358b7 update ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysMenuServiceImpl.java. 2021-04-06 11:47:27 +08:00
9f6bc13e64 🔥 去除多余代码 2021-04-02 23:06:48 +08:00
ba5ab4b091 用户、角色单条删除时,使其逻辑删除 2021-04-02 22:49:19 +08:00
17407d0127 调整cache_repeat_key为驼峰格式 2021-04-02 22:40:15 +08:00
30f330f4a0 修复firefox下表单构建拖拽会新打卡一个选项卡 2021-03-30 17:45:35 +08:00
6ca7870393 修正注释 2021-03-30 15:30:18 +08:00
2a7342ec43 !195 读取excel增加非空判断
Merge pull request !195 from 叫我宏锅锅/yuhong
2021-03-30 15:23:04 +08:00
fc57e91b80 !196 RepeatedlyRequestWrapper.ServletInputStream 实现available方法
Merge pull request !196 from wangyang/master
2021-03-30 15:17:34 +08:00
347f36ceff fix:RepeatedlyRequestWrapper.ServletInputStream 实现available方法 2021-03-29 10:17:31 +08:00
9b9c1b999f 读取excel增加
if(row == null)
{
    continue;
}
判断。防止有时候Excel表中有空数据行,导致读取时出现空指针异常。
2021-03-29 09:00:44 +08:00
ec627704b2 取消 2021-03-29 08:58:46 +08:00
9e6b2a1265 读取excel增加
if(row == null)
{
    continue;
}
判断。防止有时候Excel表中有空数据行,导致读取时出现空指针异常。
2021-03-29 08:56:51 +08:00
266a5e844f !193 修复request.getInputStream() 重复读取错误问题
Merge pull request !193 from MccRay/master
2021-03-27 13:22:01 +08:00
0822680158 update ruoyi-common/src/main/java/com/ruoyi/common/filter/RepeatableFilter.java.
修复 getInputStream() has already been called for this request异常问题
2021-03-25 17:39:51 +08:00
090e258bf9 显隐列初始默认隐藏列 2021-03-24 15:46:37 +08:00
505fa06dc3 !192 update ruoyi-ui/src/views/system/user/profile/userAvatar.vue.
Merge pull request !192 from 谢凯/N/A
2021-03-24 15:32:24 +08:00
6cf53bfacb !191 update ruoyi-ui/src/views/system/user/profile/userAvatar.vue.
Merge pull request !191 from allworldg/N/A
2021-03-24 15:31:51 +08:00
881dc3fcf0 update ruoyi-ui/src/views/system/user/profile/userAvatar.vue. 2021-03-22 17:52:34 +08:00
b65c8d4512 update ruoyi-ui/src/views/system/user/profile/userAvatar.vue. 2021-03-21 21:20:23 +08:00
67371a9028 个人信息添加手机&邮箱重复验证 2021-03-21 08:53:11 +08:00
01b545e4ab 通用Controller添加响应返回消息 2021-03-16 14:43:55 +08:00
c2e9200626 数据监控默认账户密码防止越权访问 2021-03-14 16:37:34 +08:00
9502203bbe !187 【漏洞修复】升级commons-collections版本,解决3.2.1版本的反序列化漏洞问题
Merge pull request !187 from Delusive/master
2021-03-14 16:32:07 +08:00
c0f1569ad9 修复commons-collections引起的反序列化漏洞 2021-03-12 16:59:06 +08:00
61432480c8 删除多余的代码 2021-03-07 11:06:47 +08:00
78deee063d !180 富文本编辑组件支持只读
Merge pull request !180 from JOSWAY/master
2021-03-07 10:44:04 +08:00
4ad003649e !182 解决 Byte[] 类型 to string 死循环的问题
Merge pull request !182 from sproutcat/master
2021-03-07 10:39:41 +08:00
616f5a6aca !185 update ruoyi-ui/src/views/monitor/logininfor/index.vue.
Merge pull request !185 from asher/N/A
2021-03-07 10:39:30 +08:00
fea3ff7b2a !184 update ruoyi-ui/src/views/monitor/operlog/index.vue.
Merge pull request !184 from asher/N/A
2021-03-07 10:39:22 +08:00
f938a24df0 update ruoyi-ui/src/views/monitor/logininfor/index.vue. 2021-03-04 17:00:07 +08:00
45fa686a64 update ruoyi-ui/src/views/monitor/operlog/index.vue. 2021-03-04 16:58:18 +08:00
0d8c3b4940 升级oshi到最新版本v5.6.0 2021-03-03 13:53:03 +08:00
64e807f27b 添加新群号:186866453 2021-02-24 13:45:24 +08:00
tzg
9a384a2fc2 解决 Byte[] 类型 to string 死循环的问题 2021-02-23 16:30:14 +08:00
339b932a3d 富文本编辑组件支持只读 2021-02-22 17:49:17 +08:00
284 changed files with 15637 additions and 7804 deletions

View File

@ -7,6 +7,7 @@
* 权限认证使用Jwt支持多终端认证系统。
* 支持加载动态权限菜单,多方式轻松权限控制。
* 高效率开发,使用代码生成器可以一键生成前后端代码。
* 提供了技术栈([Vue3](https://v3.cn.vuejs.org) [Element Plus](https://element-plus.org/zh-CN) [Vite](https://cn.vitejs.dev))版本[RuoYi-Vue3](https://github.com/yangzongzhuan/RuoYi-Vue3),保持同步更新。
* 提供了单应用版本[RuoYi-Vue-fast](https://github.com/yangzongzhuan/RuoYi-Vue-fast)Oracle版本[RuoYi-Vue-Oracle](https://github.com/yangzongzhuan/RuoYi-Vue-Oracle),保持同步更新。
* 不分离版本,请移步[RuoYi](https://gitee.com/y_project/RuoYi),微服务版本,请移步[RuoYi-Cloud](https://gitee.com/y_project/RuoYi-Cloud)
* 特别鸣谢:[element](https://github.com/ElemeFE/element)[vue-element-admin](https://github.com/PanJiaChen/vue-element-admin)[eladmin-web](https://github.com/elunez/eladmin-web)。
@ -82,4 +83,4 @@
## 若依前后端分离交流群
QQ群 [![加入QQ群](https://img.shields.io/badge/已满-937441-blue.svg)](https://jq.qq.com/?_wv=1027&k=5bVB1og) [![加入QQ群](https://img.shields.io/badge/已满-887144332-blue.svg)](https://jq.qq.com/?_wv=1027&k=5eiA4DH) [![加入QQ群](https://img.shields.io/badge/已满-180251782-blue.svg)](https://jq.qq.com/?_wv=1027&k=5AxMKlC) [![加入QQ群](https://img.shields.io/badge/104180207-blue.svg)](https://jq.qq.com/?_wv=1027&k=51G72yr) 点击按钮入群。
QQ群 [![加入QQ群](https://img.shields.io/badge/已满-937441-blue.svg)](https://jq.qq.com/?_wv=1027&k=5bVB1og) [![加入QQ群](https://img.shields.io/badge/已满-887144332-blue.svg)](https://jq.qq.com/?_wv=1027&k=5eiA4DH) [![加入QQ群](https://img.shields.io/badge/已满-180251782-blue.svg)](https://jq.qq.com/?_wv=1027&k=5AxMKlC) [![加入QQ群](https://img.shields.io/badge/已满-104180207-blue.svg)](https://jq.qq.com/?_wv=1027&k=51G72yr) [![加入QQ群](https://img.shields.io/badge/已满-186866453-blue.svg)](https://jq.qq.com/?_wv=1027&k=VvjN2nvu) [![加入QQ群](https://img.shields.io/badge/已满-201396349-blue.svg)](https://jq.qq.com/?_wv=1027&k=5vYAqA05) [![加入QQ群](https://img.shields.io/badge/已满-101456076-blue.svg)](https://jq.qq.com/?_wv=1027&k=kOIINEb5) [![加入QQ群](https://img.shields.io/badge/101539465-blue.svg)](https://jq.qq.com/?_wv=1027&k=UKtX5jhs) 点击按钮入群。

View File

@ -1,6 +1,6 @@
@echo off
echo.
echo [<5B><>Ϣ] <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>·<EFBFBD><C2B7><EFBFBD><EFBFBD>
echo [<5B><>Ϣ] <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>target<EFBFBD><EFBFBD><EFBFBD><EFBFBD>·<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
echo.
%~d0

View File

@ -1,6 +1,6 @@
@echo off
echo.
echo [<5B><>Ϣ] <20><><EFBFBD><EFBFBD>Web<65><62><EFBFBD>̡<EFBFBD>
echo [<5B><>Ϣ] ʹ<EFBFBD><EFBFBD>Jar<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Web<EFBFBD><EFBFBD><EFBFBD>̡<EFBFBD>
echo.
cd %~dp0

125
pom.xml
View File

@ -6,67 +6,77 @@
<groupId>com.ruoyi</groupId>
<artifactId>ruoyi</artifactId>
<version>3.4.0</version>
<version>3.8.1</version>
<name>ruoyi</name>
<url>http://www.ruoyi.vip</url>
<description>若依管理系统</description>
<properties>
<ruoyi.version>3.4.0</ruoyi.version>
<ruoyi.version>3.8.1</ruoyi.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
<maven-jar-plugin.version>3.1.1</maven-jar-plugin.version>
<druid.version>1.2.4</druid.version>
<druid.version>1.2.8</druid.version>
<bitwalker.version>1.21</bitwalker.version>
<swagger.version>2.9.2</swagger.version>
<kaptcha.version>2.3.2</kaptcha.version>
<pagehelper.boot.version>1.3.0</pagehelper.boot.version>
<fastjson.version>1.2.75</fastjson.version>
<oshi.version>5.3.6</oshi.version>
<jna.version>5.6.0</jna.version>
<commons.io.version>2.5</commons.io.version>
<commons.fileupload.version>1.3.3</commons.fileupload.version>
<swagger.version>3.0.0</swagger.version>
<kaptcha.version>2.3.2</kaptcha.version>
<mybatis-spring-boot.version>2.2.0</mybatis-spring-boot.version>
<pagehelper.boot.version>1.4.0</pagehelper.boot.version>
<fastjson.version>1.2.79</fastjson.version>
<oshi.version>5.8.6</oshi.version>
<jna.version>5.10.0</jna.version>
<commons.io.version>2.11.0</commons.io.version>
<commons.fileupload.version>1.4</commons.fileupload.version>
<commons.collections.version>3.2.2</commons.collections.version>
<poi.version>4.1.2</poi.version>
<velocity.version>1.7</velocity.version>
<velocity.version>2.3</velocity.version>
<log4j2.version>2.17.1</log4j2.version>
<jwt.version>0.9.1</jwt.version>
</properties>
<!-- 依赖声明 -->
<dependencyManagement>
<dependencies>
<!-- SpringBoot的依赖配置-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>2.2.13.RELEASE</version>
<version>2.5.8</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<!--阿里数据库连接池 -->
<!-- 阿里数据库连接池 -->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid-spring-boot-starter</artifactId>
<version>${druid.version}</version>
</dependency>
<!-- 解析客户端操作系统、浏览器等 -->
<dependency>
<groupId>eu.bitwalker</groupId>
<artifactId>UserAgentUtils</artifactId>
<version>${bitwalker.version}</version>
</dependency>
<!-- SpringBoot集成mybatis框架 -->
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>${mybatis-spring-boot.version}</version>
</dependency>
<!-- pagehelper 分页插件 -->
<dependency>
<groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper-spring-boot-starter</artifactId>
<version>${pagehelper.boot.version}</version>
</dependency>
<!-- 获取系统信息 -->
<dependency>
<groupId>com.github.oshi</groupId>
@ -85,108 +95,117 @@
<artifactId>jna-platform</artifactId>
<version>${jna.version}</version>
</dependency>
<!-- swagger2-->
<!-- Swagger3依赖 -->
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<artifactId>springfox-boot-starter</artifactId>
<version>${swagger.version}</version>
<exclusions>
<exclusion>
<groupId>io.swagger</groupId>
<artifactId>swagger-annotations</artifactId>
</exclusion>
<exclusion>
<groupId>io.swagger</groupId>
<artifactId>swagger-models</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- swagger2-UI-->
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>${swagger.version}</version>
</dependency>
<!--io常用工具类 -->
<!-- io常用工具类 -->
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>${commons.io.version}</version>
</dependency>
<!--文件上传工具类 -->
<!-- 文件上传工具类 -->
<dependency>
<groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId>
<version>${commons.fileupload.version}</version>
</dependency>
<!-- excel工具 -->
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>${poi.version}</version>
</dependency>
<!--velocity代码生成使用模板 -->
<!-- velocity代码生成使用模板 -->
<dependency>
<groupId>org.apache.velocity</groupId>
<artifactId>velocity</artifactId>
<artifactId>velocity-engine-core</artifactId>
<version>${velocity.version}</version>
</dependency>
<!-- collections工具类 -->
<dependency>
<groupId>commons-collections</groupId>
<artifactId>commons-collections</artifactId>
<version>${commons.collections.version}</version>
</dependency>
<!-- 阿里JSON解析器 -->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>${fastjson.version}</version>
</dependency>
<!--Token生成与解析-->
<!-- log4j日志组件 -->
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>${log4j2.version}</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-to-slf4j</artifactId>
<version>${log4j2.version}</version>
</dependency>
<!-- Token生成与解析-->
<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt</artifactId>
<version>${jwt.version}</version>
</dependency>
<!--验证码 -->
<!-- 验证码 -->
<dependency>
<groupId>com.github.penggle</groupId>
<artifactId>kaptcha</artifactId>
<version>${kaptcha.version}</version>
</dependency>
<!-- 定时任务-->
<dependency>
<groupId>com.ruoyi</groupId>
<artifactId>ruoyi-quartz</artifactId>
<version>${ruoyi.version}</version>
</dependency>
<!-- 代码生成-->
<dependency>
<groupId>com.ruoyi</groupId>
<artifactId>ruoyi-generator</artifactId>
<version>${ruoyi.version}</version>
</dependency>
<!-- 核心模块-->
<dependency>
<groupId>com.ruoyi</groupId>
<artifactId>ruoyi-framework</artifactId>
<version>${ruoyi.version}</version>
</dependency>
<!-- 系统模块-->
<dependency>
<groupId>com.ruoyi</groupId>
<artifactId>ruoyi-system</artifactId>
<version>${ruoyi.version}</version>
</dependency>
<!-- 通用工具-->
<dependency>
<groupId>com.ruoyi</groupId>
@ -231,7 +250,7 @@
<repository>
<id>public</id>
<name>aliyun nexus</name>
<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
<url>https://maven.aliyun.com/repository/public</url>
<releases>
<enabled>true</enabled>
</releases>
@ -242,7 +261,7 @@
<pluginRepository>
<id>public</id>
<name>aliyun nexus</name>
<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
<url>https://maven.aliyun.com/repository/public</url>
<releases>
<enabled>true</enabled>
</releases>

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>ruoyi</artifactId>
<groupId>com.ruoyi</groupId>
<version>3.4.0</version>
<version>3.8.1</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<packaging>jar</packaging>
@ -24,29 +24,17 @@
<optional>true</optional> <!-- 表示依赖不会传递 -->
</dependency>
<!-- swagger2-->
<!-- swagger3-->
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
</dependency>
<!--防止进入swagger页面报类型转换错误排除2.9.2中的引用手动增加1.5.21版本-->
<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-annotations</artifactId>
<version>1.5.21</version>
<artifactId>springfox-boot-starter</artifactId>
</dependency>
<!-- 防止进入swagger页面报类型转换错误排除3.0.0中的引用手动增加1.6.2版本 -->
<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-models</artifactId>
<version>1.5.21</version>
</dependency>
<!-- swagger2-UI-->
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>1.6.2</version>
</dependency>
<!-- Mysql驱动包 -->

View File

@ -6,8 +6,8 @@ import java.util.concurrent.TimeUnit;
import javax.annotation.Resource;
import javax.imageio.ImageIO;
import javax.servlet.http.HttpServletResponse;
import com.ruoyi.common.config.RuoYiConfig;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.util.FastByteArrayOutputStream;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
@ -17,6 +17,7 @@ import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.redis.RedisCache;
import com.ruoyi.common.utils.sign.Base64;
import com.ruoyi.common.utils.uuid.IdUtils;
import com.ruoyi.system.service.ISysConfigService;
/**
* 验证码操作处理
@ -35,16 +36,22 @@ public class CaptchaController
@Autowired
private RedisCache redisCache;
// 验证码类型
@Value("${ruoyi.captchaType}")
private String captchaType;
@Autowired
private ISysConfigService configService;
/**
* 生成验证码
*/
@GetMapping("/captchaImage")
public AjaxResult getCode(HttpServletResponse response) throws IOException
{
AjaxResult ajax = AjaxResult.success();
boolean captchaOnOff = configService.selectCaptchaOnOff();
ajax.put("captchaOnOff", captchaOnOff);
if (!captchaOnOff)
{
return ajax;
}
// 保存验证码信息
String uuid = IdUtils.simpleUUID();
String verifyKey = Constants.CAPTCHA_CODE_KEY + uuid;
@ -53,6 +60,7 @@ public class CaptchaController
BufferedImage image = null;
// 生成验证码
String captchaType = RuoYiConfig.getCaptchaType();
if ("math".equals(captchaType))
{
String capText = captchaProducerMath.createText();
@ -78,7 +86,6 @@ public class CaptchaController
return AjaxResult.error(e.getMessage());
}
AjaxResult ajax = AjaxResult.success();
ajax.put("uuid", uuid);
ajax.put("img", Base64.encode(os.toByteArray()));
return ajax;

View File

@ -1,11 +1,13 @@
package com.ruoyi.web.controller.monitor;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
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.RestController;
import com.ruoyi.common.annotation.Log;
@ -40,12 +42,12 @@ public class SysLogininforController extends BaseController
@Log(title = "登录日志", businessType = BusinessType.EXPORT)
@PreAuthorize("@ss.hasPermi('monitor:logininfor:export')")
@GetMapping("/export")
public AjaxResult export(SysLogininfor logininfor)
@PostMapping("/export")
public void export(HttpServletResponse response, SysLogininfor logininfor)
{
List<SysLogininfor> list = logininforService.selectLogininforList(logininfor);
ExcelUtil<SysLogininfor> util = new ExcelUtil<SysLogininfor>(SysLogininfor.class);
return util.exportExcel(list, "登录日志");
util.exportExcel(response, list, "登录日志");
}
@PreAuthorize("@ss.hasPermi('monitor:logininfor:remove')")

View File

@ -1,11 +1,13 @@
package com.ruoyi.web.controller.monitor;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
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.RestController;
import com.ruoyi.common.annotation.Log;
@ -40,14 +42,15 @@ public class SysOperlogController extends BaseController
@Log(title = "操作日志", businessType = BusinessType.EXPORT)
@PreAuthorize("@ss.hasPermi('monitor:operlog:export')")
@GetMapping("/export")
public AjaxResult export(SysOperLog operLog)
@PostMapping("/export")
public void export(HttpServletResponse response, SysOperLog operLog)
{
List<SysOperLog> list = operLogService.selectOperLogList(operLog);
ExcelUtil<SysOperLog> util = new ExcelUtil<SysOperLog>(SysOperLog.class);
return util.exportExcel(list, "操作日志");
util.exportExcel(response, list, "操作日志");
}
@Log(title = "操作日志", businessType = BusinessType.DELETE)
@PreAuthorize("@ss.hasPermi('monitor:operlog:remove')")
@DeleteMapping("/{operIds}")
public AjaxResult remove(@PathVariable Long[] operIds)

View File

@ -1,6 +1,7 @@
package com.ruoyi.web.controller.system;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
@ -13,13 +14,11 @@ import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.annotation.RepeatSubmit;
import com.ruoyi.common.constant.UserConstants;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.system.domain.SysConfig;
import com.ruoyi.system.service.ISysConfigService;
@ -50,12 +49,12 @@ public class SysConfigController extends BaseController
@Log(title = "参数管理", businessType = BusinessType.EXPORT)
@PreAuthorize("@ss.hasPermi('system:config:export')")
@GetMapping("/export")
public AjaxResult export(SysConfig config)
@PostMapping("/export")
public void export(HttpServletResponse response, SysConfig config)
{
List<SysConfig> list = configService.selectConfigList(config);
ExcelUtil<SysConfig> util = new ExcelUtil<SysConfig>(SysConfig.class);
return util.exportExcel(list, "参数数据");
util.exportExcel(response, list, "参数数据");
}
/**
@ -83,14 +82,13 @@ public class SysConfigController extends BaseController
@PreAuthorize("@ss.hasPermi('system:config:add')")
@Log(title = "参数管理", businessType = BusinessType.INSERT)
@PostMapping
@RepeatSubmit
public AjaxResult add(@Validated @RequestBody SysConfig config)
{
if (UserConstants.NOT_UNIQUE.equals(configService.checkConfigKeyUnique(config)))
{
return AjaxResult.error("新增参数'" + config.getConfigName() + "'失败,参数键名已存在");
}
config.setCreateBy(SecurityUtils.getUsername());
config.setCreateBy(getUsername());
return toAjax(configService.insertConfig(config));
}
@ -106,7 +104,7 @@ public class SysConfigController extends BaseController
{
return AjaxResult.error("修改参数'" + config.getConfigName() + "'失败,参数键名已存在");
}
config.setUpdateBy(SecurityUtils.getUsername());
config.setUpdateBy(getUsername());
return toAjax(configService.updateConfig(config));
}
@ -118,18 +116,19 @@ public class SysConfigController extends BaseController
@DeleteMapping("/{configIds}")
public AjaxResult remove(@PathVariable Long[] configIds)
{
return toAjax(configService.deleteConfigByIds(configIds));
configService.deleteConfigByIds(configIds);
return success();
}
/**
* 清空缓存
* 刷新参数缓存
*/
@PreAuthorize("@ss.hasPermi('system:config:remove')")
@Log(title = "参数管理", businessType = BusinessType.CLEAN)
@DeleteMapping("/clearCache")
public AjaxResult clearCache()
@DeleteMapping("/refreshCache")
public AjaxResult refreshCache()
{
configService.clearCache();
configService.resetConfigCache();
return AjaxResult.success();
}
}

View File

@ -20,7 +20,6 @@ import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.entity.SysDept;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.system.service.ISysDeptService;
@ -75,6 +74,7 @@ public class SysDeptController extends BaseController
@GetMapping(value = "/{deptId}")
public AjaxResult getInfo(@PathVariable Long deptId)
{
deptService.checkDeptDataScope(deptId);
return AjaxResult.success(deptService.selectDeptById(deptId));
}
@ -113,7 +113,7 @@ public class SysDeptController extends BaseController
{
return AjaxResult.error("新增部门'" + dept.getDeptName() + "'失败,部门名称已存在");
}
dept.setCreateBy(SecurityUtils.getUsername());
dept.setCreateBy(getUsername());
return toAjax(deptService.insertDept(dept));
}
@ -138,7 +138,7 @@ public class SysDeptController extends BaseController
{
return AjaxResult.error("该部门包含未停用的子部门!");
}
dept.setUpdateBy(SecurityUtils.getUsername());
dept.setUpdateBy(getUsername());
return toAjax(deptService.updateDept(dept));
}

View File

@ -2,6 +2,7 @@ package com.ruoyi.web.controller.system;
import java.util.ArrayList;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
@ -19,7 +20,6 @@ import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.entity.SysDictData;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.system.service.ISysDictDataService;
@ -51,12 +51,12 @@ public class SysDictDataController extends BaseController
@Log(title = "字典数据", businessType = BusinessType.EXPORT)
@PreAuthorize("@ss.hasPermi('system:dict:export')")
@GetMapping("/export")
public AjaxResult export(SysDictData dictData)
@PostMapping("/export")
public void export(HttpServletResponse response, SysDictData dictData)
{
List<SysDictData> list = dictDataService.selectDictDataList(dictData);
ExcelUtil<SysDictData> util = new ExcelUtil<SysDictData>(SysDictData.class);
return util.exportExcel(list, "字典数据");
util.exportExcel(response, list, "字典数据");
}
/**
@ -91,7 +91,7 @@ public class SysDictDataController extends BaseController
@PostMapping
public AjaxResult add(@Validated @RequestBody SysDictData dict)
{
dict.setCreateBy(SecurityUtils.getUsername());
dict.setCreateBy(getUsername());
return toAjax(dictDataService.insertDictData(dict));
}
@ -103,7 +103,7 @@ public class SysDictDataController extends BaseController
@PutMapping
public AjaxResult edit(@Validated @RequestBody SysDictData dict)
{
dict.setUpdateBy(SecurityUtils.getUsername());
dict.setUpdateBy(getUsername());
return toAjax(dictDataService.updateDictData(dict));
}
@ -115,6 +115,7 @@ public class SysDictDataController extends BaseController
@DeleteMapping("/{dictCodes}")
public AjaxResult remove(@PathVariable Long[] dictCodes)
{
return toAjax(dictDataService.deleteDictDataByIds(dictCodes));
dictDataService.deleteDictDataByIds(dictCodes);
return success();
}
}

View File

@ -1,6 +1,7 @@
package com.ruoyi.web.controller.system;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
@ -19,7 +20,6 @@ import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.entity.SysDictType;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.system.service.ISysDictTypeService;
@ -46,12 +46,12 @@ public class SysDictTypeController extends BaseController
@Log(title = "字典类型", businessType = BusinessType.EXPORT)
@PreAuthorize("@ss.hasPermi('system:dict:export')")
@GetMapping("/export")
public AjaxResult export(SysDictType dictType)
@PostMapping("/export")
public void export(HttpServletResponse response, SysDictType dictType)
{
List<SysDictType> list = dictTypeService.selectDictTypeList(dictType);
ExcelUtil<SysDictType> util = new ExcelUtil<SysDictType>(SysDictType.class);
return util.exportExcel(list, "字典类型");
util.exportExcel(response, list, "字典类型");
}
/**
@ -76,7 +76,7 @@ public class SysDictTypeController extends BaseController
{
return AjaxResult.error("新增字典'" + dict.getDictName() + "'失败,字典类型已存在");
}
dict.setCreateBy(SecurityUtils.getUsername());
dict.setCreateBy(getUsername());
return toAjax(dictTypeService.insertDictType(dict));
}
@ -92,7 +92,7 @@ public class SysDictTypeController extends BaseController
{
return AjaxResult.error("修改字典'" + dict.getDictName() + "'失败,字典类型已存在");
}
dict.setUpdateBy(SecurityUtils.getUsername());
dict.setUpdateBy(getUsername());
return toAjax(dictTypeService.updateDictType(dict));
}
@ -104,18 +104,19 @@ public class SysDictTypeController extends BaseController
@DeleteMapping("/{dictIds}")
public AjaxResult remove(@PathVariable Long[] dictIds)
{
return toAjax(dictTypeService.deleteDictTypeByIds(dictIds));
dictTypeService.deleteDictTypeByIds(dictIds);
return success();
}
/**
* 清空缓存
* 刷新字典缓存
*/
@PreAuthorize("@ss.hasPermi('system:dict:remove')")
@Log(title = "字典类型", businessType = BusinessType.CLEAN)
@DeleteMapping("/clearCache")
public AjaxResult clearCache()
@DeleteMapping("/refreshCache")
public AjaxResult refreshCache()
{
dictTypeService.clearCache();
dictTypeService.resetDictCache();
return AjaxResult.success();
}

View File

@ -0,0 +1,29 @@
package com.ruoyi.web.controller.system;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.config.RuoYiConfig;
import com.ruoyi.common.utils.StringUtils;
/**
* 首页
*
* @author ruoyi
*/
@RestController
public class SysIndexController
{
/** 系统基础配置 */
@Autowired
private RuoYiConfig ruoyiConfig;
/**
* 访问首页,提示语
*/
@RequestMapping("/")
public String index()
{
return StringUtils.format("欢迎使用{}后台管理框架当前版本v{},请通过前端地址访问。", ruoyiConfig.getName(), ruoyiConfig.getVersion());
}
}

View File

@ -12,11 +12,9 @@ import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.entity.SysMenu;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.core.domain.model.LoginBody;
import com.ruoyi.common.core.domain.model.LoginUser;
import com.ruoyi.common.utils.ServletUtils;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.framework.web.service.SysLoginService;
import com.ruoyi.framework.web.service.SysPermissionService;
import com.ruoyi.framework.web.service.TokenService;
import com.ruoyi.system.service.ISysMenuService;
/**
@ -36,9 +34,6 @@ public class SysLoginController
@Autowired
private SysPermissionService permissionService;
@Autowired
private TokenService tokenService;
/**
* 登录方法
*
@ -64,8 +59,7 @@ public class SysLoginController
@GetMapping("getInfo")
public AjaxResult getInfo()
{
LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
SysUser user = loginUser.getUser();
SysUser user = SecurityUtils.getLoginUser().getUser();
// 角色集合
Set<String> roles = permissionService.getRolePermission(user);
// 权限集合
@ -85,10 +79,8 @@ public class SysLoginController
@GetMapping("getRouters")
public AjaxResult getRouters()
{
LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
// 用户信息
SysUser user = loginUser.getUser();
List<SysMenu> menus = menuService.selectMenuTreeByUserId(user.getUserId());
Long userId = SecurityUtils.getUserId();
List<SysMenu> menus = menuService.selectMenuTreeByUserId(userId);
return AjaxResult.success(menuService.buildMenus(menus));
}
}

View File

@ -13,17 +13,12 @@ import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.constant.Constants;
import com.ruoyi.common.constant.UserConstants;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.entity.SysMenu;
import com.ruoyi.common.core.domain.model.LoginUser;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.ServletUtils;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.framework.web.service.TokenService;
import com.ruoyi.system.service.ISysMenuService;
/**
@ -38,9 +33,6 @@ public class SysMenuController extends BaseController
@Autowired
private ISysMenuService menuService;
@Autowired
private TokenService tokenService;
/**
* 获取菜单列表
*/
@ -48,9 +40,7 @@ public class SysMenuController extends BaseController
@GetMapping("/list")
public AjaxResult list(SysMenu menu)
{
LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
Long userId = loginUser.getUser().getUserId();
List<SysMenu> menus = menuService.selectMenuList(menu, userId);
List<SysMenu> menus = menuService.selectMenuList(menu, getUserId());
return AjaxResult.success(menus);
}
@ -70,9 +60,7 @@ public class SysMenuController extends BaseController
@GetMapping("/treeselect")
public AjaxResult treeselect(SysMenu menu)
{
LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
Long userId = loginUser.getUser().getUserId();
List<SysMenu> menus = menuService.selectMenuList(menu, userId);
List<SysMenu> menus = menuService.selectMenuList(menu, getUserId());
return AjaxResult.success(menuService.buildMenuTreeSelect(menus));
}
@ -82,8 +70,7 @@ public class SysMenuController extends BaseController
@GetMapping(value = "/roleMenuTreeselect/{roleId}")
public AjaxResult roleMenuTreeselect(@PathVariable("roleId") Long roleId)
{
LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
List<SysMenu> menus = menuService.selectMenuList(loginUser.getUser().getUserId());
List<SysMenu> menus = menuService.selectMenuList(getUserId());
AjaxResult ajax = AjaxResult.success();
ajax.put("checkedKeys", menuService.selectMenuListByRoleId(roleId));
ajax.put("menus", menuService.buildMenuTreeSelect(menus));
@ -102,12 +89,11 @@ public class SysMenuController extends BaseController
{
return AjaxResult.error("新增菜单'" + menu.getMenuName() + "'失败,菜单名称已存在");
}
else if (UserConstants.YES_FRAME.equals(menu.getIsFrame())
&& !StringUtils.startsWithAny(menu.getPath(), Constants.HTTP, Constants.HTTPS))
else if (UserConstants.YES_FRAME.equals(menu.getIsFrame()) && !StringUtils.ishttp(menu.getPath()))
{
return AjaxResult.error("新增菜单'" + menu.getMenuName() + "'失败地址必须以http(s)://开头");
}
menu.setCreateBy(SecurityUtils.getUsername());
menu.setCreateBy(getUsername());
return toAjax(menuService.insertMenu(menu));
}
@ -123,8 +109,7 @@ public class SysMenuController extends BaseController
{
return AjaxResult.error("修改菜单'" + menu.getMenuName() + "'失败,菜单名称已存在");
}
else if (UserConstants.YES_FRAME.equals(menu.getIsFrame())
&& !StringUtils.startsWithAny(menu.getPath(), Constants.HTTP, Constants.HTTPS))
else if (UserConstants.YES_FRAME.equals(menu.getIsFrame()) && !StringUtils.ishttp(menu.getPath()))
{
return AjaxResult.error("修改菜单'" + menu.getMenuName() + "'失败地址必须以http(s)://开头");
}
@ -132,7 +117,7 @@ public class SysMenuController extends BaseController
{
return AjaxResult.error("修改菜单'" + menu.getMenuName() + "'失败,上级菜单不能选择自己");
}
menu.setUpdateBy(SecurityUtils.getUsername());
menu.setUpdateBy(getUsername());
return toAjax(menuService.updateMenu(menu));
}

View File

@ -17,7 +17,6 @@ import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.system.domain.SysNotice;
import com.ruoyi.system.service.ISysNoticeService;
@ -63,7 +62,7 @@ public class SysNoticeController extends BaseController
@PostMapping
public AjaxResult add(@Validated @RequestBody SysNotice notice)
{
notice.setCreateBy(SecurityUtils.getUsername());
notice.setCreateBy(getUsername());
return toAjax(noticeService.insertNotice(notice));
}
@ -75,7 +74,7 @@ public class SysNoticeController extends BaseController
@PutMapping
public AjaxResult edit(@Validated @RequestBody SysNotice notice)
{
notice.setUpdateBy(SecurityUtils.getUsername());
notice.setUpdateBy(getUsername());
return toAjax(noticeService.updateNotice(notice));
}

View File

@ -1,6 +1,7 @@
package com.ruoyi.web.controller.system;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
@ -18,7 +19,6 @@ import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.system.domain.SysPost;
import com.ruoyi.system.service.ISysPostService;
@ -49,12 +49,12 @@ public class SysPostController extends BaseController
@Log(title = "岗位管理", businessType = BusinessType.EXPORT)
@PreAuthorize("@ss.hasPermi('system:post:export')")
@GetMapping("/export")
public AjaxResult export(SysPost post)
@PostMapping("/export")
public void export(HttpServletResponse response, SysPost post)
{
List<SysPost> list = postService.selectPostList(post);
ExcelUtil<SysPost> util = new ExcelUtil<SysPost>(SysPost.class);
return util.exportExcel(list, "岗位数据");
util.exportExcel(response, list, "岗位数据");
}
/**
@ -83,7 +83,7 @@ public class SysPostController extends BaseController
{
return AjaxResult.error("新增岗位'" + post.getPostName() + "'失败,岗位编码已存在");
}
post.setCreateBy(SecurityUtils.getUsername());
post.setCreateBy(getUsername());
return toAjax(postService.insertPost(post));
}
@ -103,7 +103,7 @@ public class SysPostController extends BaseController
{
return AjaxResult.error("修改岗位'" + post.getPostName() + "'失败,岗位编码已存在");
}
post.setUpdateBy(SecurityUtils.getUsername());
post.setUpdateBy(getUsername());
return toAjax(postService.updatePost(post));
}

View File

@ -12,13 +12,14 @@ import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.config.RuoYiConfig;
import com.ruoyi.common.constant.UserConstants;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.core.domain.model.LoginUser;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.ServletUtils;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.file.FileUploadUtils;
import com.ruoyi.framework.web.service.TokenService;
import com.ruoyi.system.service.ISysUserService;
@ -44,7 +45,7 @@ public class SysProfileController extends BaseController
@GetMapping
public AjaxResult profile()
{
LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
LoginUser loginUser = getLoginUser();
SysUser user = loginUser.getUser();
AjaxResult ajax = AjaxResult.success(user);
ajax.put("roleGroup", userService.selectUserRoleGroup(loginUser.getUsername()));
@ -59,14 +60,28 @@ public class SysProfileController extends BaseController
@PutMapping
public AjaxResult updateProfile(@RequestBody SysUser user)
{
LoginUser loginUser = getLoginUser();
SysUser sysUser = loginUser.getUser();
user.setUserName(sysUser.getUserName());
if (StringUtils.isNotEmpty(user.getPhonenumber())
&& UserConstants.NOT_UNIQUE.equals(userService.checkPhoneUnique(user)))
{
return AjaxResult.error("修改用户'" + user.getUserName() + "'失败,手机号码已存在");
}
if (StringUtils.isNotEmpty(user.getEmail())
&& UserConstants.NOT_UNIQUE.equals(userService.checkEmailUnique(user)))
{
return AjaxResult.error("修改用户'" + user.getUserName() + "'失败,邮箱账号已存在");
}
user.setUserId(sysUser.getUserId());
user.setPassword(null);
if (userService.updateUserProfile(user) > 0)
{
LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
// 更新缓存用户信息
loginUser.getUser().setNickName(user.getNickName());
loginUser.getUser().setPhonenumber(user.getPhonenumber());
loginUser.getUser().setEmail(user.getEmail());
loginUser.getUser().setSex(user.getSex());
sysUser.setNickName(user.getNickName());
sysUser.setPhonenumber(user.getPhonenumber());
sysUser.setEmail(user.getEmail());
sysUser.setSex(user.getSex());
tokenService.setLoginUser(loginUser);
return AjaxResult.success();
}
@ -80,7 +95,7 @@ public class SysProfileController extends BaseController
@PutMapping("/updatePwd")
public AjaxResult updatePwd(String oldPassword, String newPassword)
{
LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
LoginUser loginUser = getLoginUser();
String userName = loginUser.getUsername();
String password = loginUser.getPassword();
if (!SecurityUtils.matchesPassword(oldPassword, password))
@ -110,7 +125,7 @@ public class SysProfileController extends BaseController
{
if (!file.isEmpty())
{
LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
LoginUser loginUser = getLoginUser();
String avatar = FileUploadUtils.upload(RuoYiConfig.getAvatarPath(), file);
if (userService.updateUserAvatar(loginUser.getUsername(), avatar))
{

View File

@ -0,0 +1,38 @@
package com.ruoyi.web.controller.system;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.model.RegisterBody;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.framework.web.service.SysRegisterService;
import com.ruoyi.system.service.ISysConfigService;
/**
* 注册验证
*
* @author ruoyi
*/
@RestController
public class SysRegisterController extends BaseController
{
@Autowired
private SysRegisterService registerService;
@Autowired
private ISysConfigService configService;
@PostMapping("/register")
public AjaxResult register(@RequestBody RegisterBody user)
{
if (!("true".equals(configService.selectConfigByKey("sys.account.registerUser"))))
{
return error("当前系统没有开启注册功能!");
}
String msg = registerService.register(user);
return StringUtils.isEmpty(msg) ? success() : error(msg);
}
}

View File

@ -1,6 +1,7 @@
package com.ruoyi.web.controller.system;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
@ -17,15 +18,15 @@ import com.ruoyi.common.constant.UserConstants;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.entity.SysRole;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.core.domain.model.LoginUser;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.ServletUtils;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.service.SysPermissionService;
import com.ruoyi.framework.web.service.TokenService;
import com.ruoyi.system.domain.SysUserRole;
import com.ruoyi.system.service.ISysRoleService;
import com.ruoyi.system.service.ISysUserService;
@ -61,12 +62,12 @@ public class SysRoleController extends BaseController
@Log(title = "角色管理", businessType = BusinessType.EXPORT)
@PreAuthorize("@ss.hasPermi('system:role:export')")
@GetMapping("/export")
public AjaxResult export(SysRole role)
@PostMapping("/export")
public void export(HttpServletResponse response, SysRole role)
{
List<SysRole> list = roleService.selectRoleList(role);
ExcelUtil<SysRole> util = new ExcelUtil<SysRole>(SysRole.class);
return util.exportExcel(list, "角色数据");
util.exportExcel(response, list, "角色数据");
}
/**
@ -76,6 +77,7 @@ public class SysRoleController extends BaseController
@GetMapping(value = "/{roleId}")
public AjaxResult getInfo(@PathVariable Long roleId)
{
roleService.checkRoleDataScope(roleId);
return AjaxResult.success(roleService.selectRoleById(roleId));
}
@ -95,7 +97,7 @@ public class SysRoleController extends BaseController
{
return AjaxResult.error("新增角色'" + role.getRoleName() + "'失败,角色权限已存在");
}
role.setCreateBy(SecurityUtils.getUsername());
role.setCreateBy(getUsername());
return toAjax(roleService.insertRole(role));
}
@ -117,12 +119,12 @@ public class SysRoleController extends BaseController
{
return AjaxResult.error("修改角色'" + role.getRoleName() + "'失败,角色权限已存在");
}
role.setUpdateBy(SecurityUtils.getUsername());
role.setUpdateBy(getUsername());
if (roleService.updateRole(role) > 0)
{
// 更新缓存用户权限
LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
LoginUser loginUser = getLoginUser();
if (StringUtils.isNotNull(loginUser.getUser()) && !loginUser.getUser().isAdmin())
{
loginUser.setPermissions(permissionService.getMenuPermission(loginUser.getUser()));
@ -155,7 +157,7 @@ public class SysRoleController extends BaseController
public AjaxResult changeStatus(@RequestBody SysRole role)
{
roleService.checkRoleAllowed(role);
role.setUpdateBy(SecurityUtils.getUsername());
role.setUpdateBy(getUsername());
return toAjax(roleService.updateRoleStatus(role));
}
@ -179,4 +181,61 @@ public class SysRoleController extends BaseController
{
return AjaxResult.success(roleService.selectRoleAll());
}
/**
* 查询已分配用户角色列表
*/
@PreAuthorize("@ss.hasPermi('system:role:list')")
@GetMapping("/authUser/allocatedList")
public TableDataInfo allocatedList(SysUser user)
{
startPage();
List<SysUser> list = userService.selectAllocatedList(user);
return getDataTable(list);
}
/**
* 查询未分配用户角色列表
*/
@PreAuthorize("@ss.hasPermi('system:role:list')")
@GetMapping("/authUser/unallocatedList")
public TableDataInfo unallocatedList(SysUser user)
{
startPage();
List<SysUser> list = userService.selectUnallocatedList(user);
return getDataTable(list);
}
/**
* 取消授权用户
*/
@PreAuthorize("@ss.hasPermi('system:role:edit')")
@Log(title = "角色管理", businessType = BusinessType.GRANT)
@PutMapping("/authUser/cancel")
public AjaxResult cancelAuthUser(@RequestBody SysUserRole userRole)
{
return toAjax(roleService.deleteAuthUser(userRole));
}
/**
* 批量取消授权用户
*/
@PreAuthorize("@ss.hasPermi('system:role:edit')")
@Log(title = "角色管理", businessType = BusinessType.GRANT)
@PutMapping("/authUser/cancelAll")
public AjaxResult cancelAuthUserAll(Long roleId, Long[] userIds)
{
return toAjax(roleService.deleteAuthUsers(roleId, userIds));
}
/**
* 批量选择用户授权
*/
@PreAuthorize("@ss.hasPermi('system:role:edit')")
@Log(title = "角色管理", businessType = BusinessType.GRANT)
@PutMapping("/authUser/selectAll")
public AjaxResult selectAuthUserAll(Long roleId, Long[] userIds)
{
return toAjax(roleService.insertAuthUsers(roleId, userIds));
}
}

View File

@ -2,6 +2,8 @@ package com.ruoyi.web.controller.system;
import java.util.List;
import java.util.stream.Collectors;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.lang3.ArrayUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
@ -20,14 +22,11 @@ import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.entity.SysRole;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.core.domain.model.LoginUser;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.ServletUtils;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.service.TokenService;
import com.ruoyi.system.service.ISysPostService;
import com.ruoyi.system.service.ISysRoleService;
import com.ruoyi.system.service.ISysUserService;
@ -50,9 +49,6 @@ public class SysUserController extends BaseController
@Autowired
private ISysPostService postService;
@Autowired
private TokenService tokenService;
/**
* 获取用户列表
*/
@ -67,12 +63,12 @@ public class SysUserController extends BaseController
@Log(title = "用户管理", businessType = BusinessType.EXPORT)
@PreAuthorize("@ss.hasPermi('system:user:export')")
@GetMapping("/export")
public AjaxResult export(SysUser user)
@PostMapping("/export")
public void export(HttpServletResponse response, SysUser user)
{
List<SysUser> list = userService.selectUserList(user);
ExcelUtil<SysUser> util = new ExcelUtil<SysUser>(SysUser.class);
return util.exportExcel(list, "用户数据");
util.exportExcel(response, list, "用户数据");
}
@Log(title = "用户管理", businessType = BusinessType.IMPORT)
@ -82,17 +78,16 @@ public class SysUserController extends BaseController
{
ExcelUtil<SysUser> util = new ExcelUtil<SysUser>(SysUser.class);
List<SysUser> userList = util.importExcel(file.getInputStream());
LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
String operName = loginUser.getUsername();
String operName = getUsername();
String message = userService.importUser(userList, updateSupport, operName);
return AjaxResult.success(message);
}
@GetMapping("/importTemplate")
public AjaxResult importTemplate()
@PostMapping("/importTemplate")
public void importTemplate(HttpServletResponse response)
{
ExcelUtil<SysUser> util = new ExcelUtil<SysUser>(SysUser.class);
return util.importTemplateExcel("用户数据");
util.importTemplateExcel(response, "用户数据");
}
/**
@ -102,6 +97,7 @@ public class SysUserController extends BaseController
@GetMapping(value = { "/", "/{userId}" })
public AjaxResult getInfo(@PathVariable(value = "userId", required = false) Long userId)
{
userService.checkUserDataScope(userId);
AjaxResult ajax = AjaxResult.success();
List<SysRole> roles = roleService.selectRoleAll();
ajax.put("roles", SysUser.isAdmin(userId) ? roles : roles.stream().filter(r -> !r.isAdmin()).collect(Collectors.toList()));
@ -137,7 +133,7 @@ public class SysUserController extends BaseController
{
return AjaxResult.error("新增用户'" + user.getUserName() + "'失败,邮箱账号已存在");
}
user.setCreateBy(SecurityUtils.getUsername());
user.setCreateBy(getUsername());
user.setPassword(SecurityUtils.encryptPassword(user.getPassword()));
return toAjax(userService.insertUser(user));
}
@ -161,7 +157,7 @@ public class SysUserController extends BaseController
{
return AjaxResult.error("修改用户'" + user.getUserName() + "'失败,邮箱账号已存在");
}
user.setUpdateBy(SecurityUtils.getUsername());
user.setUpdateBy(getUsername());
return toAjax(userService.updateUser(user));
}
@ -173,6 +169,10 @@ public class SysUserController extends BaseController
@DeleteMapping("/{userIds}")
public AjaxResult remove(@PathVariable Long[] userIds)
{
if (ArrayUtils.contains(userIds, getUserId()))
{
return error("当前用户不能删除");
}
return toAjax(userService.deleteUserByIds(userIds));
}
@ -186,7 +186,7 @@ public class SysUserController extends BaseController
{
userService.checkUserAllowed(user);
user.setPassword(SecurityUtils.encryptPassword(user.getPassword()));
user.setUpdateBy(SecurityUtils.getUsername());
user.setUpdateBy(getUsername());
return toAjax(userService.resetPwd(user));
}
@ -199,7 +199,34 @@ public class SysUserController extends BaseController
public AjaxResult changeStatus(@RequestBody SysUser user)
{
userService.checkUserAllowed(user);
user.setUpdateBy(SecurityUtils.getUsername());
user.setUpdateBy(getUsername());
return toAjax(userService.updateUserStatus(user));
}
/**
* 根据用户编号获取授权角色
*/
@PreAuthorize("@ss.hasPermi('system:user:query')")
@GetMapping("/authRole/{userId}")
public AjaxResult authRole(@PathVariable("userId") Long userId)
{
AjaxResult ajax = AjaxResult.success();
SysUser user = userService.selectUserById(userId);
List<SysRole> roles = roleService.selectRolesByUserId(userId);
ajax.put("user", user);
ajax.put("roles", SysUser.isAdmin(userId) ? roles : roles.stream().filter(r -> !r.isAdmin()).collect(Collectors.toList()));
return ajax;
}
/**
* 用户授权角色
*/
@PreAuthorize("@ss.hasPermi('system:user:edit')")
@Log(title = "用户管理", businessType = BusinessType.GRANT)
@PutMapping("/authRole")
public AjaxResult insertAuthRole(Long userId, Long[] roleIds)
{
userService.insertUserAuth(userId, roleIds);
return success();
}
}

View File

@ -9,6 +9,7 @@ import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.core.controller.BaseController;
@ -16,6 +17,7 @@ import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.StringUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiOperation;
@ -45,7 +47,7 @@ public class TestController extends BaseController
}
@ApiOperation("获取用户详细")
@ApiImplicitParam(name = "userId", value = "用户ID", required = true, dataType = "int", paramType = "path")
@ApiImplicitParam(name = "userId", value = "用户ID", required = true, dataType = "int", paramType = "path", dataTypeClass = Integer.class)
@GetMapping("/{userId}")
public AjaxResult getUser(@PathVariable Integer userId)
{
@ -55,57 +57,61 @@ public class TestController extends BaseController
}
else
{
return AjaxResult.error("用户不存在");
return error("用户不存在");
}
}
@ApiOperation("新增用户")
@ApiImplicitParam(name = "userEntity", value = "新增用户信息", dataType = "UserEntity")
@ApiImplicitParams({
@ApiImplicitParam(name = "userId", value = "用户id", dataType = "Integer", dataTypeClass = Integer.class),
@ApiImplicitParam(name = "username", value = "用户名称", dataType = "String", dataTypeClass = String.class),
@ApiImplicitParam(name = "password", value = "用户密码", dataType = "String", dataTypeClass = String.class),
@ApiImplicitParam(name = "mobile", value = "用户手机", dataType = "String", dataTypeClass = String.class)
})
@PostMapping("/save")
public AjaxResult save(UserEntity user)
{
if (StringUtils.isNull(user) || StringUtils.isNull(user.getUserId()))
{
return AjaxResult.error("用户ID不能为空");
return error("用户ID不能为空");
}
return AjaxResult.success(users.put(user.getUserId(), user));
}
@ApiOperation("更新用户")
@ApiImplicitParam(name = "userEntity", value = "新增用户信息", dataType = "UserEntity")
@PutMapping("/update")
public AjaxResult update(UserEntity user)
public AjaxResult update(@RequestBody UserEntity user)
{
if (StringUtils.isNull(user) || StringUtils.isNull(user.getUserId()))
{
return AjaxResult.error("用户ID不能为空");
return error("用户ID不能为空");
}
if (users.isEmpty() || !users.containsKey(user.getUserId()))
{
return AjaxResult.error("用户不存在");
return error("用户不存在");
}
users.remove(user.getUserId());
return AjaxResult.success(users.put(user.getUserId(), user));
}
@ApiOperation("删除用户信息")
@ApiImplicitParam(name = "userId", value = "用户ID", required = true, dataType = "int", paramType = "path")
@ApiImplicitParam(name = "userId", value = "用户ID", required = true, dataType = "int", paramType = "path", dataTypeClass = Integer.class)
@DeleteMapping("/{userId}")
public AjaxResult delete(@PathVariable Integer userId)
{
if (!users.isEmpty() && users.containsKey(userId))
{
users.remove(userId);
return AjaxResult.success();
return success();
}
else
{
return AjaxResult.error("用户不存在");
return error("用户不存在");
}
}
}
@ApiModel("用户实体")
@ApiModel(value = "UserEntity", description = "用户实体")
class UserEntity
{
@ApiModelProperty("用户ID")

View File

@ -8,6 +8,7 @@ import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import com.ruoyi.common.config.RuoYiConfig;
import io.swagger.annotations.ApiOperation;
import io.swagger.models.auth.In;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
@ -16,10 +17,10 @@ import springfox.documentation.service.ApiKey;
import springfox.documentation.service.AuthorizationScope;
import springfox.documentation.service.Contact;
import springfox.documentation.service.SecurityReference;
import springfox.documentation.service.SecurityScheme;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spi.service.contexts.SecurityContext;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
/**
* Swagger2的接口配置
@ -27,7 +28,6 @@ import springfox.documentation.swagger2.annotations.EnableSwagger2;
* @author ruoyi
*/
@Configuration
@EnableSwagger2
public class SwaggerConfig
{
/** 系统基础配置 */
@ -48,7 +48,7 @@ public class SwaggerConfig
@Bean
public Docket createRestApi()
{
return new Docket(DocumentationType.SWAGGER_2)
return new Docket(DocumentationType.OAS_30)
// 是否启用Swagger
.enable(enabled)
// 用来创建该API的基本信息展示在文档的页面中自定义展示的信息
@ -71,10 +71,10 @@ public class SwaggerConfig
/**
* 安全模式这里指定token通过Authorization头请求头传递
*/
private List<ApiKey> securitySchemes()
private List<SecurityScheme> securitySchemes()
{
List<ApiKey> apiKeyList = new ArrayList<ApiKey>();
apiKeyList.add(new ApiKey("Authorization", "Authorization", "header"));
List<SecurityScheme> apiKeyList = new ArrayList<SecurityScheme>();
apiKeyList.add(new ApiKey("Authorization", "Authorization", In.HEADER.toValue()));
return apiKeyList;
}
@ -87,7 +87,7 @@ public class SwaggerConfig
securityContexts.add(
SecurityContext.builder()
.securityReferences(defaultAuth())
.forPaths(PathSelectors.regex("^(?!auth).*$"))
.operationSelector(o -> o.requestMappingPattern().matches("/.*"))
.build());
return securityContexts;
}

View File

@ -43,8 +43,8 @@ spring:
allow:
url-pattern: /druid/*
# 控制台管理用户名和密码
login-username:
login-password:
login-username: ruoyi
login-password: 123456
filter:
stat:
enabled: true

View File

@ -3,7 +3,7 @@ ruoyi:
# 名称
name: RuoYi
# 版本
version: 3.4.0
version: 3.8.1
# 版权年份
copyrightYear: 2021
# 实例演示开关
@ -25,10 +25,13 @@ server:
tomcat:
# tomcat的URI编码
uri-encoding: UTF-8
# tomcat最大线程数,默认为200
max-threads: 800
# Tomcat启动初始化的线程数默认值25
min-spare-threads: 30
# 连接数满后的排队数,默认为100
accept-count: 1000
threads:
# tomcat最大线程数默认为200
max: 800
# Tomcat启动初始化的线程数默认值10
min-spare: 100
# 日志配置
logging:
@ -100,7 +103,6 @@ mybatis:
# PageHelper分页插件
pagehelper:
helperDialect: mysql
reasonable: true
supportMethodsArguments: true
params: count=countSql
@ -116,6 +118,6 @@ xss:
# 过滤开关
enabled: true
# 排除链接(多个用逗号分隔)
excludes: /system/notice/*
excludes: /system/notice
# 匹配链接
urlPatterns: /system/*,/monitor/*,/tool/*

View File

@ -19,6 +19,7 @@ user.password.not.valid=* 5-50个字符
user.email.not.valid=邮箱格式错误
user.mobile.phone.number.not.valid=手机号格式错误
user.login.success=登录成功
user.register.success=注册成功
user.notfound=请重新登录
user.forcelogout=管理员强制退出,请重新登录
user.unknown.error=未知错误,请重新登录

View File

@ -3,13 +3,18 @@
PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-config.dtd">
<configuration>
<settings>
<setting name="cacheEnabled" value="true" /> <!-- 全局映射器启用缓存 -->
<setting name="useGeneratedKeys" value="true" /> <!-- 允许 JDBC 支持自动生成主键 -->
<setting name="defaultExecutorType" value="REUSE" /> <!-- 配置默认的执行器 -->
<setting name="logImpl" value="SLF4J" /> <!-- 指定 MyBatis 所用日志的具体实现 -->
<!-- <setting name="mapUnderscoreToCamelCase" value="true"/> 驼峰式命名 -->
<!-- 全局参数 -->
<settings>
<!-- 使全局映射器启用或禁用缓存 -->
<setting name="cacheEnabled" value="true" />
<!-- 允许JDBC 支持自动生成主键 -->
<setting name="useGeneratedKeys" value="true" />
<!-- 配置默认的执行器.SIMPLE就是普通执行器;REUSE执行器会重用预处理语句(prepared statements);BATCH执行器将重用语句并执行批量更新 -->
<setting name="defaultExecutorType" value="SIMPLE" />
<!-- 指定 MyBatis 所用日志的具体实现 -->
<setting name="logImpl" value="SLF4J" />
<!-- 使用驼峰命名法转换字段 -->
<!-- <setting name="mapUnderscoreToCamelCase" value="true"/> -->
</settings>
</configuration>

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>ruoyi</artifactId>
<groupId>com.ruoyi</groupId>
<version>3.4.0</version>
<version>3.8.1</version>
</parent>
<modelVersion>4.0.0</modelVersion>
@ -43,8 +43,8 @@
<!-- 自定义验证注解 -->
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
</dependency>
<!--常用工具类 -->
@ -89,12 +89,18 @@
<artifactId>snakeyaml</artifactId>
</dependency>
<!--Token生成与解析-->
<!-- Token生成与解析-->
<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt</artifactId>
</dependency>
<!-- Jaxb -->
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
</dependency>
<!-- redis 缓存操作 -->
<dependency>
<groupId>org.springframework.boot</groupId>

View File

@ -5,6 +5,7 @@ import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import java.math.BigDecimal;
import com.ruoyi.common.utils.poi.ExcelHandlerAdapter;
/**
* 自定义导出Excel数据注解
@ -108,7 +109,17 @@ public @interface Excel
/**
* 导出字段对齐方式0默认1靠左2居中3靠右
*/
Align align() default Align.AUTO;
public Align align() default Align.AUTO;
/**
* 自定义数据处理器
*/
public Class<?> handler() default ExcelHandlerAdapter.class;
/**
* 自定义数据处理器参数
*/
public String[] args() default {};
public enum Align
{

View File

@ -14,5 +14,5 @@ import java.lang.annotation.Target;
@Retention(RetentionPolicy.RUNTIME)
public @interface Excels
{
Excel[] value();
public Excel[] value();
}

View File

@ -38,4 +38,9 @@ public @interface Log
* 是否保存请求的参数
*/
public boolean isSaveRequestData() default true;
/**
* 是否保存响应的参数
*/
public boolean isSaveResponseData() default true;
}

View File

@ -0,0 +1,40 @@
package com.ruoyi.common.annotation;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import com.ruoyi.common.constant.Constants;
import com.ruoyi.common.enums.LimitType;
/**
* 限流注解
*
* @author ruoyi
*/
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface RateLimiter
{
/**
* 限流key
*/
public String key() default Constants.RATE_LIMIT_KEY;
/**
* 限流时间,单位秒
*/
public int time() default 60;
/**
* 限流次数
*/
public int count() default 100;
/**
* 限流类型
*/
public LimitType limitType() default LimitType.DEFAULT;
}

View File

@ -19,5 +19,13 @@ import java.lang.annotation.Target;
@Documented
public @interface RepeatSubmit
{
/**
* 间隔时间(ms),小于此时间视为重复提交
*/
public int interval() default 5000;
/**
* 提示消息
*/
public String message() default "不允许重复提交,请稍候再试";
}

View File

@ -30,6 +30,9 @@ public class RuoYiConfig
/** 获取地址开关 */
private static boolean addressEnabled;
/** 验证码类型 */
private static String captchaType;
public String getName()
{
return name;
@ -90,6 +93,22 @@ public class RuoYiConfig
RuoYiConfig.addressEnabled = addressEnabled;
}
public static String getCaptchaType() {
return captchaType;
}
public void setCaptchaType(String captchaType) {
RuoYiConfig.captchaType = captchaType;
}
/**
* 获取导入上传路径
*/
public static String getImportPath()
{
return getProfile() + "/import";
}
/**
* 获取头像上传路径
*/

View File

@ -1,5 +1,7 @@
package com.ruoyi.common.constant;
import io.jsonwebtoken.Claims;
/**
* 通用常量信息
*
@ -47,6 +49,11 @@ public class Constants
*/
public static final String LOGOUT = "Logout";
/**
* 注册
*/
public static final String REGISTER = "Register";
/**
* 登录失败
*/
@ -61,12 +68,17 @@ public class Constants
* 登录用户 redis key
*/
public static final String LOGIN_TOKEN_KEY = "login_tokens:";
/**
* 防重提交 redis key
*/
public static final String REPEAT_SUBMIT_KEY = "repeat_submit:";
/**
* 限流 redis key
*/
public static final String RATE_LIMIT_KEY = "rate_limit:";
/**
* 验证码有效期(分钟)
*/
@ -95,7 +107,7 @@ public class Constants
/**
* 用户名称
*/
public static final String JWT_USERNAME = "sub";
public static final String JWT_USERNAME = Claims.SUBJECT;
/**
* 用户头像
@ -126,4 +138,20 @@ public class Constants
* 资源映射路径 前缀
*/
public static final String RESOURCE_PREFIX = "/profile";
}
/**
* RMI 远程方法调用
*/
public static final String LOOKUP_RMI = "rmi://";
/**
* LDAP 远程方法调用
*/
public static final String LOOKUP_LDAP = "ldap://";
/**
* 定时任务违规的字符
*/
public static final String[] JOB_ERROR_STR = { "java.net.URL", "javax.naming.InitialContext", "org.yaml.snakeyaml",
"org.springframework.jndi" };
}

View File

@ -53,11 +53,26 @@ public class UserConstants
/** Layout组件标识 */
public final static String LAYOUT = "Layout";
/** ParentView组件标识 */
public final static String PARENT_VIEW = "ParentView";
/** InnerLink组件标识 */
public final static String INNER_LINK = "InnerLink";
/** 校验返回结果码 */
public final static String UNIQUE = "0";
public final static String NOT_UNIQUE = "1";
/**
* 用户名长度限制
*/
public static final int USERNAME_MIN_LENGTH = 2;
public static final int USERNAME_MAX_LENGTH = 20;
/**
* 密码长度限制
*/
public static final int PASSWORD_MIN_LENGTH = 5;
public static final int PASSWORD_MAX_LENGTH = 20;
}

View File

@ -11,10 +11,13 @@ import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.ruoyi.common.constant.HttpStatus;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.model.LoginUser;
import com.ruoyi.common.core.page.PageDomain;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.core.page.TableSupport;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.PageUtils;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.sql.SqlUtil;
@ -25,7 +28,7 @@ import com.ruoyi.common.utils.sql.SqlUtil;
*/
public class BaseController
{
protected final Logger logger = LoggerFactory.getLogger(BaseController.class);
protected final Logger logger = LoggerFactory.getLogger(this.getClass());
/**
* 将前台传递过来的日期格式的字符串自动转化为Date类型
@ -48,14 +51,20 @@ public class BaseController
* 设置请求分页数据
*/
protected void startPage()
{
PageUtils.startPage();
}
/**
* 设置请求排序数据
*/
protected void startOrderBy()
{
PageDomain pageDomain = TableSupport.buildPageRequest();
Integer pageNum = pageDomain.getPageNum();
Integer pageSize = pageDomain.getPageSize();
if (StringUtils.isNotNull(pageNum) && StringUtils.isNotNull(pageSize))
if (StringUtils.isNotEmpty(pageDomain.getOrderBy()))
{
String orderBy = SqlUtil.escapeOrderBySql(pageDomain.getOrderBy());
PageHelper.startPage(pageNum, pageSize, orderBy);
PageHelper.orderBy(orderBy);
}
}
@ -73,6 +82,38 @@ public class BaseController
return rspData;
}
/**
* 返回成功
*/
public AjaxResult success()
{
return AjaxResult.success();
}
/**
* 返回失败消息
*/
public AjaxResult error()
{
return AjaxResult.error();
}
/**
* 返回成功消息
*/
public AjaxResult success(String message)
{
return AjaxResult.success(message);
}
/**
* 返回失败消息
*/
public AjaxResult error(String message)
{
return AjaxResult.error(message);
}
/**
* 响应返回结果
*
@ -84,6 +125,17 @@ public class BaseController
return rows > 0 ? AjaxResult.success() : AjaxResult.error();
}
/**
* 响应返回结果
*
* @param result 结果
* @return 操作结果
*/
protected AjaxResult toAjax(boolean result)
{
return result ? success() : error();
}
/**
* 页面跳转
*/
@ -91,4 +143,36 @@ public class BaseController
{
return StringUtils.format("redirect:{}", url);
}
/**
* 获取用户缓存信息
*/
public LoginUser getLoginUser()
{
return SecurityUtils.getLoginUser();
}
/**
* 获取登录用户id
*/
public Long getUserId()
{
return getLoginUser().getUserId();
}
/**
* 获取登录部门id
*/
public Long getDeptId()
{
return getLoginUser().getDeptId();
}
/**
* 获取登录用户名
*/
public String getUsername()
{
return getLoginUser().getUsername();
}
}

View File

@ -145,4 +145,18 @@ public class AjaxResult extends HashMap<String, Object>
{
return new AjaxResult(code, msg, null);
}
/**
* 方便链式调用
*
* @param key 键
* @param value 值
* @return 数据对象
*/
@Override
public AjaxResult put(String key, Object value)
{
super.put(key, value);
return this;
}
}

View File

@ -38,6 +38,9 @@ public class SysMenu extends BaseEntity
/** 组件路径 */
private String component;
/** 路由参数 */
private String query;
/** 是否为外链0是 1否 */
private String isFrame;
@ -137,6 +140,16 @@ public class SysMenu extends BaseEntity
this.component = component;
}
public String getQuery()
{
return query;
}
public void setQuery(String query)
{
this.query = query;
}
public String getIsFrame()
{
return isFrame;

View File

@ -33,8 +33,8 @@ public class SysRole extends BaseEntity
@Excel(name = "角色排序")
private String roleSort;
/** 数据范围1所有数据权限2自定义数据权限3本部门数据权限4本部门及以下数据权限 */
@Excel(name = "数据范围", readConverterExp = "1=所有数据权限,2=自定义数据权限,3=本部门数据权限,4=本部门及以下数据权限")
/** 数据范围1所有数据权限2自定义数据权限3本部门数据权限4本部门及以下数据权限5仅本人数据权限 */
@Excel(name = "数据范围", readConverterExp = "1=所有数据权限,2=自定义数据权限,3=本部门数据权限,4=本部门及以下数据权限,5=仅本人数据权限")
private String dataScope;
/** 菜单树选择项是否关联显示( 0父子不互相关联显示 1父子互相关联显示 */

View File

@ -2,9 +2,7 @@ package com.ruoyi.common.core.domain.entity;
import java.util.Date;
import java.util.List;
import javax.validation.constraints.Email;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Size;
import javax.validation.constraints.*;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.fasterxml.jackson.annotation.JsonIgnore;
@ -14,6 +12,7 @@ import com.ruoyi.common.annotation.Excel.ColumnType;
import com.ruoyi.common.annotation.Excel.Type;
import com.ruoyi.common.annotation.Excels;
import com.ruoyi.common.core.domain.BaseEntity;
import com.ruoyi.common.xss.Xss;
/**
* 用户对象 sys_user
@ -92,6 +91,9 @@ public class SysUser extends BaseEntity
/** 岗位组 */
private Long[] postIds;
/** 角色ID */
private Long roleId;
public SysUser()
{
@ -132,6 +134,7 @@ public class SysUser extends BaseEntity
this.deptId = deptId;
}
@Xss(message = "用户昵称不能包含脚本字符")
@Size(min = 0, max = 30, message = "用户昵称长度不能超过30个字符")
public String getNickName()
{
@ -143,6 +146,7 @@ public class SysUser extends BaseEntity
this.nickName = nickName;
}
@Xss(message = "用户账号不能包含脚本字符")
@NotBlank(message = "用户账号不能为空")
@Size(min = 0, max = 30, message = "用户账号长度不能超过30个字符")
public String getUserName()
@ -198,7 +202,7 @@ public class SysUser extends BaseEntity
this.avatar = avatar;
}
@JsonIgnore
@JsonIgnore
@JsonProperty
public String getPassword()
{
@ -300,6 +304,16 @@ public class SysUser extends BaseEntity
this.postIds = postIds;
}
public Long getRoleId()
{
return roleId;
}
public void setRoleId(Long roleId)
{
this.roleId = roleId;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)

View File

@ -4,7 +4,7 @@ import java.util.Collection;
import java.util.Set;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.alibaba.fastjson.annotation.JSONField;
import com.ruoyi.common.core.domain.entity.SysUser;
/**
@ -16,6 +16,16 @@ public class LoginUser implements UserDetails
{
private static final long serialVersionUID = 1L;
/**
* 用户ID
*/
private Long userId;
/**
* 部门ID
*/
private Long deptId;
/**
* 用户唯一标识
*/
@ -61,6 +71,26 @@ public class LoginUser implements UserDetails
*/
private SysUser user;
public Long getUserId()
{
return userId;
}
public void setUserId(Long userId)
{
this.userId = userId;
}
public Long getDeptId()
{
return deptId;
}
public void setDeptId(Long deptId)
{
this.deptId = deptId;
}
public String getToken()
{
return token;
@ -81,7 +111,15 @@ public class LoginUser implements UserDetails
this.permissions = permissions;
}
@JsonIgnore
public LoginUser(Long userId, Long deptId, SysUser user, Set<String> permissions)
{
this.userId = userId;
this.deptId = deptId;
this.user = user;
this.permissions = permissions;
}
@JSONField(serialize = false)
@Override
public String getPassword()
{
@ -97,7 +135,7 @@ public class LoginUser implements UserDetails
/**
* 账户是否未过期,过期无法验证
*/
@JsonIgnore
@JSONField(serialize = false)
@Override
public boolean isAccountNonExpired()
{
@ -109,7 +147,7 @@ public class LoginUser implements UserDetails
*
* @return
*/
@JsonIgnore
@JSONField(serialize = false)
@Override
public boolean isAccountNonLocked()
{
@ -121,7 +159,7 @@ public class LoginUser implements UserDetails
*
* @return
*/
@JsonIgnore
@JSONField(serialize = false)
@Override
public boolean isCredentialsNonExpired()
{
@ -133,7 +171,7 @@ public class LoginUser implements UserDetails
*
* @return
*/
@JsonIgnore
@JSONField(serialize = false)
@Override
public boolean isEnabled()
{

View File

@ -0,0 +1,11 @@
package com.ruoyi.common.core.domain.model;
/**
* 用户注册对象
*
* @author ruoyi
*/
public class RegisterBody extends LoginBody
{
}

View File

@ -1,72 +1,101 @@
package com.ruoyi.common.core.page;
import com.ruoyi.common.utils.StringUtils;
/**
* 分页数据
*
* @author ruoyi
*/
public class PageDomain
{
/** 当前记录起始索引 */
private Integer pageNum;
/** 每页显示记录数 */
private Integer pageSize;
/** 排序列 */
private String orderByColumn;
/** 排序的方向desc或者asc */
private String isAsc = "asc";
public String getOrderBy()
{
if (StringUtils.isEmpty(orderByColumn))
{
return "";
}
return StringUtils.toUnderScoreCase(orderByColumn) + " " + isAsc;
}
public Integer getPageNum()
{
return pageNum;
}
public void setPageNum(Integer pageNum)
{
this.pageNum = pageNum;
}
public Integer getPageSize()
{
return pageSize;
}
public void setPageSize(Integer pageSize)
{
this.pageSize = pageSize;
}
public String getOrderByColumn()
{
return orderByColumn;
}
public void setOrderByColumn(String orderByColumn)
{
this.orderByColumn = orderByColumn;
}
public String getIsAsc()
{
return isAsc;
}
public void setIsAsc(String isAsc)
{
this.isAsc = isAsc;
}
}
package com.ruoyi.common.core.page;
import com.ruoyi.common.utils.StringUtils;
/**
* 分页数据
*
* @author ruoyi
*/
public class PageDomain
{
/** 当前记录起始索引 */
private Integer pageNum;
/** 每页显示记录数 */
private Integer pageSize;
/** 排序列 */
private String orderByColumn;
/** 排序的方向desc或者asc */
private String isAsc = "asc";
/** 分页参数合理化 */
private Boolean reasonable = true;
public String getOrderBy()
{
if (StringUtils.isEmpty(orderByColumn))
{
return "";
}
return StringUtils.toUnderScoreCase(orderByColumn) + " " + isAsc;
}
public Integer getPageNum()
{
return pageNum;
}
public void setPageNum(Integer pageNum)
{
this.pageNum = pageNum;
}
public Integer getPageSize()
{
return pageSize;
}
public void setPageSize(Integer pageSize)
{
this.pageSize = pageSize;
}
public String getOrderByColumn()
{
return orderByColumn;
}
public void setOrderByColumn(String orderByColumn)
{
this.orderByColumn = orderByColumn;
}
public String getIsAsc()
{
return isAsc;
}
public void setIsAsc(String isAsc)
{
if (StringUtils.isNotEmpty(isAsc))
{
// 兼容前端排序类型
if ("ascending".equals(isAsc))
{
isAsc = "asc";
}
else if ("descending".equals(isAsc))
{
isAsc = "desc";
}
this.isAsc = isAsc;
}
}
public Boolean getReasonable()
{
if (StringUtils.isNull(reasonable))
{
return Boolean.TRUE;
}
return reasonable;
}
public void setReasonable(Boolean reasonable)
{
this.reasonable = reasonable;
}
}

View File

@ -29,6 +29,11 @@ public class TableSupport
*/
public static final String IS_ASC = "isAsc";
/**
* 分页参数合理化
*/
public static final String REASONABLE = "reasonable";
/**
* 封装分页对象
*/
@ -39,6 +44,7 @@ public class TableSupport
pageDomain.setPageSize(ServletUtils.getParameterToInt(PAGE_SIZE));
pageDomain.setOrderByColumn(ServletUtils.getParameter(ORDER_BY_COLUMN));
pageDomain.setIsAsc(ServletUtils.getParameter(IS_ASC));
pageDomain.setReasonable(ServletUtils.getParameterToBool(REASONABLE));
return pageDomain;
}

View File

@ -209,6 +209,18 @@ public class RedisCache
return opsForHash.get(key, hKey);
}
/**
* 删除Hash中的数据
*
* @param key
* @param mapkey
*/
public void delCacheMapValue(final String key, final String hkey)
{
HashOperations hashOperations = redisTemplate.opsForHash();
hashOperations.delete(key, hkey);
}
/**
* 获取多个Hash中的数据
*

View File

@ -7,10 +7,11 @@ import java.nio.charset.Charset;
import java.text.NumberFormat;
import java.util.Set;
import com.ruoyi.common.utils.StringUtils;
import org.apache.commons.lang3.ArrayUtils;
/**
* 类型转换器
*
*
* @author ruoyi
*/
public class Convert
@ -19,7 +20,7 @@ public class Convert
* 转换为字符串<br>
* 如果给定的值为null或者转换失败返回默认值<br>
* 转换失败不会报错
*
*
* @param value 被转换的值
* @param defaultValue 转换错误时的默认值
* @return 结果
@ -41,7 +42,7 @@ public class Convert
* 转换为字符串<br>
* 如果给定的值为<code>null</code>,或者转换失败,返回默认值<code>null</code><br>
* 转换失败不会报错
*
*
* @param value 被转换的值
* @return 结果
*/
@ -54,7 +55,7 @@ public class Convert
* 转换为字符<br>
* 如果给定的值为null或者转换失败返回默认值<br>
* 转换失败不会报错
*
*
* @param value 被转换的值
* @param defaultValue 转换错误时的默认值
* @return 结果
@ -78,7 +79,7 @@ public class Convert
* 转换为字符<br>
* 如果给定的值为<code>null</code>,或者转换失败,返回默认值<code>null</code><br>
* 转换失败不会报错
*
*
* @param value 被转换的值
* @return 结果
*/
@ -91,7 +92,7 @@ public class Convert
* 转换为byte<br>
* 如果给定的值为<code>null</code>,或者转换失败,返回默认值<br>
* 转换失败不会报错
*
*
* @param value 被转换的值
* @param defaultValue 转换错误时的默认值
* @return 结果
@ -129,7 +130,7 @@ public class Convert
* 转换为byte<br>
* 如果给定的值为<code>null</code>,或者转换失败,返回默认值<code>null</code><br>
* 转换失败不会报错
*
*
* @param value 被转换的值
* @return 结果
*/
@ -142,7 +143,7 @@ public class Convert
* 转换为Short<br>
* 如果给定的值为<code>null</code>,或者转换失败,返回默认值<br>
* 转换失败不会报错
*
*
* @param value 被转换的值
* @param defaultValue 转换错误时的默认值
* @return 结果
@ -180,7 +181,7 @@ public class Convert
* 转换为Short<br>
* 如果给定的值为<code>null</code>,或者转换失败,返回默认值<code>null</code><br>
* 转换失败不会报错
*
*
* @param value 被转换的值
* @return 结果
*/
@ -193,7 +194,7 @@ public class Convert
* 转换为Number<br>
* 如果给定的值为空,或者转换失败,返回默认值<br>
* 转换失败不会报错
*
*
* @param value 被转换的值
* @param defaultValue 转换错误时的默认值
* @return 结果
@ -227,7 +228,7 @@ public class Convert
* 转换为Number<br>
* 如果给定的值为空,或者转换失败,返回默认值<code>null</code><br>
* 转换失败不会报错
*
*
* @param value 被转换的值
* @return 结果
*/
@ -240,7 +241,7 @@ public class Convert
* 转换为int<br>
* 如果给定的值为空,或者转换失败,返回默认值<br>
* 转换失败不会报错
*
*
* @param value 被转换的值
* @param defaultValue 转换错误时的默认值
* @return 结果
@ -278,7 +279,7 @@ public class Convert
* 转换为int<br>
* 如果给定的值为<code>null</code>,或者转换失败,返回默认值<code>null</code><br>
* 转换失败不会报错
*
*
* @param value 被转换的值
* @return 结果
*/
@ -289,7 +290,7 @@ public class Convert
/**
* 转换为Integer数组<br>
*
*
* @param str 被转换的值
* @return 结果
*/
@ -300,7 +301,7 @@ public class Convert
/**
* 转换为Long数组<br>
*
*
* @param str 被转换的值
* @return 结果
*/
@ -311,7 +312,7 @@ public class Convert
/**
* 转换为Integer数组<br>
*
*
* @param split 分隔符
* @param split 被转换的值
* @return 结果
@ -334,7 +335,7 @@ public class Convert
/**
* 转换为Long数组<br>
*
*
* @param split 分隔符
* @param str 被转换的值
* @return 结果
@ -357,7 +358,7 @@ public class Convert
/**
* 转换为String数组<br>
*
*
* @param str 被转换的值
* @return 结果
*/
@ -368,7 +369,7 @@ public class Convert
/**
* 转换为String数组<br>
*
*
* @param split 分隔符
* @param split 被转换的值
* @return 结果
@ -382,7 +383,7 @@ public class Convert
* 转换为long<br>
* 如果给定的值为空,或者转换失败,返回默认值<br>
* 转换失败不会报错
*
*
* @param value 被转换的值
* @param defaultValue 转换错误时的默认值
* @return 结果
@ -421,7 +422,7 @@ public class Convert
* 转换为long<br>
* 如果给定的值为<code>null</code>,或者转换失败,返回默认值<code>null</code><br>
* 转换失败不会报错
*
*
* @param value 被转换的值
* @return 结果
*/
@ -434,7 +435,7 @@ public class Convert
* 转换为double<br>
* 如果给定的值为空,或者转换失败,返回默认值<br>
* 转换失败不会报错
*
*
* @param value 被转换的值
* @param defaultValue 转换错误时的默认值
* @return 结果
@ -473,7 +474,7 @@ public class Convert
* 转换为double<br>
* 如果给定的值为空,或者转换失败,返回默认值<code>null</code><br>
* 转换失败不会报错
*
*
* @param value 被转换的值
* @return 结果
*/
@ -486,7 +487,7 @@ public class Convert
* 转换为Float<br>
* 如果给定的值为空,或者转换失败,返回默认值<br>
* 转换失败不会报错
*
*
* @param value 被转换的值
* @param defaultValue 转换错误时的默认值
* @return 结果
@ -524,7 +525,7 @@ public class Convert
* 转换为Float<br>
* 如果给定的值为空,或者转换失败,返回默认值<code>null</code><br>
* 转换失败不会报错
*
*
* @param value 被转换的值
* @return 结果
*/
@ -537,7 +538,7 @@ public class Convert
* 转换为boolean<br>
* String支持的值为true、false、yes、ok、no1,0 如果给定的值为空,或者转换失败,返回默认值<br>
* 转换失败不会报错
*
*
* @param value 被转换的值
* @param defaultValue 转换错误时的默认值
* @return 结果
@ -583,7 +584,7 @@ public class Convert
* 转换为boolean<br>
* 如果给定的值为空,或者转换失败,返回默认值<code>null</code><br>
* 转换失败不会报错
*
*
* @param value 被转换的值
* @return 结果
*/
@ -595,7 +596,7 @@ public class Convert
/**
* 转换为Enum对象<br>
* 如果给定的值为空,或者转换失败,返回默认值<br>
*
*
* @param clazz Enum的Class
* @param value 值
* @param defaultValue 默认值
@ -631,7 +632,7 @@ public class Convert
/**
* 转换为Enum对象<br>
* 如果给定的值为空,或者转换失败,返回默认值<code>null</code><br>
*
*
* @param clazz Enum的Class
* @param value 值
* @return Enum
@ -645,7 +646,7 @@ public class Convert
* 转换为BigInteger<br>
* 如果给定的值为空,或者转换失败,返回默认值<br>
* 转换失败不会报错
*
*
* @param value 被转换的值
* @param defaultValue 转换错误时的默认值
* @return 结果
@ -683,7 +684,7 @@ public class Convert
* 转换为BigInteger<br>
* 如果给定的值为空,或者转换失败,返回默认值<code>null</code><br>
* 转换失败不会报错
*
*
* @param value 被转换的值
* @return 结果
*/
@ -696,7 +697,7 @@ public class Convert
* 转换为BigDecimal<br>
* 如果给定的值为空,或者转换失败,返回默认值<br>
* 转换失败不会报错
*
*
* @param value 被转换的值
* @param defaultValue 转换错误时的默认值
* @return 结果
@ -742,7 +743,7 @@ public class Convert
* 转换为BigDecimal<br>
* 如果给定的值为空,或者转换失败,返回默认值<br>
* 转换失败不会报错
*
*
* @param value 被转换的值
* @return 结果
*/
@ -754,7 +755,7 @@ public class Convert
/**
* 将对象转为字符串<br>
* 1、Byte数组和ByteBuffer会被转换为对应字符串的数组 2、对象数组会调用Arrays.toString方法
*
*
* @param obj 对象
* @return 字符串
*/
@ -766,7 +767,7 @@ public class Convert
/**
* 将对象转为字符串<br>
* 1、Byte数组和ByteBuffer会被转换为对应字符串的数组 2、对象数组会调用Arrays.toString方法
*
*
* @param obj 对象
* @param charsetName 字符集
* @return 字符串
@ -779,7 +780,7 @@ public class Convert
/**
* 将对象转为字符串<br>
* 1、Byte数组和ByteBuffer会被转换为对应字符串的数组 2、对象数组会调用Arrays.toString方法
*
*
* @param obj 对象
* @param charset 字符集
* @return 字符串
@ -795,9 +796,14 @@ public class Convert
{
return (String) obj;
}
else if (obj instanceof byte[] || obj instanceof Byte[])
else if (obj instanceof byte[])
{
return str((Byte[]) obj, charset);
return str((byte[]) obj, charset);
}
else if (obj instanceof Byte[])
{
byte[] bytes = ArrayUtils.toPrimitive((Byte[]) obj);
return str(bytes, charset);
}
else if (obj instanceof ByteBuffer)
{
@ -808,7 +814,7 @@ public class Convert
/**
* 将byte数组转为字符串
*
*
* @param bytes byte数组
* @param charset 字符集
* @return 字符串
@ -820,7 +826,7 @@ public class Convert
/**
* 解码字节码
*
*
* @param data 字符串
* @param charset 字符集,如果此字段为空,则解码的结果取决于平台
* @return 解码后的字符串
@ -841,7 +847,7 @@ public class Convert
/**
* 将编码的byteBuffer数据转换为字符串
*
*
* @param data 数据
* @param charset 字符集,如果为空使用当前系统字符集
* @return 字符串
@ -858,7 +864,7 @@ public class Convert
/**
* 将编码的byteBuffer数据转换为字符串
*
*
* @param data 数据
* @param charset 字符集,如果为空使用当前系统字符集
* @return 字符串
@ -875,7 +881,7 @@ public class Convert
// ----------------------------------------------------------------------- 全角半角转换
/**
* 半角转全角
*
*
* @param input String.
* @return 全角字符串.
*/
@ -886,7 +892,7 @@ public class Convert
/**
* 半角转全角
*
*
* @param input String
* @param notConvertSet 不替换的字符集合
* @return 全角字符串.
@ -917,7 +923,7 @@ public class Convert
/**
* 全角转半角
*
*
* @param input String.
* @return 半角字符串
*/
@ -928,7 +934,7 @@ public class Convert
/**
* 替换全角为半角
*
*
* @param text 文本
* @param notConvertSet 不替换的字符集合
* @return 替换后的字符
@ -960,7 +966,7 @@ public class Convert
/**
* 数字金额大写转换 先写个完整的然后将如零拾替换成零
*
*
* @param n 数字
* @return 中文大写数字
*/

View File

@ -0,0 +1,20 @@
package com.ruoyi.common.enums;
/**
* 限流类型
*
* @author ruoyi
*/
public enum LimitType
{
/**
* 默认策略全局限流
*/
DEFAULT,
/**
* 根据请求者IP进行限流
*/
IP
}

View File

@ -1,43 +0,0 @@
package com.ruoyi.common.exception;
/**
* 自定义异常
*
* @author ruoyi
*/
public class CustomException extends RuntimeException
{
private static final long serialVersionUID = 1L;
private Integer code;
private String message;
public CustomException(String message)
{
this.message = message;
}
public CustomException(String message, Integer code)
{
this.message = message;
this.code = code;
}
public CustomException(String message, Throwable e)
{
super(message, e);
this.message = message;
}
@Override
public String getMessage()
{
return message;
}
public Integer getCode()
{
return code;
}
}

View File

@ -0,0 +1,58 @@
package com.ruoyi.common.exception;
/**
* 全局异常
*
* @author ruoyi
*/
public class GlobalException extends RuntimeException
{
private static final long serialVersionUID = 1L;
/**
* 错误提示
*/
private String message;
/**
* 错误明细,内部调试错误
*
* 和 {@link CommonResult#getDetailMessage()} 一致的设计
*/
private String detailMessage;
/**
* 空构造方法,避免反序列化问题
*/
public GlobalException()
{
}
public GlobalException(String message)
{
this.message = message;
}
public String getDetailMessage()
{
return detailMessage;
}
public GlobalException setDetailMessage(String detailMessage)
{
this.detailMessage = detailMessage;
return this;
}
public String getMessage()
{
return message;
}
public GlobalException setMessage(String message)
{
this.message = message;
return this;
}
}

View File

@ -0,0 +1,73 @@
package com.ruoyi.common.exception;
/**
* 业务异常
*
* @author ruoyi
*/
public final class ServiceException extends RuntimeException
{
private static final long serialVersionUID = 1L;
/**
* 错误码
*/
private Integer code;
/**
* 错误提示
*/
private String message;
/**
* 错误明细,内部调试错误
*
* 和 {@link CommonResult#getDetailMessage()} 一致的设计
*/
private String detailMessage;
/**
* 空构造方法,避免反序列化问题
*/
public ServiceException()
{
}
public ServiceException(String message)
{
this.message = message;
}
public ServiceException(String message, Integer code)
{
this.message = message;
this.code = code;
}
public String getDetailMessage()
{
return detailMessage;
}
public String getMessage()
{
return message;
}
public Integer getCode()
{
return code;
}
public ServiceException setMessage(String message)
{
this.message = message;
return this;
}
public ServiceException setDetailMessage(String detailMessage)
{
this.detailMessage = detailMessage;
return this;
}
}

View File

@ -1,4 +1,4 @@
package com.ruoyi.common.exception;
package com.ruoyi.common.exception.base;
import com.ruoyi.common.utils.MessageUtils;
import com.ruoyi.common.utils.StringUtils;

View File

@ -1,6 +1,6 @@
package com.ruoyi.common.exception.file;
import com.ruoyi.common.exception.BaseException;
import com.ruoyi.common.exception.base.BaseException;
/**
* 文件信息异常类

View File

@ -68,4 +68,14 @@ public class InvalidExtensionException extends FileUploadException
super(allowedExtension, extension, filename);
}
}
public static class InvalidVideoExtensionException extends InvalidExtensionException
{
private static final long serialVersionUID = 1L;
public InvalidVideoExtensionException(String[] allowedExtension, String extension, String filename)
{
super(allowedExtension, extension, filename);
}
}
}

View File

@ -1,6 +1,6 @@
package com.ruoyi.common.exception.user;
import com.ruoyi.common.exception.BaseException;
import com.ruoyi.common.exception.base.BaseException;
/**
* 用户信息异常类

View File

@ -30,7 +30,7 @@ public class RepeatableFilter implements Filter
{
ServletRequest requestWrapper = null;
if (request instanceof HttpServletRequest
&& StringUtils.equalsAnyIgnoreCase(request.getContentType(), MediaType.APPLICATION_JSON_VALUE))
&& StringUtils.startsWithIgnoreCase(request.getContentType(), MediaType.APPLICATION_JSON_VALUE))
{
requestWrapper = new RepeatedlyRequestWrapper((HttpServletRequest) request, response);
}

View File

@ -38,18 +38,21 @@ public class RepeatedlyRequestWrapper extends HttpServletRequestWrapper
@Override
public ServletInputStream getInputStream() throws IOException
{
final ByteArrayInputStream bais = new ByteArrayInputStream(body);
return new ServletInputStream()
{
@Override
public int read() throws IOException
{
return bais.read();
}
@Override
public int available() throws IOException
{
return body.length;
}
@Override
public boolean isFinished()
{

View File

@ -3,8 +3,6 @@ package com.ruoyi.common.filter;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
@ -27,16 +25,10 @@ public class XssFilter implements Filter
*/
public List<String> excludes = new ArrayList<>();
/**
* xss过滤开关
*/
public boolean enabled = false;
@Override
public void init(FilterConfig filterConfig) throws ServletException
{
String tempExcludes = filterConfig.getInitParameter("excludes");
String tempEnabled = filterConfig.getInitParameter("enabled");
if (StringUtils.isNotEmpty(tempExcludes))
{
String[] url = tempExcludes.split(",");
@ -45,10 +37,6 @@ public class XssFilter implements Filter
excludes.add(url[i]);
}
}
if (StringUtils.isNotEmpty(tempEnabled))
{
enabled = Boolean.valueOf(tempEnabled);
}
}
@Override
@ -68,25 +56,14 @@ public class XssFilter implements Filter
private boolean handleExcludeURL(HttpServletRequest request, HttpServletResponse response)
{
if (!enabled)
String url = request.getServletPath();
String method = request.getMethod();
// GET DELETE 不过滤
if (method == null || method.matches("GET") || method.matches("DELETE"))
{
return true;
}
if (excludes == null || excludes.isEmpty())
{
return false;
}
String url = request.getServletPath();
for (String pattern : excludes)
{
Pattern p = Pattern.compile("^" + pattern);
Matcher m = p.matcher(url);
if (m.find())
{
return true;
}
}
return false;
return StringUtils.matches(url, excludes);
}
@Override

View File

@ -63,7 +63,8 @@ public class XssHttpServletRequestWrapper extends HttpServletRequestWrapper
// xss过滤
json = EscapeUtil.clean(json).trim();
final ByteArrayInputStream bis = new ByteArrayInputStream(json.getBytes("utf-8"));
byte[] jsonBytes = json.getBytes("utf-8");
final ByteArrayInputStream bis = new ByteArrayInputStream(jsonBytes);
return new ServletInputStream()
{
@Override
@ -78,6 +79,12 @@ public class XssHttpServletRequestWrapper extends HttpServletRequestWrapper
return true;
}
@Override
public int available() throws IOException
{
return jsonBytes.length;
}
@Override
public void setReadListener(ReadListener readListener)
{
@ -99,6 +106,6 @@ public class XssHttpServletRequestWrapper extends HttpServletRequestWrapper
public boolean isJsonRequest()
{
String header = super.getHeader(HttpHeaders.CONTENT_TYPE);
return MediaType.APPLICATION_JSON_VALUE.equalsIgnoreCase(header);
return StringUtils.startsWithIgnoreCase(header, MediaType.APPLICATION_JSON_VALUE);
}
}

View File

@ -1,114 +1,114 @@
package com.ruoyi.common.utils;
import java.math.BigDecimal;
import java.math.RoundingMode;
/**
* 精确的浮点数运算
*
* @author ruoyi
*/
public class Arith
{
/** 默认除法运算精度 */
private static final int DEF_DIV_SCALE = 10;
/** 这个类不能实例化 */
private Arith()
{
}
/**
* 提供精确的加法运算。
* @param v1 被加数
* @param v2 加数
* @return 两个参数的和
*/
public static double add(double v1, double v2)
{
BigDecimal b1 = new BigDecimal(Double.toString(v1));
BigDecimal b2 = new BigDecimal(Double.toString(v2));
return b1.add(b2).doubleValue();
}
/**
* 提供精确的减法运算。
* @param v1 被减数
* @param v2 减数
* @return 两个参数的差
*/
public static double sub(double v1, double v2)
{
BigDecimal b1 = new BigDecimal(Double.toString(v1));
BigDecimal b2 = new BigDecimal(Double.toString(v2));
return b1.subtract(b2).doubleValue();
}
/**
* 提供精确的乘法运算。
* @param v1 被乘数
* @param v2 乘数
* @return 两个参数的积
*/
public static double mul(double v1, double v2)
{
BigDecimal b1 = new BigDecimal(Double.toString(v1));
BigDecimal b2 = new BigDecimal(Double.toString(v2));
return b1.multiply(b2).doubleValue();
}
/**
* 提供(相对)精确的除法运算,当发生除不尽的情况时,精确到
* 小数点以后10位以后的数字四舍五入。
* @param v1 被除数
* @param v2 除数
* @return 两个参数的商
*/
public static double div(double v1, double v2)
{
return div(v1, v2, DEF_DIV_SCALE);
}
/**
* 提供相对精确的除法运算。当发生除不尽的情况时由scale参数指
* 定精度,以后的数字四舍五入。
* @param v1 被除数
* @param v2 除数
* @param scale 表示表示需要精确到小数点以后几位。
* @return 两个参数的商
*/
public static double div(double v1, double v2, int scale)
{
if (scale < 0)
{
throw new IllegalArgumentException(
"The scale must be a positive integer or zero");
}
BigDecimal b1 = new BigDecimal(Double.toString(v1));
BigDecimal b2 = new BigDecimal(Double.toString(v2));
if (b1.compareTo(BigDecimal.ZERO) == 0)
{
return BigDecimal.ZERO.doubleValue();
}
return b1.divide(b2, scale, RoundingMode.HALF_UP).doubleValue();
}
/**
* 提供精确的小数位四舍五入处理。
* @param v 需要四舍五入的数字
* @param scale 小数点后保留几位
* @return 四舍五入后的结果
*/
public static double round(double v, int scale)
{
if (scale < 0)
{
throw new IllegalArgumentException(
"The scale must be a positive integer or zero");
}
BigDecimal b = new BigDecimal(Double.toString(v));
BigDecimal one = new BigDecimal("1");
return b.divide(one, scale, RoundingMode.HALF_UP).doubleValue();
}
}
package com.ruoyi.common.utils;
import java.math.BigDecimal;
import java.math.RoundingMode;
/**
* 精确的浮点数运算
*
* @author ruoyi
*/
public class Arith
{
/** 默认除法运算精度 */
private static final int DEF_DIV_SCALE = 10;
/** 这个类不能实例化 */
private Arith()
{
}
/**
* 提供精确的加法运算。
* @param v1 被加数
* @param v2 加数
* @return 两个参数的和
*/
public static double add(double v1, double v2)
{
BigDecimal b1 = new BigDecimal(Double.toString(v1));
BigDecimal b2 = new BigDecimal(Double.toString(v2));
return b1.add(b2).doubleValue();
}
/**
* 提供精确的减法运算。
* @param v1 被减数
* @param v2 减数
* @return 两个参数的差
*/
public static double sub(double v1, double v2)
{
BigDecimal b1 = new BigDecimal(Double.toString(v1));
BigDecimal b2 = new BigDecimal(Double.toString(v2));
return b1.subtract(b2).doubleValue();
}
/**
* 提供精确的乘法运算。
* @param v1 被乘数
* @param v2 乘数
* @return 两个参数的积
*/
public static double mul(double v1, double v2)
{
BigDecimal b1 = new BigDecimal(Double.toString(v1));
BigDecimal b2 = new BigDecimal(Double.toString(v2));
return b1.multiply(b2).doubleValue();
}
/**
* 提供(相对)精确的除法运算,当发生除不尽的情况时,精确到
* 小数点以后10位以后的数字四舍五入。
* @param v1 被除数
* @param v2 除数
* @return 两个参数的商
*/
public static double div(double v1, double v2)
{
return div(v1, v2, DEF_DIV_SCALE);
}
/**
* 提供相对精确的除法运算。当发生除不尽的情况时由scale参数指
* 定精度,以后的数字四舍五入。
* @param v1 被除数
* @param v2 除数
* @param scale 表示表示需要精确到小数点以后几位。
* @return 两个参数的商
*/
public static double div(double v1, double v2, int scale)
{
if (scale < 0)
{
throw new IllegalArgumentException(
"The scale must be a positive integer or zero");
}
BigDecimal b1 = new BigDecimal(Double.toString(v1));
BigDecimal b2 = new BigDecimal(Double.toString(v2));
if (b1.compareTo(BigDecimal.ZERO) == 0)
{
return BigDecimal.ZERO.doubleValue();
}
return b1.divide(b2, scale, RoundingMode.HALF_UP).doubleValue();
}
/**
* 提供精确的小数位四舍五入处理。
* @param v 需要四舍五入的数字
* @param scale 小数点后保留几位
* @return 四舍五入后的结果
*/
public static double round(double v, int scale)
{
if (scale < 0)
{
throw new IllegalArgumentException(
"The scale must be a positive integer or zero");
}
BigDecimal b = new BigDecimal(Double.toString(v));
BigDecimal one = BigDecimal.ONE;
return b.divide(one, scale, RoundingMode.HALF_UP).doubleValue();
}
}

View File

@ -151,6 +151,16 @@ public class DictUtils
return StringUtils.stripEnd(propertyString.toString(), separator);
}
/**
* 删除指定字典缓存
*
* @param key 字典键
*/
public static void removeDictCache(String key)
{
SpringUtils.getBean(RedisCache.class).deleteObject(getCacheKey(key));
}
/**
* 清空字典缓存
*/

View File

@ -22,7 +22,7 @@ public class ExceptionUtil
return str;
}
public static String getRootErrorMseeage(Exception e)
public static String getRootErrorMessage(Exception e)
{
Throwable root = ExceptionUtils.getRootCause(e);
root = (root == null ? e : root);

View File

@ -0,0 +1,29 @@
package com.ruoyi.common.utils;
import com.github.pagehelper.PageHelper;
import com.ruoyi.common.core.page.PageDomain;
import com.ruoyi.common.core.page.TableSupport;
import com.ruoyi.common.utils.sql.SqlUtil;
/**
* 分页工具类
*
* @author ruoyi
*/
public class PageUtils extends PageHelper
{
/**
* 设置请求分页数据
*/
public static void startPage()
{
PageDomain pageDomain = TableSupport.buildPageRequest();
Integer pageNum = pageDomain.getPageNum();
Integer pageSize = pageDomain.getPageSize();
if (StringUtils.isNotNull(pageNum) && StringUtils.isNotNull(pageSize))
{
String orderBy = SqlUtil.escapeOrderBySql(pageDomain.getOrderBy());
PageHelper.startPage(pageNum, pageSize, orderBy);
}
}
}

View File

@ -5,7 +5,7 @@ import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import com.ruoyi.common.constant.HttpStatus;
import com.ruoyi.common.core.domain.model.LoginUser;
import com.ruoyi.common.exception.CustomException;
import com.ruoyi.common.exception.ServiceException;
/**
* 安全服务工具类
@ -14,6 +14,36 @@ import com.ruoyi.common.exception.CustomException;
*/
public class SecurityUtils
{
/**
* 用户ID
**/
public static Long getUserId()
{
try
{
return getLoginUser().getUserId();
}
catch (Exception e)
{
throw new ServiceException("获取用户ID异常", HttpStatus.UNAUTHORIZED);
}
}
/**
* 获取部门ID
**/
public static Long getDeptId()
{
try
{
return getLoginUser().getDeptId();
}
catch (Exception e)
{
throw new ServiceException("获取部门ID异常", HttpStatus.UNAUTHORIZED);
}
}
/**
* 获取用户账户
**/
@ -25,7 +55,7 @@ public class SecurityUtils
}
catch (Exception e)
{
throw new CustomException("获取用户账户异常", HttpStatus.UNAUTHORIZED);
throw new ServiceException("获取用户账户异常", HttpStatus.UNAUTHORIZED);
}
}
@ -40,7 +70,7 @@ public class SecurityUtils
}
catch (Exception e)
{
throw new CustomException("获取用户信息异常", HttpStatus.UNAUTHORIZED);
throw new ServiceException("获取用户信息异常", HttpStatus.UNAUTHORIZED);
}
}

View File

@ -48,6 +48,22 @@ public class ServletUtils
return Convert.toInt(getRequest().getParameter(name), defaultValue);
}
/**
* 获取Boolean参数
*/
public static Boolean getParameterToBool(String name)
{
return Convert.toBool(getRequest().getParameter(name));
}
/**
* 获取Boolean参数
*/
public static Boolean getParameterToBool(String name, Boolean defaultValue)
{
return Convert.toBool(getRequest().getParameter(name), defaultValue);
}
/**
* 获取request
*/

View File

@ -6,6 +6,8 @@ import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.springframework.util.AntPathMatcher;
import com.ruoyi.common.constant.Constants;
import com.ruoyi.common.core.text.StrFormatter;
/**
@ -260,6 +262,17 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils
return StrFormatter.format(template, params);
}
/**
* 是否为http(s)://开头
*
* @param link 链接
* @return 结果
*/
public static boolean ishttp(String link)
{
return StringUtils.startsWithAny(link, Constants.HTTP, Constants.HTTPS);
}
/**
* 字符串转set
*
@ -312,7 +325,30 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils
}
/**
* 下划线转驼峰命名
* 查找指定字符串是否包含指定字符串列表中的任意一个字符串同时串忽略大小写
*
* @param cs 指定字符串
* @param searchCharSequences 需要检查的字符串数组
* @return 是否包含任意一个字符串
*/
public static boolean containsAnyIgnoreCase(CharSequence cs, CharSequence... searchCharSequences)
{
if (isEmpty(cs) || isEmpty(searchCharSequences))
{
return false;
}
for (CharSequence testStr : searchCharSequences)
{
if (containsIgnoreCase(cs, testStr))
{
return true;
}
}
return false;
}
/**
* 驼峰转下划线命名
*/
public static String toUnderScoreCase(String str)
{
@ -451,6 +487,45 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils
return sb.toString();
}
/**
* 查找指定字符串是否匹配指定字符串列表中的任意一个字符串
*
* @param str 指定字符串
* @param strs 需要检查的字符串数组
* @return 是否匹配
*/
public static boolean matches(String str, List<String> strs)
{
if (isEmpty(str) || isEmpty(strs))
{
return false;
}
for (String pattern : strs)
{
if (isMatch(pattern, str))
{
return true;
}
}
return false;
}
/**
* 判断url是否与规则配置:
* ? 表示单个字符;
* * 表示一层路径内的任意字符串,不可跨层级;
* ** 表示任意层路径;
*
* @param pattern 匹配规则
* @param url 需要匹配的url
* @return
*/
public static boolean isMatch(String pattern, String url)
{
AntPathMatcher matcher = new AntPathMatcher();
return matcher.match(pattern, url);
}
@SuppressWarnings("unchecked")
public static <T> T cast(Object obj)
{

View File

@ -36,7 +36,7 @@ public class Threads
* 停止线程池
* 先使用shutdown, 停止接收新任务并尝试完成所有已存在任务.
* 如果超时, 则调用shutdownNow, 取消在workQueue中Pending的任务,并中断所有阻塞函数.
* 如果仍超時,則強制退出.
* 如果仍超時,則強制退出.
* 另对在shutdown时线程本身被调用中断做了处理.
*/
public static void shutdownAndAwaitTermination(ExecutorService pool)

View File

@ -0,0 +1,24 @@
package com.ruoyi.common.utils.bean;
import java.util.Set;
import javax.validation.ConstraintViolation;
import javax.validation.ConstraintViolationException;
import javax.validation.Validator;
/**
* bean对象属性验证
*
* @author ruoyi
*/
public class BeanValidators
{
public static void validateWithException(Validator validator, Object object, Class<?>... groups)
throws ConstraintViolationException
{
Set<ConstraintViolation<Object>> constraintViolations = validator.validate(object, groups);
if (!constraintViolations.isEmpty())
{
throw new ConstraintViolationException(constraintViolations);
}
}
}

View File

@ -127,22 +127,21 @@ public class FileUploadUtils
return fileName;
}
private static final File getAbsoluteFile(String uploadDir, String fileName) throws IOException
public static final File getAbsoluteFile(String uploadDir, String fileName) throws IOException
{
File desc = new File(uploadDir + File.separator + fileName);
if (!desc.getParentFile().exists())
{
desc.getParentFile().mkdirs();
}
if (!desc.exists())
{
desc.createNewFile();
if (!desc.getParentFile().exists())
{
desc.getParentFile().mkdirs();
}
}
return desc;
}
private static final String getPathFileName(String uploadDir, String fileName) throws IOException
public static final String getPathFileName(String uploadDir, String fileName) throws IOException
{
int dirLastIndex = RuoYiConfig.getProfile().length() + 1;
String currentDir = StringUtils.substring(uploadDir, dirLastIndex);
@ -186,6 +185,11 @@ public class FileUploadUtils
throw new InvalidExtensionException.InvalidMediaExtensionException(allowedExtension, extension,
fileName);
}
else if (allowedExtension == MimeTypeUtils.VIDEO_EXTENSION)
{
throw new InvalidExtensionException.InvalidVideoExtensionException(allowedExtension, extension,
fileName);
}
else
{
throw new InvalidExtensionException(allowedExtension, extension, fileName);

View File

@ -3,6 +3,7 @@ package com.ruoyi.common.utils.file;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.io.UnsupportedEncodingException;
@ -10,15 +11,19 @@ import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.ArrayUtils;
import com.ruoyi.common.config.RuoYiConfig;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.uuid.IdUtils;
/**
* 文件处理工具类
*
* @author ruoyi
*/
public class FileUtils extends org.apache.commons.io.FileUtils
public class FileUtils
{
public static String FILENAME_PATTERN = "[a-zA-Z0-9_\\-\\|\\.\\u4e00-\\u9fa5]+";
@ -53,31 +58,50 @@ public class FileUtils extends org.apache.commons.io.FileUtils
}
finally
{
if (os != null)
{
try
{
os.close();
}
catch (IOException e1)
{
e1.printStackTrace();
}
}
if (fis != null)
{
try
{
fis.close();
}
catch (IOException e1)
{
e1.printStackTrace();
}
}
IOUtils.close(os);
IOUtils.close(fis);
}
}
/**
* 写数据到文件中
*
* @param data 数据
* @return 目标文件
* @throws IOException IO异常
*/
public static String writeImportBytes(byte[] data) throws IOException
{
return writeBytes(data, RuoYiConfig.getImportPath());
}
/**
* 写数据到文件中
*
* @param data 数据
* @param uploadDir 目标文件
* @return 目标文件
* @throws IOException IO异常
*/
public static String writeBytes(byte[] data, String uploadDir) throws IOException
{
FileOutputStream fos = null;
String pathName = "";
try
{
String extension = getFileExtendName(data);
pathName = DateUtils.datePath() + "/" + IdUtils.fastUUID() + "." + extension;
File file = FileUploadUtils.getAbsoluteFile(uploadDir, pathName);
fos = new FileOutputStream(file);
fos.write(data);
}
finally
{
IOUtils.close(fos);
}
return FileUploadUtils.getPathFileName(uploadDir, pathName);
}
/**
* 删除文件
*
@ -186,7 +210,10 @@ public class FileUtils extends org.apache.commons.io.FileUtils
.append("utf-8''")
.append(percentEncodedFileName);
response.addHeader("Access-Control-Allow-Origin", "*");
response.addHeader("Access-Control-Expose-Headers", "Content-Disposition,download-filename");
response.setHeader("Content-disposition", contentDispositionValue.toString());
response.setHeader("download-filename", percentEncodedFileName);
}
/**
@ -200,4 +227,33 @@ public class FileUtils extends org.apache.commons.io.FileUtils
String encode = URLEncoder.encode(s, StandardCharsets.UTF_8.toString());
return encode.replaceAll("\\+", "%20");
}
/**
* 获取图像后缀
*
* @param photoByte 图像数据
* @return 后缀名
*/
public static String getFileExtendName(byte[] photoByte)
{
String strFileExtendName = "jpg";
if ((photoByte[0] == 71) && (photoByte[1] == 73) && (photoByte[2] == 70) && (photoByte[3] == 56)
&& ((photoByte[4] == 55) || (photoByte[4] == 57)) && (photoByte[5] == 97))
{
strFileExtendName = "gif";
}
else if ((photoByte[6] == 74) && (photoByte[7] == 70) && (photoByte[8] == 73) && (photoByte[9] == 70))
{
strFileExtendName = "jpg";
}
else if ((photoByte[0] == 66) && (photoByte[1] == 77))
{
strFileExtendName = "bmp";
}
else if ((photoByte[1] == 80) && (photoByte[2] == 78) && (photoByte[3] == 71))
{
strFileExtendName = "png";
}
return strFileExtendName;
}
}

View File

@ -94,6 +94,7 @@ public class ImageUtils
}
finally
{
IOUtils.closeQuietly(in);
IOUtils.closeQuietly(baos);
}
}

View File

@ -24,6 +24,8 @@ public class MimeTypeUtils
public static final String[] MEDIA_EXTENSION = { "swf", "flv", "mp3", "wav", "wma", "wmv", "mid", "avi", "mpg",
"asf", "rm", "rmvb" };
public static final String[] VIDEO_EXTENSION = { "mp4", "avi", "rmvb" };
public static final String[] DEFAULT_ALLOWED_EXTENSION = {
// 图片
"bmp", "gif", "jpg", "jpeg", "png",
@ -31,6 +33,8 @@ public class MimeTypeUtils
"doc", "docx", "xls", "xlsx", "ppt", "pptx", "html", "htm", "txt",
// 压缩文件
"rar", "zip", "gz", "bz2",
// 视频格式
"mp4", "avi", "rmvb",
// pdf
"pdf" };

View File

@ -22,7 +22,7 @@ public class EscapeUtil
// special HTML characters
TEXT['\''] = "&#039;".toCharArray(); // 单引号
TEXT['"'] = "&#34;".toCharArray(); // 引号
TEXT['"'] = "&#34;".toCharArray(); // 引号
TEXT['&'] = "&#38;".toCharArray(); // &符
TEXT['<'] = "&#60;".toCharArray(); // 小于号
TEXT['>'] = "&#62;".toCharArray(); // 大于号
@ -69,26 +69,37 @@ public class EscapeUtil
*/
private static String encode(String text)
{
int len;
if ((text == null) || ((len = text.length()) == 0))
if (StringUtils.isEmpty(text))
{
return StringUtils.EMPTY;
}
StringBuilder buffer = new StringBuilder(len + (len >> 2));
final StringBuilder tmp = new StringBuilder(text.length() * 6);
char c;
for (int i = 0; i < len; i++)
for (int i = 0; i < text.length(); i++)
{
c = text.charAt(i);
if (c < 64)
if (c < 256)
{
buffer.append(TEXT[c]);
tmp.append("%");
if (c < 16)
{
tmp.append("0");
}
tmp.append(Integer.toString(c, 16));
}
else
{
buffer.append(c);
tmp.append("%u");
if (c <= 0xfff)
{
// issue#I49JU8@Gitee
tmp.append("0");
}
tmp.append(Integer.toString(c, 16));
}
}
return buffer.toString();
return tmp.toString();
}
/**
@ -145,11 +156,12 @@ public class EscapeUtil
public static void main(String[] args)
{
String html = "<script>alert(1);</script>";
String escape = EscapeUtil.escape(html);
// String html = "<scr<script>ipt>alert(\"XSS\")</scr<script>ipt>";
// String html = "<123";
// String html = "123>";
System.out.println(EscapeUtil.clean(html));
System.out.println(EscapeUtil.escape(html));
System.out.println(EscapeUtil.unescape(html));
System.out.println("clean: " + EscapeUtil.clean(html));
System.out.println("escape: " + escape);
System.out.println("unescape: " + EscapeUtil.unescape(escape));
}
}

View File

@ -332,7 +332,7 @@ public final class HTMLFilter
final String name = m.group(1).toLowerCase();
if (allowed(name))
{
if (false == inArray(name, vSelfClosingTags))
if (!inArray(name, vSelfClosingTags))
{
if (vTagCounts.containsKey(name))
{
@ -387,7 +387,7 @@ public final class HTMLFilter
{
paramValue = processParamProtocol(paramValue);
}
params.append(' ').append(paramName).append("=\"").append(paramValue).append("\"");
params.append(' ').append(paramName).append("=\\\"").append(paramValue).append("\"");
}
}

View File

@ -19,6 +19,7 @@ import javax.net.ssl.X509TrustManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.ruoyi.common.constant.Constants;
import com.ruoyi.common.utils.StringUtils;
/**
* 通用http发送方法
@ -29,6 +30,17 @@ public class HttpUtils
{
private static final Logger log = LoggerFactory.getLogger(HttpUtils.class);
/**
* 向指定 URL 发送GET方法的请求
*
* @param url 发送请求的 URL
* @return 所代表远程资源的响应结果
*/
public static String sendGet(String url)
{
return sendGet(url, StringUtils.EMPTY);
}
/**
* 向指定 URL 发送GET方法的请求
*
@ -55,7 +67,7 @@ public class HttpUtils
BufferedReader in = null;
try
{
String urlNameString = url + "?" + param;
String urlNameString = StringUtils.isNotBlank(param) ? url + "?" + param : url;
log.info("sendGet - {}", urlNameString);
URL realUrl = new URL(urlNameString);
URLConnection connection = realUrl.openConnection();

View File

@ -0,0 +1,19 @@
package com.ruoyi.common.utils.poi;
/**
* Excel数据格式处理适配器
*
* @author ruoyi
*/
public interface ExcelHandlerAdapter
{
/**
* 格式化
*
* @param value 单元格数据值
* @param args excel注解args参数组
*
* @return 处理后的值
*/
Object format(Object value, String[] args);
}

View File

@ -6,6 +6,7 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.math.BigDecimal;
import java.text.DecimalFormat;
import java.util.ArrayList;
@ -18,6 +19,14 @@ import java.util.Map;
import java.util.Set;
import java.util.UUID;
import java.util.stream.Collectors;
import javax.servlet.http.HttpServletResponse;
import org.apache.poi.hssf.usermodel.HSSFClientAnchor;
import org.apache.poi.hssf.usermodel.HSSFPicture;
import org.apache.poi.hssf.usermodel.HSSFPictureData;
import org.apache.poi.hssf.usermodel.HSSFShape;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ooxml.POIXMLDocumentPart;
import org.apache.poi.ss.usermodel.BorderStyle;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.CellStyle;
@ -32,15 +41,24 @@ import org.apache.poi.ss.usermodel.FillPatternType;
import org.apache.poi.ss.usermodel.Font;
import org.apache.poi.ss.usermodel.HorizontalAlignment;
import org.apache.poi.ss.usermodel.IndexedColors;
import org.apache.poi.ss.usermodel.PictureData;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.VerticalAlignment;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.ss.usermodel.WorkbookFactory;
import org.apache.poi.ss.util.CellRangeAddress;
import org.apache.poi.ss.util.CellRangeAddressList;
import org.apache.poi.util.IOUtils;
import org.apache.poi.xssf.streaming.SXSSFWorkbook;
import org.apache.poi.xssf.usermodel.XSSFClientAnchor;
import org.apache.poi.xssf.usermodel.XSSFDataValidation;
import org.apache.poi.xssf.usermodel.XSSFDrawing;
import org.apache.poi.xssf.usermodel.XSSFPicture;
import org.apache.poi.xssf.usermodel.XSSFShape;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.openxmlformats.schemas.drawingml.x2006.spreadsheetDrawing.CTMarker;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.ruoyi.common.annotation.Excel;
@ -50,11 +68,12 @@ import com.ruoyi.common.annotation.Excels;
import com.ruoyi.common.config.RuoYiConfig;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.text.Convert;
import com.ruoyi.common.exception.CustomException;
import com.ruoyi.common.exception.UtilException;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.DictUtils;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.file.FileTypeUtils;
import com.ruoyi.common.utils.file.FileUtils;
import com.ruoyi.common.utils.file.ImageUtils;
import com.ruoyi.common.utils.reflect.ReflectUtils;
@ -107,6 +126,16 @@ public class ExcelUtil<T>
*/
private List<Object[]> fields;
/**
* 当前行号
*/
private int rownum;
/**
* 标题
*/
private String title;
/**
* 最大高度
*/
@ -116,12 +145,12 @@ public class ExcelUtil<T>
* 统计列表
*/
private Map<Integer, Double> statistics = new HashMap<Integer, Double>();
/**
* 数字格式
*/
private static final DecimalFormat DOUBLE_FORMAT = new DecimalFormat("######0.00");
/**
* 实体对象
*/
@ -132,7 +161,7 @@ public class ExcelUtil<T>
this.clazz = clazz;
}
public void init(List<T> list, String sheetName, Type type)
public void init(List<T> list, String sheetName, String title, Type type)
{
if (list == null)
{
@ -141,8 +170,27 @@ public class ExcelUtil<T>
this.list = list;
this.sheetName = sheetName;
this.type = type;
this.title = title;
createExcelField();
createWorkbook();
createTitle();
}
/**
* 创建excel第一行标题
*/
public void createTitle()
{
if (StringUtils.isNotEmpty(title))
{
Row titleRow = sheet.createRow(rownum == 0 ? rownum++ : 0);
titleRow.setHeightInPoints(30);
Cell titleCell = titleRow.createCell(0);
titleCell.setCellStyle(styles.get("title"));
titleCell.setCellValue(title);
sheet.addMergedRegion(new CellRangeAddress(titleRow.getRowNum(), titleRow.getRowNum(), titleRow.getRowNum(),
this.fields.size() - 1));
}
}
/**
@ -153,46 +201,59 @@ public class ExcelUtil<T>
*/
public List<T> importExcel(InputStream is) throws Exception
{
return importExcel(StringUtils.EMPTY, is);
return importExcel(is, 0);
}
/**
* 对excel表单默认第一个索引名转换成list
*
* @param is 输入流
* @param titleNum 标题占用行数
* @return 转换后集合
*/
public List<T> importExcel(InputStream is, int titleNum) throws Exception
{
return importExcel(StringUtils.EMPTY, is, titleNum);
}
/**
* 对excel表单指定表格索引名转换成list
*
* @param sheetName 表格索引名
* @param titleNum 标题占用行数
* @param is 输入流
* @return 转换后集合
*/
public List<T> importExcel(String sheetName, InputStream is) throws Exception
public List<T> importExcel(String sheetName, InputStream is, int titleNum) throws Exception
{
this.type = Type.IMPORT;
this.wb = WorkbookFactory.create(is);
List<T> list = new ArrayList<T>();
Sheet sheet = null;
if (StringUtils.isNotEmpty(sheetName))
{
// 如果指定sheet名,则取指定sheet中的内容.
sheet = wb.getSheet(sheetName);
}
else
{
// 如果传入的sheet名不存在则默认指向第1个sheet.
sheet = wb.getSheetAt(0);
}
// 如果指定sheet名,则取指定sheet中的内容 否则默认指向第1个sheet
Sheet sheet = StringUtils.isNotEmpty(sheetName) ? wb.getSheet(sheetName) : wb.getSheetAt(0);
if (sheet == null)
{
throw new IOException("文件sheet不存在");
}
int rows = sheet.getPhysicalNumberOfRows();
boolean isXSSFWorkbook = !(wb instanceof HSSFWorkbook);
Map<String, PictureData> pictures;
if (isXSSFWorkbook)
{
pictures = getSheetPictures07((XSSFSheet) sheet, (XSSFWorkbook) wb);
}
else
{
pictures = getSheetPictures03((HSSFSheet) sheet, (HSSFWorkbook) wb);
}
// 获取最后一个非空行的行下标比如总行数为n则返回的为n-1
int rows = sheet.getLastRowNum();
if (rows > 0)
{
// 定义一个map用于存放excel列的序号和field.
Map<String, Integer> cellMap = new HashMap<String, Integer>();
// 获取表头
Row heard = sheet.getRow(0);
Row heard = sheet.getRow(titleNum);
for (int i = 0; i < heard.getPhysicalNumberOfCells(); i++)
{
Cell cell = heard.getCell(i);
@ -207,37 +268,36 @@ public class ExcelUtil<T>
}
}
// 有数据时才处理 得到类的所有field.
Field[] allFields = clazz.getDeclaredFields();
// 定义一个map用于存放列的序号和field.
Map<Integer, Field> fieldsMap = new HashMap<Integer, Field>();
for (int col = 0; col < allFields.length; col++)
List<Object[]> fields = this.getFields();
Map<Integer, Object[]> fieldsMap = new HashMap<Integer, Object[]>();
for (Object[] objects : fields)
{
Field field = allFields[col];
Excel attr = field.getAnnotation(Excel.class);
if (attr != null && (attr.type() == Type.ALL || attr.type() == type))
Excel attr = (Excel) objects[1];
Integer column = cellMap.get(attr.name());
if (column != null)
{
// 设置类的私有字段属性可访问.
field.setAccessible(true);
Integer column = cellMap.get(attr.name());
if (column != null)
{
fieldsMap.put(column, field);
}
fieldsMap.put(column, objects);
}
}
for (int i = 1; i < rows; i++)
for (int i = titleNum + 1; i <= rows; i++)
{
// 从第2行开始取数据,默认第一行是表头.
Row row = sheet.getRow(i);
// 判断当前行是否是空行
if (isRowEmpty(row))
{
continue;
}
T entity = null;
for (Map.Entry<Integer, Field> entry : fieldsMap.entrySet())
for (Map.Entry<Integer, Object[]> entry : fieldsMap.entrySet())
{
Object val = this.getCellValue(row, entry.getKey());
// 如果不存在实例则新建.
entity = (entity == null ? clazz.newInstance() : entity);
// 从map中得到对应列的field.
Field field = fieldsMap.get(entry.getKey());
Field field = (Field) entry.getValue()[0];
Excel attr = (Excel) entry.getValue()[1];
// 取得类型,并根据对象类型设置值.
Class<?> fieldType = field.getType();
if (String.class == fieldType)
@ -297,7 +357,6 @@ public class ExcelUtil<T>
}
if (StringUtils.isNotNull(fieldType))
{
Excel attr = field.getAnnotation(Excel.class);
String propertyName = field.getName();
if (StringUtils.isNotEmpty(attr.targetAttr()))
{
@ -311,6 +370,23 @@ public class ExcelUtil<T>
{
val = reverseDictByExp(Convert.toStr(val), attr.dictType(), attr.separator());
}
else if (!attr.handler().equals(ExcelHandlerAdapter.class))
{
val = dataFormatHandlerAdapter(val, attr);
}
else if (ColumnType.IMAGE == attr.cellType() && StringUtils.isNotEmpty(pictures))
{
PictureData image = pictures.get(row.getRowNum() + "_" + entry.getKey());
if (image == null)
{
val = "";
}
else
{
byte[] data = image.getData();
val = FileUtils.writeImportBytes(data);
}
}
ReflectUtils.invokeSetter(entity, propertyName, val);
}
}
@ -329,10 +405,55 @@ public class ExcelUtil<T>
*/
public AjaxResult exportExcel(List<T> list, String sheetName)
{
this.init(list, sheetName, Type.EXPORT);
return exportExcel(list, sheetName, StringUtils.EMPTY);
}
/**
* 对list数据源将其里面的数据导入到excel表单
*
* @param list 导出数据集合
* @param sheetName 工作表的名称
* @param title 标题
* @return 结果
*/
public AjaxResult exportExcel(List<T> list, String sheetName, String title)
{
this.init(list, sheetName, title, Type.EXPORT);
return exportExcel();
}
/**
* 对list数据源将其里面的数据导入到excel表单
*
* @param response 返回数据
* @param list 导出数据集合
* @param sheetName 工作表的名称
* @return 结果
* @throws IOException
*/
public void exportExcel(HttpServletResponse response, List<T> list, String sheetName)
{
exportExcel(response, list, sheetName, StringUtils.EMPTY);
}
/**
* 对list数据源将其里面的数据导入到excel表单
*
* @param response 返回数据
* @param list 导出数据集合
* @param sheetName 工作表的名称
* @param title 标题
* @return 结果
* @throws IOException
*/
public void exportExcel(HttpServletResponse response, List<T> list, String sheetName, String title)
{
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
response.setCharacterEncoding("utf-8");
this.init(list, sheetName, title, Type.EXPORT);
exportExcel(response);
}
/**
* 对list数据源将其里面的数据导入到excel表单
*
@ -341,10 +462,70 @@ public class ExcelUtil<T>
*/
public AjaxResult importTemplateExcel(String sheetName)
{
this.init(null, sheetName, Type.IMPORT);
return importTemplateExcel(sheetName, StringUtils.EMPTY);
}
/**
* 对list数据源将其里面的数据导入到excel表单
*
* @param sheetName 工作表的名称
* @param title 标题
* @return 结果
*/
public AjaxResult importTemplateExcel(String sheetName, String title)
{
this.init(null, sheetName, title, Type.IMPORT);
return exportExcel();
}
/**
* 对list数据源将其里面的数据导入到excel表单
*
* @param sheetName 工作表的名称
* @return 结果
*/
public void importTemplateExcel(HttpServletResponse response, String sheetName)
{
importTemplateExcel(response, sheetName, StringUtils.EMPTY);
}
/**
* 对list数据源将其里面的数据导入到excel表单
*
* @param sheetName 工作表的名称
* @param title 标题
* @return 结果
*/
public void importTemplateExcel(HttpServletResponse response, String sheetName, String title)
{
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
response.setCharacterEncoding("utf-8");
this.init(null, sheetName, title, Type.IMPORT);
exportExcel(response);
}
/**
* 对list数据源将其里面的数据导入到excel表单
*
* @return 结果
*/
public void exportExcel(HttpServletResponse response)
{
try
{
writeSheet();
wb.write(response.getOutputStream());
}
catch (Exception e)
{
log.error("导出Excel异常{}", e.getMessage());
}
finally
{
IOUtils.closeQuietly(wb);
}
}
/**
* 对list数据源将其里面的数据导入到excel表单
*
@ -355,27 +536,7 @@ public class ExcelUtil<T>
OutputStream out = null;
try
{
// 取出一共有多少个sheet.
double sheetNo = Math.ceil(list.size() / sheetSize);
for (int index = 0; index <= sheetNo; index++)
{
createSheet(sheetNo, index);
// 产生一行
Row row = sheet.createRow(0);
int column = 0;
// 写入各个字段的列头名称
for (Object[] os : fields)
{
Excel excel = (Excel) os[1];
this.createCell(excel, row, column++);
}
if (Type.EXPORT.equals(type))
{
fillExcelData(index, row);
addStatisticsRow();
}
}
writeSheet();
String filename = encodingFilename(sheetName);
out = new FileOutputStream(getAbsoluteFile(filename));
wb.write(out);
@ -384,31 +545,39 @@ public class ExcelUtil<T>
catch (Exception e)
{
log.error("导出Excel异常{}", e.getMessage());
throw new CustomException("导出Excel失败请联系网站管理员");
throw new UtilException("导出Excel失败请联系网站管理员");
}
finally
{
if (wb != null)
IOUtils.closeQuietly(wb);
IOUtils.closeQuietly(out);
}
}
/**
* 创建写入数据到Sheet
*/
public void writeSheet()
{
// 取出一共有多少个sheet.
int sheetNo = Math.max(1, (int) Math.ceil(list.size() * 1.0 / sheetSize));
for (int index = 0; index < sheetNo; index++)
{
createSheet(sheetNo, index);
// 产生一行
Row row = sheet.createRow(rownum);
int column = 0;
// 写入各个字段的列头名称
for (Object[] os : fields)
{
try
{
wb.close();
}
catch (IOException e1)
{
e1.printStackTrace();
}
Excel excel = (Excel) os[1];
this.createCell(excel, row, column++);
}
if (out != null)
if (Type.EXPORT.equals(type))
{
try
{
out.close();
}
catch (IOException e1)
{
e1.printStackTrace();
}
fillExcelData(index, row);
addStatisticsRow();
}
}
}
@ -425,7 +594,7 @@ public class ExcelUtil<T>
int endNo = Math.min(startNo + sheetSize, list.size());
for (int i = startNo; i < endNo; i++)
{
row = sheet.createRow(i + 1 - startNo);
row = sheet.createRow(i + 1 + rownum - startNo);
// 得到导出对象.
T vo = (T) list.get(i);
int column = 0;
@ -433,8 +602,6 @@ public class ExcelUtil<T>
{
Field field = (Field) os[0];
Excel excel = (Excel) os[1];
// 设置实体类私有属性可访问
field.setAccessible(true);
this.addCell(excel, row, vo, field, column++);
}
}
@ -453,6 +620,16 @@ public class ExcelUtil<T>
CellStyle style = wb.createCellStyle();
style.setAlignment(HorizontalAlignment.CENTER);
style.setVerticalAlignment(VerticalAlignment.CENTER);
Font titleFont = wb.createFont();
titleFont.setFontName("Arial");
titleFont.setFontHeightInPoints((short) 16);
titleFont.setBold(true);
style.setFont(titleFont);
styles.put("title", style);
style = wb.createCellStyle();
style.setAlignment(HorizontalAlignment.CENTER);
style.setVerticalAlignment(VerticalAlignment.CENTER);
style.setBorderRight(BorderStyle.THIN);
style.setRightBorderColor(IndexedColors.GREY_50_PERCENT.getIndex());
style.setBorderLeft(BorderStyle.THIN);
@ -480,7 +657,7 @@ public class ExcelUtil<T>
headerFont.setColor(IndexedColors.WHITE.getIndex());
style.setFont(headerFont);
styles.put("header", style);
style = wb.createCellStyle();
style.setAlignment(HorizontalAlignment.CENTER);
style.setVerticalAlignment(VerticalAlignment.CENTER);
@ -537,12 +714,14 @@ public class ExcelUtil<T>
}
else if (ColumnType.NUMERIC == attr.cellType())
{
cell.setCellValue(StringUtils.contains(Convert.toStr(value), ".") ? Convert.toDouble(value) : Convert.toInt(value));
if (StringUtils.isNotNull(value))
{
cell.setCellValue(StringUtils.contains(Convert.toStr(value), ".") ? Convert.toDouble(value) : Convert.toInt(value));
}
}
else if (ColumnType.IMAGE == attr.cellType())
{
ClientAnchor anchor = new XSSFClientAnchor(0, 0, 0, 0, (short) cell.getColumnIndex(), cell.getRow().getRowNum(), (short) (cell.getColumnIndex() + 1),
cell.getRow().getRowNum() + 1);
ClientAnchor anchor = new XSSFClientAnchor(0, 0, 0, 0, (short) cell.getColumnIndex(), cell.getRow().getRowNum(), (short) (cell.getColumnIndex() + 1), cell.getRow().getRowNum() + 1);
String imagePath = Convert.toStr(value);
if (StringUtils.isNotEmpty(imagePath))
{
@ -552,7 +731,7 @@ public class ExcelUtil<T>
}
}
}
/**
* 获取画布
*/
@ -650,6 +829,10 @@ public class ExcelUtil<T>
{
cell.setCellValue((((BigDecimal) value).setScale(attr.scale(), attr.roundingMode())).toString());
}
else if (!attr.handler().equals(ExcelHandlerAdapter.class))
{
cell.setCellValue(dataFormatHandlerAdapter(value, attr));
}
else
{
// 设置列类型
@ -795,7 +978,7 @@ public class ExcelUtil<T>
}
return StringUtils.stripEnd(propertyString.toString(), separator);
}
/**
* 解析字典值
*
@ -821,7 +1004,29 @@ public class ExcelUtil<T>
{
return DictUtils.getDictValue(dictType, dictLabel, separator);
}
/**
* 数据处理器
*
* @param value 数据值
* @param excel 数据注解
* @return
*/
public String dataFormatHandlerAdapter(Object value, Excel excel)
{
try
{
Object instance = excel.handler().newInstance();
Method formatMethod = excel.handler().getMethod("format", new Class[] { Object.class, String[].class });
value = formatMethod.invoke(instance, value, excel.args());
}
catch (Exception e)
{
log.error("不能格式化数据 " + excel.handler(), e.getMessage());
}
return Convert.toStr(value);
}
/**
* 合计统计信息
*/
@ -852,13 +1057,12 @@ public class ExcelUtil<T>
{
if (statistics.size() > 0)
{
Cell cell = null;
Row row = sheet.createRow(sheet.getLastRowNum() + 1);
Set<Integer> keys = statistics.keySet();
cell = row.createCell(0);
Cell cell = row.createCell(0);
cell.setCellStyle(styles.get("total"));
cell.setCellValue("合计");
for (Integer key : keys)
{
cell = row.createCell(key);
@ -950,7 +1154,17 @@ public class ExcelUtil<T>
*/
private void createExcelField()
{
this.fields = new ArrayList<Object[]>();
this.fields = getFields();
this.fields = this.fields.stream().sorted(Comparator.comparing(objects -> ((Excel) objects[1]).sort())).collect(Collectors.toList());
this.maxHeight = getRowHeight();
}
/**
* 获取字段注解信息
*/
public List<Object[]> getFields()
{
List<Object[]> fields = new ArrayList<Object[]>();
List<Field> tempFields = new ArrayList<>();
tempFields.addAll(Arrays.asList(clazz.getSuperclass().getDeclaredFields()));
tempFields.addAll(Arrays.asList(clazz.getDeclaredFields()));
@ -959,7 +1173,12 @@ public class ExcelUtil<T>
// 单注解
if (field.isAnnotationPresent(Excel.class))
{
putToField(field, field.getAnnotation(Excel.class));
Excel attr = field.getAnnotation(Excel.class);
if (attr != null && (attr.type() == Type.ALL || attr.type() == type))
{
field.setAccessible(true);
fields.add(new Object[] { field, attr });
}
}
// 多注解
@ -967,16 +1186,19 @@ public class ExcelUtil<T>
{
Excels attrs = field.getAnnotation(Excels.class);
Excel[] excels = attrs.value();
for (Excel excel : excels)
for (Excel attr : excels)
{
putToField(field, excel);
if (attr != null && (attr.type() == Type.ALL || attr.type() == type))
{
field.setAccessible(true);
fields.add(new Object[] { field, attr });
}
}
}
}
this.fields = this.fields.stream().sorted(Comparator.comparing(objects -> ((Excel) objects[1]).sort())).collect(Collectors.toList());
this.maxHeight = getRowHeight();
return fields;
}
/**
* 根据注解获取最大行高
*/
@ -991,23 +1213,15 @@ public class ExcelUtil<T>
return (short) (maxHeight * 20);
}
/**
* 放到字段集合中
*/
private void putToField(Field field, Excel attr)
{
if (attr != null && (attr.type() == Type.ALL || attr.type() == type))
{
this.fields.add(new Object[] { field, attr });
}
}
/**
* 创建一个工作簿
*/
public void createWorkbook()
{
this.wb = new SXSSFWorkbook(500);
this.sheet = wb.createSheet();
wb.setSheetName(0, sheetName);
this.styles = createStyles(wb);
}
/**
@ -1016,17 +1230,13 @@ public class ExcelUtil<T>
* @param sheetNo sheet数量
* @param index 序号
*/
public void createSheet(double sheetNo, int index)
public void createSheet(int sheetNo, int index)
{
this.sheet = wb.createSheet();
this.styles = createStyles(wb);
// 设置工作表的名称.
if (sheetNo == 0)
{
wb.setSheetName(index, sheetName);
}
else
if (sheetNo > 1 && index > 0)
{
this.sheet = wb.createSheet();
this.createTitle();
wb.setSheetName(index, sheetName + index);
}
}
@ -1090,4 +1300,92 @@ public class ExcelUtil<T>
}
return val;
}
}
/**
* 判断是否是空行
*
* @param row 判断的行
* @return
*/
private boolean isRowEmpty(Row row)
{
if (row == null)
{
return true;
}
for (int i = row.getFirstCellNum(); i < row.getLastCellNum(); i++)
{
Cell cell = row.getCell(i);
if (cell != null && cell.getCellType() != CellType.BLANK)
{
return false;
}
}
return true;
}
/**
* 获取Excel2003图片
*
* @param sheet 当前sheet对象
* @param workbook 工作簿对象
* @return Map key:图片单元格索引1_1Stringvalue:图片流PictureData
*/
public static Map<String, PictureData> getSheetPictures03(HSSFSheet sheet, HSSFWorkbook workbook)
{
Map<String, PictureData> sheetIndexPicMap = new HashMap<String, PictureData>();
List<HSSFPictureData> pictures = workbook.getAllPictures();
if (!pictures.isEmpty())
{
for (HSSFShape shape : sheet.getDrawingPatriarch().getChildren())
{
HSSFClientAnchor anchor = (HSSFClientAnchor) shape.getAnchor();
if (shape instanceof HSSFPicture)
{
HSSFPicture pic = (HSSFPicture) shape;
int pictureIndex = pic.getPictureIndex() - 1;
HSSFPictureData picData = pictures.get(pictureIndex);
String picIndex = String.valueOf(anchor.getRow1()) + "_" + String.valueOf(anchor.getCol1());
sheetIndexPicMap.put(picIndex, picData);
}
}
return sheetIndexPicMap;
}
else
{
return sheetIndexPicMap;
}
}
/**
* 获取Excel2007图片
*
* @param sheet 当前sheet对象
* @param workbook 工作簿对象
* @return Map key:图片单元格索引1_1Stringvalue:图片流PictureData
*/
public static Map<String, PictureData> getSheetPictures07(XSSFSheet sheet, XSSFWorkbook workbook)
{
Map<String, PictureData> sheetIndexPicMap = new HashMap<String, PictureData>();
for (POIXMLDocumentPart dr : sheet.getRelations())
{
if (dr instanceof XSSFDrawing)
{
XSSFDrawing drawing = (XSSFDrawing) dr;
List<XSSFShape> shapes = drawing.getShapes();
for (XSSFShape shape : shapes)
{
if (shape instanceof XSSFPicture)
{
XSSFPicture pic = (XSSFPicture) shape;
XSSFClientAnchor anchor = pic.getPreferredSize();
CTMarker ctMarker = anchor.getFrom();
String picIndex = ctMarker.getRow() + "_" + ctMarker.getCol();
sheetIndexPicMap.put(picIndex, pic.getPictureData());
}
}
}
}
return sheetIndexPicMap;
}
}

View File

@ -1,6 +1,6 @@
package com.ruoyi.common.utils.sql;
import com.ruoyi.common.exception.BaseException;
import com.ruoyi.common.exception.UtilException;
import com.ruoyi.common.utils.StringUtils;
/**
@ -10,6 +10,11 @@ import com.ruoyi.common.utils.StringUtils;
*/
public class SqlUtil
{
/**
* 定义常用的 sql关键字
*/
public static String SQL_REGEX = "select |insert |delete |update |drop |count |exec |chr |mid |master |truncate |char |and |declare ";
/**
* 仅支持字母、数字、下划线、空格、逗号、小数点(支持多个字段排序)
*/
@ -22,7 +27,7 @@ public class SqlUtil
{
if (StringUtils.isNotEmpty(value) && !isValidOrderBySql(value))
{
throw new BaseException("参数不符合规范,不能进行查询");
throw new UtilException("参数不符合规范,不能进行查询");
}
return value;
}
@ -34,4 +39,23 @@ public class SqlUtil
{
return value.matches(SQL_PATTERN);
}
/**
* SQL关键字检查
*/
public static void filterKeyword(String value)
{
if (StringUtils.isEmpty(value))
{
return;
}
String[] sqlKeywords = StringUtils.split(SQL_REGEX, "\\|");
for (int i = 0; i < sqlKeywords.length; i++)
{
if (StringUtils.indexOfIgnoreCase(value, sqlKeywords[i]) > -1)
{
throw new UtilException("参数存在SQL注入风险");
}
}
}
}

View File

@ -1,7 +1,5 @@
package com.ruoyi.common.utils.uuid;
import com.ruoyi.common.utils.uuid.UUID;
/**
* ID生成器工具类
*

View File

@ -343,25 +343,25 @@ public final class UUID implements java.io.Serializable, Comparable<UUID>
final StringBuilder builder = new StringBuilder(isSimple ? 32 : 36);
// time_low
builder.append(digits(mostSigBits >> 32, 8));
if (false == isSimple)
if (!isSimple)
{
builder.append('-');
}
// time_mid
builder.append(digits(mostSigBits >> 16, 4));
if (false == isSimple)
if (!isSimple)
{
builder.append('-');
}
// time_high_and_version
builder.append(digits(mostSigBits, 4));
if (false == isSimple)
if (!isSimple)
{
builder.append('-');
}
// variant_and_sequence
builder.append(digits(leastSigBits >> 48, 4));
if (false == isSimple)
if (!isSimple)
{
builder.append('-');
}

View File

@ -0,0 +1,27 @@
package com.ruoyi.common.xss;
import javax.validation.Constraint;
import javax.validation.Payload;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* 自定义xss校验注解
*
* @author ruoyi
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(value = { ElementType.METHOD, ElementType.FIELD, ElementType.CONSTRUCTOR, ElementType.PARAMETER })
@Constraint(validatedBy = { XssValidator.class })
public @interface Xss
{
String message()
default "不允许任何脚本运行";
Class<?>[] groups() default {};
Class<? extends Payload>[] payload() default {};
}

View File

@ -0,0 +1,29 @@
package com.ruoyi.common.xss;
import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* 自定义xss校验注解实现
*
* @author ruoyi
*/
public class XssValidator implements ConstraintValidator<Xss, String>
{
private final String HTML_PATTERN = "<(\\S*?)[^>]*>.*?|<.*? />";
@Override
public boolean isValid(String value, ConstraintValidatorContext constraintValidatorContext)
{
return !containsHtml(value);
}
public boolean containsHtml(String value)
{
Pattern pattern = Pattern.compile(HTML_PATTERN);
Matcher matcher = pattern.matcher(value);
return matcher.matches();
}
}

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>ruoyi</artifactId>
<groupId>com.ruoyi</groupId>
<version>3.4.0</version>
<version>3.8.1</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -1,22 +1,16 @@
package com.ruoyi.framework.aspectj;
import java.lang.reflect.Method;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.Signature;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
import org.aspectj.lang.reflect.MethodSignature;
import org.springframework.stereotype.Component;
import com.ruoyi.common.annotation.DataScope;
import com.ruoyi.common.core.domain.BaseEntity;
import com.ruoyi.common.core.domain.entity.SysRole;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.core.domain.model.LoginUser;
import com.ruoyi.common.utils.ServletUtils;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.spring.SpringUtils;
import com.ruoyi.framework.web.service.TokenService;
import com.ruoyi.common.utils.SecurityUtils;
/**
* 数据过滤处理
@ -57,28 +51,17 @@ public class DataScopeAspect
*/
public static final String DATA_SCOPE = "dataScope";
// 配置织入点
@Pointcut("@annotation(com.ruoyi.common.annotation.DataScope)")
public void dataScopePointCut()
@Before("@annotation(controllerDataScope)")
public void doBefore(JoinPoint point, DataScope controllerDataScope) throws Throwable
{
clearDataScope(point);
handleDataScope(point, controllerDataScope);
}
@Before("dataScopePointCut()")
public void doBefore(JoinPoint point) throws Throwable
protected void handleDataScope(final JoinPoint joinPoint, DataScope controllerDataScope)
{
handleDataScope(point);
}
protected void handleDataScope(final JoinPoint joinPoint)
{
// 获得注解
DataScope controllerDataScope = getAnnotationLog(joinPoint);
if (controllerDataScope == null)
{
return;
}
// 获取当前的用户
LoginUser loginUser = SpringUtils.getBean(TokenService.class).getLoginUser(ServletUtils.getRequest());
LoginUser loginUser = SecurityUtils.getLoginUser();
if (StringUtils.isNotNull(loginUser))
{
SysUser currentUser = loginUser.getUser();
@ -152,18 +135,15 @@ public class DataScopeAspect
}
/**
* 是否存在注解,如果存在就获取
* 拼接权限sql前先清空params.dataScope参数防止注入
*/
private DataScope getAnnotationLog(JoinPoint joinPoint)
private void clearDataScope(final JoinPoint joinPoint)
{
Signature signature = joinPoint.getSignature();
MethodSignature methodSignature = (MethodSignature) signature;
Method method = methodSignature.getMethod();
if (method != null)
Object params = joinPoint.getArgs()[0];
if (StringUtils.isNotNull(params) && params instanceof BaseEntity)
{
return method.getAnnotation(DataScope.class);
BaseEntity baseEntity = (BaseEntity) params;
baseEntity.getParams().put(DATA_SCOPE, "");
}
return null;
}
}

View File

@ -1,21 +1,17 @@
package com.ruoyi.framework.aspectj;
import java.lang.reflect.Method;
import java.util.Collection;
import java.util.Iterator;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.Signature;
import org.aspectj.lang.annotation.AfterReturning;
import org.aspectj.lang.annotation.AfterThrowing;
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.stereotype.Component;
import org.springframework.validation.BindingResult;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.servlet.HandlerMapping;
import com.alibaba.fastjson.JSON;
@ -26,10 +22,9 @@ import com.ruoyi.common.enums.HttpMethod;
import com.ruoyi.common.utils.ServletUtils;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.ip.IpUtils;
import com.ruoyi.common.utils.spring.SpringUtils;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.framework.manager.AsyncManager;
import com.ruoyi.framework.manager.factory.AsyncFactory;
import com.ruoyi.framework.web.service.TokenService;
import com.ruoyi.system.domain.SysOperLog;
/**
@ -43,21 +38,15 @@ public class LogAspect
{
private static final Logger log = LoggerFactory.getLogger(LogAspect.class);
// 配置织入点
@Pointcut("@annotation(com.ruoyi.common.annotation.Log)")
public void logPointCut()
{
}
/**
* 处理完请求后执行
*
* @param joinPoint 切点
*/
@AfterReturning(pointcut = "logPointCut()", returning = "jsonResult")
public void doAfterReturning(JoinPoint joinPoint, Object jsonResult)
@AfterReturning(pointcut = "@annotation(controllerLog)", returning = "jsonResult")
public void doAfterReturning(JoinPoint joinPoint, Log controllerLog, Object jsonResult)
{
handleLog(joinPoint, null, jsonResult);
handleLog(joinPoint, controllerLog, null, jsonResult);
}
/**
@ -66,25 +55,19 @@ public class LogAspect
* @param joinPoint 切点
* @param e 异常
*/
@AfterThrowing(value = "logPointCut()", throwing = "e")
public void doAfterThrowing(JoinPoint joinPoint, Exception e)
@AfterThrowing(value = "@annotation(controllerLog)", throwing = "e")
public void doAfterThrowing(JoinPoint joinPoint, Log controllerLog, Exception e)
{
handleLog(joinPoint, e, null);
handleLog(joinPoint, controllerLog, e, null);
}
protected void handleLog(final JoinPoint joinPoint, final Exception e, Object jsonResult)
protected void handleLog(final JoinPoint joinPoint, Log controllerLog, final Exception e, Object jsonResult)
{
try
{
// 获得注解
Log controllerLog = getAnnotationLog(joinPoint);
if (controllerLog == null)
{
return;
}
// 获取当前的用户
LoginUser loginUser = SpringUtils.getBean(TokenService.class).getLoginUser(ServletUtils.getRequest());
LoginUser loginUser = SecurityUtils.getLoginUser();
// *========数据库日志=========*//
SysOperLog operLog = new SysOperLog();
@ -92,9 +75,6 @@ public class LogAspect
// 请求的地址
String ip = IpUtils.getIpAddr(ServletUtils.getRequest());
operLog.setOperIp(ip);
// 返回参数
operLog.setJsonResult(JSON.toJSONString(jsonResult));
operLog.setOperUrl(ServletUtils.getRequest().getRequestURI());
if (loginUser != null)
{
@ -113,7 +93,7 @@ public class LogAspect
// 设置请求方式
operLog.setRequestMethod(ServletUtils.getRequest().getMethod());
// 处理设置注解上的参数
getControllerMethodDescription(joinPoint, controllerLog, operLog);
getControllerMethodDescription(joinPoint, controllerLog, operLog, jsonResult);
// 保存数据库
AsyncManager.me().execute(AsyncFactory.recordOper(operLog));
}
@ -133,7 +113,7 @@ public class LogAspect
* @param operLog 操作日志
* @throws Exception
*/
public void getControllerMethodDescription(JoinPoint joinPoint, Log log, SysOperLog operLog) throws Exception
public void getControllerMethodDescription(JoinPoint joinPoint, Log log, SysOperLog operLog, Object jsonResult) throws Exception
{
// 设置action动作
operLog.setBusinessType(log.businessType().ordinal());
@ -147,6 +127,11 @@ public class LogAspect
// 获取参数的信息,传入到数据库中。
setRequestValue(joinPoint, operLog);
}
// 是否需要保存response参数和值
if (log.isSaveResponseData() && StringUtils.isNotNull(jsonResult))
{
operLog.setJsonResult(StringUtils.substring(JSON.toJSONString(jsonResult), 0, 2000));
}
}
/**
@ -170,22 +155,6 @@ public class LogAspect
}
}
/**
* 是否存在注解,如果存在就获取
*/
private Log getAnnotationLog(JoinPoint joinPoint) throws Exception
{
Signature signature = joinPoint.getSignature();
MethodSignature methodSignature = (MethodSignature) signature;
Method method = methodSignature.getMethod();
if (method != null)
{
return method.getAnnotation(Log.class);
}
return null;
}
/**
* 参数拼装
*/
@ -194,12 +163,18 @@ public class LogAspect
String params = "";
if (paramsArray != null && paramsArray.length > 0)
{
for (int i = 0; i < paramsArray.length; i++)
for (Object o : paramsArray)
{
if (!isFilterObject(paramsArray[i]))
if (StringUtils.isNotNull(o) && !isFilterObject(o))
{
Object jsonObj = JSON.toJSON(paramsArray[i]);
params += jsonObj.toString() + " ";
try
{
Object jsonObj = JSON.toJSON(o);
params += jsonObj.toString() + " ";
}
catch (Exception e)
{
}
}
}
}
@ -223,20 +198,21 @@ public class LogAspect
else if (Collection.class.isAssignableFrom(clazz))
{
Collection collection = (Collection) o;
for (Iterator iter = collection.iterator(); iter.hasNext();)
for (Object value : collection)
{
return iter.next() instanceof MultipartFile;
return value instanceof MultipartFile;
}
}
else if (Map.class.isAssignableFrom(clazz))
{
Map map = (Map) o;
for (Iterator iter = map.entrySet().iterator(); iter.hasNext();)
for (Object value : map.entrySet())
{
Map.Entry entry = (Map.Entry) iter.next();
Map.Entry entry = (Map.Entry) value;
return entry.getValue() instanceof MultipartFile;
}
}
return o instanceof MultipartFile || o instanceof HttpServletRequest || o instanceof HttpServletResponse;
return o instanceof MultipartFile || o instanceof HttpServletRequest || o instanceof HttpServletResponse
|| o instanceof BindingResult;
}
}

View File

@ -0,0 +1,91 @@
package com.ruoyi.framework.aspectj;
import java.lang.reflect.Method;
import java.util.Collections;
import java.util.List;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.reflect.MethodSignature;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.script.RedisScript;
import org.springframework.stereotype.Component;
import com.ruoyi.common.annotation.RateLimiter;
import com.ruoyi.common.enums.LimitType;
import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.common.utils.ServletUtils;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.ip.IpUtils;
/**
* 限流处理
*
* @author ruoyi
*/
@Aspect
@Component
public class RateLimiterAspect
{
private static final Logger log = LoggerFactory.getLogger(RateLimiterAspect.class);
private RedisTemplate<Object, Object> redisTemplate;
private RedisScript<Long> limitScript;
@Autowired
public void setRedisTemplate1(RedisTemplate<Object, Object> redisTemplate)
{
this.redisTemplate = redisTemplate;
}
@Autowired
public void setLimitScript(RedisScript<Long> limitScript)
{
this.limitScript = limitScript;
}
@Before("@annotation(rateLimiter)")
public void doBefore(JoinPoint point, RateLimiter rateLimiter) throws Throwable
{
String key = rateLimiter.key();
int time = rateLimiter.time();
int count = rateLimiter.count();
String combineKey = getCombineKey(rateLimiter, point);
List<Object> keys = Collections.singletonList(combineKey);
try
{
Long number = redisTemplate.execute(limitScript, keys, count, time);
if (StringUtils.isNull(number) || number.intValue() > count)
{
throw new ServiceException("访问过于频繁,请稍候再试");
}
log.info("限制请求'{}',当前请求'{}',缓存key'{}'", count, number.intValue(), key);
}
catch (ServiceException e)
{
throw e;
}
catch (Exception e)
{
throw new RuntimeException("服务器限流异常,请稍候再试");
}
}
public String getCombineKey(RateLimiter rateLimiter, JoinPoint point)
{
StringBuffer stringBuffer = new StringBuffer(rateLimiter.key());
if (rateLimiter.limitType() == LimitType.IP)
{
stringBuffer.append(IpUtils.getIpAddr(ServletUtils.getRequest())).append("-");
}
MethodSignature signature = (MethodSignature) point.getSignature();
Method method = signature.getMethod();
Class<?> targetClass = method.getDeclaringClass();
stringBuffer.append(targetClass.getName()).append("-").append(method.getName());
return stringBuffer.toString();
}
}

View File

@ -4,6 +4,7 @@ import java.util.HashMap;
import java.util.Map;
import javax.servlet.DispatcherType;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@ -19,9 +20,6 @@ import com.ruoyi.common.utils.StringUtils;
@Configuration
public class FilterConfig
{
@Value("${xss.enabled}")
private String enabled;
@Value("${xss.excludes}")
private String excludes;
@ -30,6 +28,7 @@ public class FilterConfig
@SuppressWarnings({ "rawtypes", "unchecked" })
@Bean
@ConditionalOnProperty(value = "xss.enabled", havingValue = "true")
public FilterRegistrationBean xssFilterRegistration()
{
FilterRegistrationBean registration = new FilterRegistrationBean();
@ -40,7 +39,6 @@ public class FilterConfig
registration.setOrder(FilterRegistrationBean.HIGHEST_PRECEDENCE);
Map<String, String> initParameters = new HashMap<String, String>();
initParameters.put("excludes", excludes);
initParameters.put("enabled", enabled);
registration.setInitParameters(initParameters);
return registration;
}

View File

@ -6,6 +6,7 @@ import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.script.DefaultRedisScript;
import org.springframework.data.redis.serializer.StringRedisSerializer;
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
@ -36,10 +37,43 @@ public class RedisConfig extends CachingConfigurerSupport
mapper.activateDefaultTyping(LaissezFaireSubTypeValidator.instance, ObjectMapper.DefaultTyping.NON_FINAL, JsonTypeInfo.As.PROPERTY);
serializer.setObjectMapper(mapper);
template.setValueSerializer(serializer);
// 使用StringRedisSerializer来序列化和反序列化redis的key值
template.setKeySerializer(new StringRedisSerializer());
template.setValueSerializer(serializer);
// Hash的key也采用StringRedisSerializer的序列化方式
template.setHashKeySerializer(new StringRedisSerializer());
template.setHashValueSerializer(serializer);
template.afterPropertiesSet();
return template;
}
@Bean
public DefaultRedisScript<Long> limitScript()
{
DefaultRedisScript<Long> redisScript = new DefaultRedisScript<>();
redisScript.setScriptText(limitScriptText());
redisScript.setResultType(Long.class);
return redisScript;
}
/**
* 限流脚本
*/
private String limitScriptText()
{
return "local key = KEYS[1]\n" +
"local count = tonumber(ARGV[1])\n" +
"local time = tonumber(ARGV[2])\n" +
"local current = redis.call('get', key);\n" +
"if current and tonumber(current) > count then\n" +
" return tonumber(current);\n" +
"end\n" +
"current = redis.call('incr', key)\n" +
"if tonumber(current) == 1 then\n" +
" redis.call('expire', key, time)\n" +
"end\n" +
"return tonumber(current);";
}
}

View File

@ -28,11 +28,12 @@ public class ResourcesConfig implements WebMvcConfigurer
public void addResourceHandlers(ResourceHandlerRegistry registry)
{
/** 本地文件上传路径 */
registry.addResourceHandler(Constants.RESOURCE_PREFIX + "/**").addResourceLocations("file:" + RuoYiConfig.getProfile() + "/");
registry.addResourceHandler(Constants.RESOURCE_PREFIX + "/**")
.addResourceLocations("file:" + RuoYiConfig.getProfile() + "/");
/** swagger配置 */
registry.addResourceHandler("swagger-ui.html").addResourceLocations("classpath:/META-INF/resources/");
registry.addResourceHandler("/webjars/**").addResourceLocations("classpath:/META-INF/resources/webjars/");
registry.addResourceHandler("/swagger-ui/**")
.addResourceLocations("classpath:/META-INF/resources/webjars/springfox-swagger-ui/");
}
/**
@ -50,17 +51,20 @@ public class ResourcesConfig implements WebMvcConfigurer
@Bean
public CorsFilter corsFilter()
{
UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
CorsConfiguration config = new CorsConfiguration();
config.setAllowCredentials(true);
// 设置访问源地址
config.addAllowedOrigin("*");
config.addAllowedOriginPattern("*");
// 设置访问源请求头
config.addAllowedHeader("*");
// 设置访问源请求方法
config.addAllowedMethod("*");
// 对接口配置跨域设置
// 有效期 1800秒
config.setMaxAge(1800L);
// 添加映射路径,拦截一切请求
UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
source.registerCorsConfiguration("/**", config);
// 返回新的CorsFilter
return new CorsFilter(source);
}
}

View File

@ -49,7 +49,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter
*/
@Autowired
private JwtAuthenticationTokenFilter authenticationTokenFilter;
/**
* 跨域过滤器
*/
@ -96,18 +96,17 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter
.sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS).and()
// 过滤请求
.authorizeRequests()
// 对于登录login 验证码captchaImage 允许匿名访问
.antMatchers("/login", "/captchaImage").anonymous()
// 对于登录login 注册register 验证码captchaImage 允许匿名访问
.antMatchers("/login", "/register", "/captchaImage").anonymous()
.antMatchers(
HttpMethod.GET,
"/",
"/*.html",
"/**/*.html",
"/**/*.css",
"/**/*.js"
"/**/*.js",
"/profile/**"
).permitAll()
.antMatchers("/profile/**").anonymous()
.antMatchers("/common/download**").anonymous()
.antMatchers("/common/download/resource**").anonymous()
.antMatchers("/swagger-ui.html").anonymous()
.antMatchers("/swagger-resources/**").anonymous()
.antMatchers("/webjars/**").anonymous()
@ -125,7 +124,6 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter
httpSecurity.addFilterBefore(corsFilter, LogoutFilter.class);
}
/**
* 强散列哈希加密实现
*/

View File

@ -5,7 +5,7 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.stereotype.Component;
import org.springframework.web.method.HandlerMethod;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
import org.springframework.web.servlet.HandlerInterceptor;
import com.alibaba.fastjson.JSONObject;
import com.ruoyi.common.annotation.RepeatSubmit;
import com.ruoyi.common.core.domain.AjaxResult;
@ -17,7 +17,7 @@ import com.ruoyi.common.utils.ServletUtils;
* @author ruoyi
*/
@Component
public abstract class RepeatSubmitInterceptor extends HandlerInterceptorAdapter
public abstract class RepeatSubmitInterceptor implements HandlerInterceptor
{
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception
@ -29,9 +29,9 @@ public abstract class RepeatSubmitInterceptor extends HandlerInterceptorAdapter
RepeatSubmit annotation = method.getAnnotation(RepeatSubmit.class);
if (annotation != null)
{
if (this.isRepeatSubmit(request))
if (this.isRepeatSubmit(request, annotation))
{
AjaxResult ajaxResult = AjaxResult.error("不允许重复提交,请稍后再试");
AjaxResult ajaxResult = AjaxResult.error(annotation.message());
ServletUtils.renderString(response, JSONObject.toJSONString(ajaxResult));
return false;
}
@ -40,7 +40,7 @@ public abstract class RepeatSubmitInterceptor extends HandlerInterceptorAdapter
}
else
{
return super.preHandle(request, response, handler);
return true;
}
}
@ -51,5 +51,5 @@ public abstract class RepeatSubmitInterceptor extends HandlerInterceptorAdapter
* @return
* @throws Exception
*/
public abstract boolean isRepeatSubmit(HttpServletRequest request);
public abstract boolean isRepeatSubmit(HttpServletRequest request, RepeatSubmit annotation);
}

View File

@ -8,6 +8,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import com.alibaba.fastjson.JSONObject;
import com.ruoyi.common.annotation.RepeatSubmit;
import com.ruoyi.common.constant.Constants;
import com.ruoyi.common.core.redis.RedisCache;
import com.ruoyi.common.filter.RepeatedlyRequestWrapper;
@ -35,21 +36,9 @@ public class SameUrlDataInterceptor extends RepeatSubmitInterceptor
@Autowired
private RedisCache redisCache;
/**
* 间隔时间,单位:秒 默认10秒
*
* 两次相同参数的请求,如果间隔时间大于该参数,系统不会认定为重复提交的数据
*/
private int intervalTime = 10;
public void setIntervalTime(int intervalTime)
{
this.intervalTime = intervalTime;
}
@SuppressWarnings("unchecked")
@Override
public boolean isRepeatSubmit(HttpServletRequest request)
public boolean isRepeatSubmit(HttpServletRequest request, RepeatSubmit annotation)
{
String nowParams = "";
if (request instanceof RepeatedlyRequestWrapper)
@ -71,23 +60,19 @@ public class SameUrlDataInterceptor extends RepeatSubmitInterceptor
String url = request.getRequestURI();
// 唯一值(没有消息头则使用请求地址)
String submitKey = request.getHeader(header);
if (StringUtils.isEmpty(submitKey))
{
submitKey = url;
}
String submitKey = StringUtils.trimToEmpty(request.getHeader(header));
// 唯一标识指定key + 消息头)
String cache_repeat_key = Constants.REPEAT_SUBMIT_KEY + submitKey;
// 唯一标识指定key + url + 消息头)
String cacheRepeatKey = Constants.REPEAT_SUBMIT_KEY + url + submitKey;
Object sessionObj = redisCache.getCacheObject(cache_repeat_key);
Object sessionObj = redisCache.getCacheObject(cacheRepeatKey);
if (sessionObj != null)
{
Map<String, Object> sessionMap = (Map<String, Object>) sessionObj;
if (sessionMap.containsKey(url))
{
Map<String, Object> preDataMap = (Map<String, Object>) sessionMap.get(url);
if (compareParams(nowDataMap, preDataMap) && compareTime(nowDataMap, preDataMap))
if (compareParams(nowDataMap, preDataMap) && compareTime(nowDataMap, preDataMap, annotation.interval()))
{
return true;
}
@ -95,7 +80,7 @@ public class SameUrlDataInterceptor extends RepeatSubmitInterceptor
}
Map<String, Object> cacheMap = new HashMap<String, Object>();
cacheMap.put(url, nowDataMap);
redisCache.setCacheObject(cache_repeat_key, cacheMap, intervalTime, TimeUnit.SECONDS);
redisCache.setCacheObject(cacheRepeatKey, cacheMap, annotation.interval(), TimeUnit.MILLISECONDS);
return false;
}
@ -112,11 +97,11 @@ public class SameUrlDataInterceptor extends RepeatSubmitInterceptor
/**
* 判断两次间隔时间
*/
private boolean compareTime(Map<String, Object> nowMap, Map<String, Object> preMap)
private boolean compareTime(Map<String, Object> nowMap, Map<String, Object> preMap, int interval)
{
long time1 = (Long) nowMap.get(REPEAT_TIME);
long time2 = (Long) preMap.get(REPEAT_TIME);
if ((time1 - time2) < (this.intervalTime * 1000))
if ((time1 - time2) < interval)
{
return true;
}

View File

@ -6,6 +6,7 @@ import org.slf4j.LoggerFactory;
import com.ruoyi.common.constant.Constants;
import com.ruoyi.common.utils.LogUtils;
import com.ruoyi.common.utils.ServletUtils;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.ip.AddressUtils;
import com.ruoyi.common.utils.ip.IpUtils;
import com.ruoyi.common.utils.spring.SpringUtils;
@ -65,7 +66,7 @@ public class AsyncFactory
logininfor.setOs(os);
logininfor.setMsg(message);
// 日志状态
if (Constants.LOGIN_SUCCESS.equals(status) || Constants.LOGOUT.equals(status))
if (StringUtils.equalsAny(status, Constants.LOGIN_SUCCESS, Constants.LOGOUT, Constants.REGISTER))
{
logininfor.setStatus(Constants.SUCCESS);
}

View File

@ -1,20 +1,18 @@
package com.ruoyi.framework.web.exception;
import javax.servlet.http.HttpServletRequest;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.security.access.AccessDeniedException;
import org.springframework.security.authentication.AccountExpiredException;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.validation.BindException;
import org.springframework.web.HttpRequestMethodNotSupportedException;
import org.springframework.web.bind.MethodArgumentNotValidException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;
import org.springframework.web.servlet.NoHandlerFoundException;
import com.ruoyi.common.constant.HttpStatus;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.exception.BaseException;
import com.ruoyi.common.exception.CustomException;
import com.ruoyi.common.exception.DemoModeException;
import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.common.utils.StringUtils;
/**
@ -28,59 +26,58 @@ public class GlobalExceptionHandler
private static final Logger log = LoggerFactory.getLogger(GlobalExceptionHandler.class);
/**
* 基础异常
* 权限校验异常
*/
@ExceptionHandler(BaseException.class)
public AjaxResult baseException(BaseException e)
@ExceptionHandler(AccessDeniedException.class)
public AjaxResult handleAccessDeniedException(AccessDeniedException e, HttpServletRequest request)
{
String requestURI = request.getRequestURI();
log.error("请求地址'{}',权限校验失败'{}'", requestURI, e.getMessage());
return AjaxResult.error(HttpStatus.FORBIDDEN, "没有权限,请联系管理员授权");
}
/**
* 请求方式不支持
*/
@ExceptionHandler(HttpRequestMethodNotSupportedException.class)
public AjaxResult handleHttpRequestMethodNotSupported(HttpRequestMethodNotSupportedException e,
HttpServletRequest request)
{
String requestURI = request.getRequestURI();
log.error("请求地址'{}',不支持'{}'请求", requestURI, e.getMethod());
return AjaxResult.error(e.getMessage());
}
/**
* 业务异常
*/
@ExceptionHandler(CustomException.class)
public AjaxResult businessException(CustomException e)
{
if (StringUtils.isNull(e.getCode()))
{
return AjaxResult.error(e.getMessage());
}
return AjaxResult.error(e.getCode(), e.getMessage());
}
@ExceptionHandler(NoHandlerFoundException.class)
public AjaxResult handlerNoFoundException(Exception e)
@ExceptionHandler(ServiceException.class)
public AjaxResult handleServiceException(ServiceException e, HttpServletRequest request)
{
log.error(e.getMessage(), e);
return AjaxResult.error(HttpStatus.NOT_FOUND, "路径不存在,请检查路径是否正确");
Integer code = e.getCode();
return StringUtils.isNotNull(code) ? AjaxResult.error(code, e.getMessage()) : AjaxResult.error(e.getMessage());
}
@ExceptionHandler(AccessDeniedException.class)
public AjaxResult handleAuthorizationException(AccessDeniedException e)
/**
* 拦截未知的运行时异常
*/
@ExceptionHandler(RuntimeException.class)
public AjaxResult handleRuntimeException(RuntimeException e, HttpServletRequest request)
{
log.error(e.getMessage());
return AjaxResult.error(HttpStatus.FORBIDDEN, "没有权限,请联系管理员授权");
}
@ExceptionHandler(AccountExpiredException.class)
public AjaxResult handleAccountExpiredException(AccountExpiredException e)
{
log.error(e.getMessage(), e);
return AjaxResult.error(e.getMessage());
}
@ExceptionHandler(UsernameNotFoundException.class)
public AjaxResult handleUsernameNotFoundException(UsernameNotFoundException e)
{
log.error(e.getMessage(), e);
String requestURI = request.getRequestURI();
log.error("请求地址'{}',发生未知异常.", requestURI, e);
return AjaxResult.error(e.getMessage());
}
/**
* 系统异常
*/
@ExceptionHandler(Exception.class)
public AjaxResult handleException(Exception e)
public AjaxResult handleException(Exception e, HttpServletRequest request)
{
log.error(e.getMessage(), e);
String requestURI = request.getRequestURI();
log.error("请求地址'{}',发生系统异常.", requestURI, e);
return AjaxResult.error(e.getMessage());
}
@ -88,7 +85,7 @@ public class GlobalExceptionHandler
* 自定义验证异常
*/
@ExceptionHandler(BindException.class)
public AjaxResult validatedBindException(BindException e)
public AjaxResult handleBindException(BindException e)
{
log.error(e.getMessage(), e);
String message = e.getAllErrors().get(0).getDefaultMessage();
@ -99,7 +96,7 @@ public class GlobalExceptionHandler
* 自定义验证异常
*/
@ExceptionHandler(MethodArgumentNotValidException.class)
public Object validExceptionHandler(MethodArgumentNotValidException e)
public Object handleMethodArgumentNotValidException(MethodArgumentNotValidException e)
{
log.error(e.getMessage(), e);
String message = e.getBindingResult().getFieldError().getDefaultMessage();
@ -110,7 +107,7 @@ public class GlobalExceptionHandler
* 演示模式异常
*/
@ExceptionHandler(DemoModeException.class)
public AjaxResult demoModeException(DemoModeException e)
public AjaxResult handleDemoModeException(DemoModeException e)
{
return AjaxResult.error("演示模式,不允许操作");
}

View File

@ -1,12 +1,11 @@
package com.ruoyi.framework.web.service;
import java.util.Set;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import com.ruoyi.common.core.domain.entity.SysRole;
import com.ruoyi.common.core.domain.model.LoginUser;
import com.ruoyi.common.utils.ServletUtils;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.StringUtils;
/**
@ -27,9 +26,6 @@ public class PermissionService
private static final String PERMISSION_DELIMETER = ",";
@Autowired
private TokenService tokenService;
/**
* 验证用户是否具备某权限
*
@ -42,7 +38,7 @@ public class PermissionService
{
return false;
}
LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
LoginUser loginUser = SecurityUtils.getLoginUser();
if (StringUtils.isNull(loginUser) || CollectionUtils.isEmpty(loginUser.getPermissions()))
{
return false;
@ -73,7 +69,7 @@ public class PermissionService
{
return false;
}
LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
LoginUser loginUser = SecurityUtils.getLoginUser();
if (StringUtils.isNull(loginUser) || CollectionUtils.isEmpty(loginUser.getPermissions()))
{
return false;
@ -101,7 +97,7 @@ public class PermissionService
{
return false;
}
LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
LoginUser loginUser = SecurityUtils.getLoginUser();
if (StringUtils.isNull(loginUser) || CollectionUtils.isEmpty(loginUser.getUser().getRoles()))
{
return false;
@ -140,7 +136,7 @@ public class PermissionService
{
return false;
}
LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
LoginUser loginUser = SecurityUtils.getLoginUser();
if (StringUtils.isNull(loginUser) || CollectionUtils.isEmpty(loginUser.getUser().getRoles()))
{
return false;

View File

@ -8,15 +8,21 @@ import org.springframework.security.authentication.UsernamePasswordAuthenticatio
import org.springframework.security.core.Authentication;
import org.springframework.stereotype.Component;
import com.ruoyi.common.constant.Constants;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.core.domain.model.LoginUser;
import com.ruoyi.common.core.redis.RedisCache;
import com.ruoyi.common.exception.CustomException;
import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.common.exception.user.CaptchaException;
import com.ruoyi.common.exception.user.CaptchaExpireException;
import com.ruoyi.common.exception.user.UserPasswordNotMatchException;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.MessageUtils;
import com.ruoyi.common.utils.ServletUtils;
import com.ruoyi.common.utils.ip.IpUtils;
import com.ruoyi.framework.manager.AsyncManager;
import com.ruoyi.framework.manager.factory.AsyncFactory;
import com.ruoyi.system.service.ISysConfigService;
import com.ruoyi.system.service.ISysUserService;
/**
* 登录校验方法
@ -34,6 +40,12 @@ public class SysLoginService
@Autowired
private RedisCache redisCache;
@Autowired
private ISysUserService userService;
@Autowired
private ISysConfigService configService;
/**
* 登录验证
@ -46,18 +58,11 @@ public class SysLoginService
*/
public String login(String username, String password, String code, String uuid)
{
String verifyKey = Constants.CAPTCHA_CODE_KEY + uuid;
String captcha = redisCache.getCacheObject(verifyKey);
redisCache.deleteObject(verifyKey);
if (captcha == null)
boolean captchaOnOff = configService.selectCaptchaOnOff();
// 验证码开关
if (captchaOnOff)
{
AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_FAIL, MessageUtils.message("user.jcaptcha.expire")));
throw new CaptchaExpireException();
}
if (!code.equalsIgnoreCase(captcha))
{
AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_FAIL, MessageUtils.message("user.jcaptcha.error")));
throw new CaptchaException();
validateCaptcha(username, code, uuid);
}
// 用户验证
Authentication authentication = null;
@ -77,12 +82,52 @@ public class SysLoginService
else
{
AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_FAIL, e.getMessage()));
throw new CustomException(e.getMessage());
throw new ServiceException(e.getMessage());
}
}
AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_SUCCESS, MessageUtils.message("user.login.success")));
LoginUser loginUser = (LoginUser) authentication.getPrincipal();
recordLoginInfo(loginUser.getUserId());
// 生成token
return tokenService.createToken(loginUser);
}
/**
* 校验验证码
*
* @param username 用户名
* @param code 验证码
* @param uuid 唯一标识
* @return 结果
*/
public void validateCaptcha(String username, String code, String uuid)
{
String verifyKey = Constants.CAPTCHA_CODE_KEY + uuid;
String captcha = redisCache.getCacheObject(verifyKey);
redisCache.deleteObject(verifyKey);
if (captcha == null)
{
AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_FAIL, MessageUtils.message("user.jcaptcha.expire")));
throw new CaptchaExpireException();
}
if (!code.equalsIgnoreCase(captcha))
{
AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_FAIL, MessageUtils.message("user.jcaptcha.error")));
throw new CaptchaException();
}
}
/**
* 记录登录信息
*
* @param userId 用户ID
*/
public void recordLoginInfo(Long userId)
{
SysUser sysUser = new SysUser();
sysUser.setUserId(userId);
sysUser.setLoginIp(IpUtils.getIpAddr(ServletUtils.getRequest()));
sysUser.setLoginDate(DateUtils.getNowDate());
userService.updateUserProfile(sysUser);
}
}

View File

@ -0,0 +1,115 @@
package com.ruoyi.framework.web.service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import com.ruoyi.common.constant.Constants;
import com.ruoyi.common.constant.UserConstants;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.core.domain.model.RegisterBody;
import com.ruoyi.common.core.redis.RedisCache;
import com.ruoyi.common.exception.user.CaptchaException;
import com.ruoyi.common.exception.user.CaptchaExpireException;
import com.ruoyi.common.utils.MessageUtils;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.framework.manager.AsyncManager;
import com.ruoyi.framework.manager.factory.AsyncFactory;
import com.ruoyi.system.service.ISysConfigService;
import com.ruoyi.system.service.ISysUserService;
/**
* 注册校验方法
*
* @author ruoyi
*/
@Component
public class SysRegisterService
{
@Autowired
private ISysUserService userService;
@Autowired
private ISysConfigService configService;
@Autowired
private RedisCache redisCache;
/**
* 注册
*/
public String register(RegisterBody registerBody)
{
String msg = "", username = registerBody.getUsername(), password = registerBody.getPassword();
boolean captchaOnOff = configService.selectCaptchaOnOff();
// 验证码开关
if (captchaOnOff)
{
validateCaptcha(username, registerBody.getCode(), registerBody.getUuid());
}
if (StringUtils.isEmpty(username))
{
msg = "用户名不能为空";
}
else if (StringUtils.isEmpty(password))
{
msg = "用户密码不能为空";
}
else if (username.length() < UserConstants.USERNAME_MIN_LENGTH
|| username.length() > UserConstants.USERNAME_MAX_LENGTH)
{
msg = "账户长度必须在2到20个字符之间";
}
else if (password.length() < UserConstants.PASSWORD_MIN_LENGTH
|| password.length() > UserConstants.PASSWORD_MAX_LENGTH)
{
msg = "密码长度必须在5到20个字符之间";
}
else if (UserConstants.NOT_UNIQUE.equals(userService.checkUserNameUnique(username)))
{
msg = "保存用户'" + username + "'失败,注册账号已存在";
}
else
{
SysUser sysUser = new SysUser();
sysUser.setUserName(username);
sysUser.setNickName(username);
sysUser.setPassword(SecurityUtils.encryptPassword(registerBody.getPassword()));
boolean regFlag = userService.registerUser(sysUser);
if (!regFlag)
{
msg = "注册失败,请联系系统管理人员";
}
else
{
AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.REGISTER,
MessageUtils.message("user.register.success")));
}
}
return msg;
}
/**
* 校验验证码
*
* @param username 用户名
* @param code 验证码
* @param uuid 唯一标识
* @return 结果
*/
public void validateCaptcha(String username, String code, String uuid)
{
String verifyKey = Constants.CAPTCHA_CODE_KEY + uuid;
String captcha = redisCache.getCacheObject(verifyKey);
redisCache.deleteObject(verifyKey);
if (captcha == null)
{
throw new CaptchaExpireException();
}
if (!code.equalsIgnoreCase(captcha))
{
throw new CaptchaException();
}
}
}

View File

@ -60,12 +60,18 @@ public class TokenService
String token = getToken(request);
if (StringUtils.isNotEmpty(token))
{
Claims claims = parseToken(token);
// 解析对应的权限以及用户信息
String uuid = (String) claims.get(Constants.LOGIN_USER_KEY);
String userKey = getTokenKey(uuid);
LoginUser user = redisCache.getCacheObject(userKey);
return user;
try
{
Claims claims = parseToken(token);
// 解析对应的权限以及用户信息
String uuid = (String) claims.get(Constants.LOGIN_USER_KEY);
String userKey = getTokenKey(uuid);
LoginUser user = redisCache.getCacheObject(userKey);
return user;
}
catch (Exception e)
{
}
}
return null;
}

View File

@ -10,7 +10,7 @@ import org.springframework.stereotype.Service;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.core.domain.model.LoginUser;
import com.ruoyi.common.enums.UserStatus;
import com.ruoyi.common.exception.BaseException;
import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.system.service.ISysUserService;
@ -37,17 +37,17 @@ public class UserDetailsServiceImpl implements UserDetailsService
if (StringUtils.isNull(user))
{
log.info("登录用户:{} 不存在.", username);
throw new UsernameNotFoundException("登录用户:" + username + " 不存在");
throw new ServiceException("登录用户:" + username + " 不存在");
}
else if (UserStatus.DELETED.getCode().equals(user.getDelFlag()))
{
log.info("登录用户:{} 已被删除.", username);
throw new BaseException("对不起,您的账号:" + username + " 已被删除");
throw new ServiceException("对不起,您的账号:" + username + " 已被删除");
}
else if (UserStatus.DISABLE.getCode().equals(user.getStatus()))
{
log.info("登录用户:{} 已被停用.", username);
throw new BaseException("对不起,您的账号:" + username + " 已停用");
throw new ServiceException("对不起,您的账号:" + username + " 已停用");
}
return createLoginUser(user);
@ -55,6 +55,6 @@ public class UserDetailsServiceImpl implements UserDetailsService
public UserDetails createLoginUser(SysUser user)
{
return new LoginUser(user, permissionService.getMenuPermission(user));
return new LoginUser(user.getUserId(), user.getDeptId(), user, permissionService.getMenuPermission(user));
}
}

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>ruoyi</artifactId>
<groupId>com.ruoyi</groupId>
<version>3.4.0</version>
<version>3.8.1</version>
</parent>
<modelVersion>4.0.0</modelVersion>
@ -20,7 +20,13 @@
<!--velocity代码生成使用模板 -->
<dependency>
<groupId>org.apache.velocity</groupId>
<artifactId>velocity</artifactId>
<artifactId>velocity-engine-core</artifactId>
</dependency>
<!-- collections工具类 -->
<dependency>
<groupId>commons-collections</groupId>
<artifactId>commons-collections</artifactId>
</dependency>
<!-- 通用工具-->

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