280 Commits

Author SHA1 Message Date
d98acffe4e Merge remote-tracking branch 'origin/dev'
# Conflicts:
#	ruoyi-ui/package.json
2021-12-28 10:37:00 +08:00
ed659da488 发布 v3.5.0-release 正式版 2021-12-28 10:35:52 +08:00
a8227453fc update hutool 5.7.17 => 5.7.18 bugfix
update redisson 3.16.6 => 3.16.7 bugfix
2021-12-27 11:43:59 +08:00
225eda7176 update 更新 Sa-Token 文档说明与连接 2021-12-27 11:06:12 +08:00
295cd3670f Merge branch 'master' of https://gitee.com/y_project/RuoYi-Vue into dev
 Conflicts:
	pom.xml
	ruoyi-generator/src/main/java/com/ruoyi/generator/util/VelocityUtils.java
2021-12-27 09:30:12 +08:00
e4df0c6da1 优化代码生成字典组重复问题 2021-12-24 14:51:33 +08:00
2a421deaa3 update 更改项目介绍 2021-12-24 12:39:13 +08:00
7b23b6db6f 升级oshi到最新版本v5.8.6 2021-12-24 12:00:29 +08:00
5ca038d888 update 调整监控依赖 从 common 迁移到 framework 2021-12-24 11:36:02 +08:00
3454e34c7c update 更新 文档 satoken 说明 2021-12-22 13:23:21 +08:00
619a80228f update springboot 2.5.7 => 2.5.8 升级预防 log4j2 问题
update springboot-admin 2.5.4 => 2.5.5
update hutool 5.7.16 => 5.7.17
2021-12-22 10:22:00 +08:00
89de1beb6f update 优化web拦截器 使用原生接口处理 默认非生产环境开启 2021-12-22 10:19:57 +08:00
b6442b4640 Merge remote-tracking branch 'ruoyi-vue/master' into dev
# Conflicts:
#	pom.xml
#	ruoyi-common/src/main/java/com/ruoyi/common/utils/sql/SqlUtil.java
2021-12-22 10:10: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
4c99cea3e4 update 更新批处理演示案例注释说明 2021-12-21 11:18:03 +08:00
1d54ef57c7 update 更新 nginx 配置文件关于 https 可能遇到的问题与解决方案说明 2021-12-21 10:54:57 +08:00
673b225da2 Merge remote-tracking branch 'ruoyi-vue/master' into dev
# Conflicts:
#	ruoyi-ui/vue.config.js
2021-12-20 14:34:05 +08:00
c3fe137720 Merge remote-tracking branch 'ruoyi-vue/master' into dev
# Conflicts:
#	ruoyi-ui/package.json
#	ruoyi-ui/vue.config.js
2021-12-20 14:32:21 +08:00
c28aa299bd 新增使用Gzip解压缩静态文件地址 2021-12-20 14:25:52 +08:00
b2189ae965 集成compression-webpack-plugin插件实现打包Gzip压缩 2021-12-20 10:00:26 +08:00
a3504dac6e Merge branch 'master' of https://gitee.com/y_project/RuoYi-Vue into dev
 Conflicts:
	pom.xml
	ruoyi-common/src/main/java/com/ruoyi/common/core/controller/BaseController.java
	ruoyi-common/src/main/java/com/ruoyi/common/utils/PageUtils.java
	ruoyi-ui/package.json
	ruoyi-ui/src/main.js
	ruoyi-ui/src/router/index.js
	ruoyi-ui/src/store/modules/permission.js
	ruoyi-ui/vue.config.js
2021-12-20 09:47:56 +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
08f4ae04e1 update 更新 jdbc 配置参考博客地址 2021-12-19 02:05:31 +08:00
83d69ba507 add [重磅更新] 增加 jdbc 批处理参数 大幅提升批量操作性能 对原生语句与 MP 均有效 2021-12-18 22:59:55 +08:00
63cb34b563 update 优化 pr 调整导包位置 2021-12-18 18:34:23 +08:00
271e42176c !126 自动生成代码未引入此依赖 import com.baomidou.mybatisplus.extension.plugins.pag
Merge pull request !126 from 抓蛙师/auto-7465549-dev-1639814849312
2021-12-18 10:19:34 +00:00
e5647793ce 路由支持单独配置菜单或角色权限 2021-12-18 16:48:31 +08:00
b87e45ce32 自动生成代码未引入此依赖
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
2021-12-18 16:07:24 +08:00
903b5aebca 新增图片预览组件 2021-12-18 12:23:59 +08:00
7492dcc9e6 请求分页方法设置成通用方便灵活调用 2021-12-18 12:22:41 +08:00
5d2b162bea add 增加 DataPermissionHelper 类 便于操作数据权限变量 2021-12-17 21:52:11 +08:00
3fce90dbb9 update 优化数据权限缓存合并为一个 标注版本注释 2021-12-17 21:50:14 +08:00
d40b9324ca add oss下载增加 loading 层 2021-12-17 17:53:19 +08:00
6875935d37 fix 修复 集群雪花id重复问题 使用网卡信息绑定生成 2021-12-17 13:47:24 +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
3546ac2854 fix 修复 redisson 集群模式 路径未匹配协议头问题 2021-12-16 15:37:31 +08:00
d600cdd8a0 add 代码生成增加 vue3 页面模板 2021-12-16 15:09:35 +08:00
d2c6e27d07 Merge branch 'master' of https://gitee.com/y_project/RuoYi-Vue into dev
 Conflicts:
	ruoyi-ui/src/views/system/user/index.vue
2021-12-16 14:21:04 +08:00
8041ced02d update 数据权限增加全局缓存 提高处理性能 减少重复处理 2021-12-16 13:58:52 +08:00
d81056cbe7 update 修改 缓存懒加载 为 false 默认启动预加载数据 2021-12-16 13:55:14 +08:00
44e8a012e2 update 去除 jdk17 标签 由于很多组件还未适配 导致一些问题 2021-12-16 12:10:42 +08:00
30483dacfb update 回滚错误修改 2021-12-16 11:52:55 +08:00
9d81d95700 update 代码生成 数据库功能使用 mapper 操作 规范用法避免滥用 2021-12-16 11:45:58 +08:00
e6b45d4cdb update 数据权限注解支持类标注 2021-12-16 10:54:44 +08:00
c2e28b5d94 update 修改 基础方法返回空判断 优化返回值 2021-12-16 10:54:26 +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
ffde310d30 update qiniu 7.8.0 => 7.9.0
update minio 8.3.3 => 8.3.4
2021-12-16 00:13:04 +08:00
44bc7dd9a5 update 修改已过期方法 调整编译警告 2021-12-16 00:11:38 +08:00
9e5b64e1b7 Merge remote-tracking branch 'origin/dev' into dev 2021-12-15 23:33:57 +08:00
2599073f56 fix 修复数据权限 兜底sql处理逻辑问题 2021-12-15 23:33:51 +08:00
a2d49f9981 update 更改演示案例多数据源注解 2021-12-15 17:28:41 +08:00
877a9d510b update tlog 1.3.5 => 1.3.6 修复 jdk17 不兼容问题 2021-12-15 15:33:31 +08:00
2455d0b859 add 增加 自定义 Xss 校验注解 用户导入增加 Bean 校验 2021-12-15 15:03:44 +08:00
b3c3afc2b4 Merge branch 'master' of https://gitee.com/y_project/RuoYi-Vue into dev
 Conflicts:
	pom.xml
	ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/SysUser.java
	ruoyi-system/src/main/java/com/ruoyi/system/domain/SysNotice.java
	ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java
2021-12-15 14:12:36 +08:00
3f97d19381 update [重磅更新] 重构分页 简化使用 2021-12-15 13:29:54 +08:00
3ab3d49055 update 清除警告 2021-12-15 13:23:16 +08:00
bd89cc0287 update ServicePlusImpl 功能 下沉到 BaseMapperPlus 2021-12-15 12:17:04 +08:00
d365a52cd6 自定义xss校验注解实现 2021-12-15 10:50:10 +08:00
5e38e054a7 update hutool 工具 改为单包引入 减少无用依赖 2021-12-15 10:44:50 +08:00
317f6d5c87 fix 修复代码生成 sql异常 屏蔽代码生成数据权限过滤 2021-12-14 23:47:59 +08:00
c876776a25 update 更正包名书写错误 2021-12-14 18:00:38 +08:00
e1c7115d8c 升级log4j2到安全版本,防止漏洞风险 2021-12-14 12:09:57 +08:00
bb4d75aff0 升级log4j2到安全版本,防止漏洞风险 2021-12-14 10:33:25 +08:00
c5dbd04c9c fix 修复数据权限 仅自己 相关问题 2021-12-14 10:11:16 +08:00
2a8a72a085 add 新增 Vue3 分支(由于组件还未完善 仅供学习) 2021-12-13 20:33:31 +08:00
29c46a15f9 Merge branch 'master' of https://gitee.com/y_project/RuoYi-Vue into dev
 Conflicts:
	README.md
	pom.xml
	ruoyi-admin/pom.xml
	ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysProfileController.java
	ruoyi-admin/src/main/resources/application.yml
	ruoyi-common/pom.xml
	ruoyi-framework/pom.xml
	ruoyi-generator/pom.xml
	ruoyi-job/pom.xml
	ruoyi-quartz/src/main/java/com/ruoyi/quartz/util/JobInvokeUtil.java
	ruoyi-system/pom.xml
	ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysDeptMapper.java
	ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysMenuMapper.java
	ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysPostMapper.java
	ruoyi-system/src/main/java/com/ruoyi/system/service/ISysDeptService.java
	ruoyi-system/src/main/java/com/ruoyi/system/service/ISysMenuService.java
	ruoyi-system/src/main/java/com/ruoyi/system/service/ISysPostService.java
	ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDeptServiceImpl.java
	ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysMenuServiceImpl.java
	ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysPostServiceImpl.java
	ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java
	ruoyi-system/src/main/resources/mapper/system/SysDeptMapper.xml
	ruoyi-system/src/main/resources/mapper/system/SysMenuMapper.xml
	ruoyi-system/src/main/resources/mapper/system/SysPostMapper.xml
	ruoyi-ui/package.json
	ruoyi-ui/src/directive/index.js
	ruoyi-ui/src/plugins/download.js
	ruoyi-ui/src/views/index.vue
	ruoyi-ui/src/views/monitor/online/index.vue
	ruoyi-ui/src/views/system/user/authRole.vue
	ruoyi-ui/src/views/system/user/index.vue
	ruoyi-ui/src/views/tool/gen/basicInfoForm.vue
	ruoyi-ui/src/views/tool/gen/genInfoForm.vue
2021-12-13 12:37:36 +08:00
aae3fe5305 update [重大更新] 重写数据权限实现 2021-12-13 03:49:05 +00:00
2743785aaf 修复多参数逗号分隔的问题 2021-12-13 10:11:34 +08:00
4d92ef22c3 fix 修复代码生成 导出注解错误 2021-12-13 10:03:29 +08:00
79fc16eeb7 fix 修复代码生成 导出注解错误 2021-12-13 10:02:32 +08:00
2a235917dc 优化下载解析blob异常提示 2021-12-10 10:03:25 +08:00
8a5c8d0db5 update 补全缺失导包 2021-12-09 11:52:27 +08:00
bcd5b713f8 fix 修复 SysOssConfig 主键类型错误 2021-12-09 11:50:34 +08:00
a9488ba3c9 update 多数据源切换标注过期 3.6.0 移除 推荐使用原生注解 2021-12-09 11:50:25 +08:00
be13e3494a update redisson 3.16.4 => 3.16.6
update dynamic-ds 3.4.1 => 3.5.0
2021-12-09 11:49:00 +08:00
a62d65a9b8 fix 修复 TreeBuildUtils 顶节点不为 0 问题 2021-12-09 11:48:55 +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
df6759b033 remove 删除无用注入 2021-12-07 17:41:50 +08:00
bf8bac2bcc fix 关于 Undertow 的错误说明 2021-12-07 17:06:11 +08:00
37def02ee1 fix 修复sql关键字处理 防止解析器报错 2021-12-07 15:16:37 +08:00
09dfb25d73 update 修改 健康检查权限 改为用户放行 提高安全性 2021-12-07 12:20:21 +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
ed22f395ba update 更新 redis.conf 配置文件 标注key监听器配置 2021-12-06 20:25:33 +08:00
bcbc7c1d47 update 更新 RedisUtils 增加 注册监听器方法 2021-12-06 20:22:45 +08:00
1445d6d24a update 更新 RedisUtils 返回客户端实例 2021-12-06 19:52:27 +08:00
4de4763baf update 优化查询用户的角色组、岗位组代码 2021-12-06 18:32:51 +08:00
8362fe1b39 update 优化查询用户的角色组、岗位组代码 2021-12-06 14:48:04 +08:00
258dc16cfd update 更新 jdk 版本说明 暂不支持 jdk17 2021-12-06 14:36:59 +08:00
8f8e796c77 update tlog 1.3.4 => 1.3.5 启用 tlog 自动配置 2021-12-06 14:36:38 +08:00
a39a98cda9 update 移除 包错误引用 2021-12-06 14:35:55 +08:00
90ba39593a update 声明 cglib 依赖 控制版本 2021-12-06 12:12:20 +08:00
c3061a19a2 remove 移除过期工具 2021-12-06 11:01:07 +08:00
e11a6163dd update 禁止所有工具类实例化 优化代码书写规范 2021-12-06 10:59:54 +08:00
1b752c35cc update 使用 Cglib 重构 BeanCopyUtils 性能优异 2021-12-06 10:40:57 +08:00
8b9d3541dd update LoginUser 增加角色缓存 优化角色权限代码 2021-12-03 19:25:38 +08:00
d4f49b10d7 update 重构代码生成分页相关 基于新分页方法 2021-12-03 15:58:16 +08:00
5ba39c0086 update 重构分页 基于 分页新方法 2021-12-03 15:57:58 +08:00
b5db6fe186 update 重构分页工具 使用分页实体类 过期方法标注过期 3.6.0 移除 2021-12-03 15:57:11 +08:00
8d2886e1ca add 增加 分页查询实体类 2021-12-03 15:56:19 +08:00
965ebd0f03 fix 修复主键溢出问题 将查询返回类型改为 Long 2021-12-03 11:11:43 +08:00
cb306b0793 remove 移除过期 用户导入 2021-12-03 10:45:31 +08:00
c5dc08e082 update 调整 角色查询部门 返回值类型 2021-12-03 10:45:04 +08:00
b00c6dd89b !120 selectPostListByUserId方法出参调整为Long
Merge pull request !120 from zendwang/dev
2021-12-03 02:40:05 +00:00
2fd28ca5c8 update 更新 nginx 演示环境配置 2021-12-02 21:07:43 +08:00
14a05ddaca !119 系统用户自定义导入时初始密码加密优化
Merge pull request !119 from zendwang/dev
2021-12-02 12:37:08 +00:00
209654fdff fix selectPostListByUserId方法出参调整为Long 2021-12-02 20:13:47 +08:00
f30aa02e7c fix 系统用户自定义导入时初始密码加密优化 2021-12-02 19:48:56 +08:00
dd4374229b fix 修复更改密码问题 由于移除redis上存储的密码 导致找不到缓存内的旧密码 2021-12-02 19:11:36 +08:00
7eedf37149 update 优化 pr !118 代码结构 2021-12-02 18:47:18 +08:00
7aea32f48b !118 为Transactional注解设置rollback属性
Merge pull request !118 from zendwang/dev
2021-12-02 10:44:24 +00:00
ac38f7b909 fix 为Transactional注解设置rollback属性 2021-12-02 18:34:49 +08:00
2c3f1c28e5 tomcat update 2021-12-02 16:31:51 +08:00
e8ee5ad691 update 用户登录 支持校验错误次数锁定登录 2021-12-02 16:04:45 +08:00
5322f5f707 update 常量类 接口化 2021-12-02 14:18:20 +08:00
408f5055a9 update 通用权限服务 迁移回 ruoyi-framework 模块 2021-12-02 14:02:00 +08:00
6bfae2652f 若依 3.8.0 2021-12-01 08:53:11 +08:00
9036370d67 remove 删除 jjwt 无用依赖 2021-11-30 17:34:31 +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
255b5f2f07 update 更改前端工程文件版本号 2021-11-30 11:11:23 +08:00
f43a5cb244 update 更改前端工程文件版本号 2021-11-30 11:11:03 +08:00
bf4ac3ad7a !378 fix: crontab组件bug
Merge pull request !378 from fuzui/fix_cron_tool
2021-11-30 03:03:08 +00:00
4f0e73ba97 update 使用 hutool-jwt 替换老旧 jjwt 依赖 2021-11-30 10:33:35 +08: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
c6fe27b040 update 调整 OSS 表字段内容长度 2021-11-29 17:07:41 +08:00
3e2ddb3b25 fix 修复 count 语法异常 2021-11-29 17:07:41 +08:00
230d19a7aa update 调整 OSS 表字段内容长度 2021-11-29 16:46:27 +08:00
d2b7843d97 fix 修复 count 语法异常 2021-11-29 16:41:20 +08:00
ebc6617a8e Merge remote-tracking branch 'origin/dev' 2021-11-29 14:01:44 +08:00
dbba894544 发布 v3.4.0 2021-11-29 14:01:28 +08:00
65eb873f9a Merge remote-tracking branch 'origin/dev' 2021-11-29 13:59:15 +08:00
52673152cc 发布 v3.4.0 2021-11-29 13:58:42 +08:00
36fd16562e Merge remote-tracking branch 'origin/dev' 2021-11-29 13:31:37 +08:00
a8a4f2101d add 增加 mapper 目录下 package-info 防止建错目录 2021-11-29 09:59:53 +08:00
f46bd8b6ba update 更新 Validation 框架国际化说明 2021-11-28 21:47:08 +08:00
a627de02c7 Merge remote-tracking branch 'origin/dev' into dev 2021-11-28 21:04:13 +08:00
a94a0589dd update [重磅更新] Validator 校验框架支持国际化 2021-11-28 21:03:48 +08:00
81755a280d Merge branch 'master' of https://gitee.com/y_project/RuoYi-Vue into dev
 Conflicts:
	ruoyi-ui/src/utils/index.js
	ruoyi-ui/src/views/register.vue
2021-11-28 15:10:05 +08:00
89d776acb5 fix 修复 OSS 工厂 未实例化服务更新加载问题 2021-11-27 16:36:11 +08:00
daf660e66d update 更改 excel 方法注释 更清晰明显用法 2021-11-27 13:20:50 +08:00
e4020faff3 update 使用导入新写法 重构系统用户导入 2021-11-27 12:57:21 +08:00
e11b727584 update 修改移除无用回执信息 2021-11-27 12:43:34 +08:00
0a36a94b73 update 报错增加 excel 表头信息 2021-11-27 11:18:41 +08:00
89e7cb19b9 注册成功提示类型success 2021-11-26 18:11:57 +08:00
fa2bdcd5ac update 抽象 Excel 导入支持自定义监听器 2021-11-26 18:11:41 +08:00
ea71c9b214 !376 camelCase中应该转换下划线,而不是横杠
Merge pull request !376 from khejing/master
2021-11-26 10:07:58 +00:00
c00e397405 update 抽象 Excel 导入支持自定义监听器 2021-11-26 18:06:44 +08:00
a2a2640d29 update 调整校验异常 返回完整信息 2021-11-26 18:05:47 +08:00
7c4a104823 !113 add 新增 excel 导入支持开启 Validator 数据验证
Merge pull request !113 from Yjoioooo/auto-5403234-dev-1637903026810
2021-11-26 08:40:42 +00:00
7892ec5a59 fix 修复重复提交不生效问题 由于概念不同 使用 RedisUtils 重构 2021-11-26 16:32:56 +08:00
e5fd1f76db camelCase中应该是下划线,而不是横杠 2021-11-26 08:26:45 +00:00
6502f21072 update 修改不规范命名 2021-11-26 05:57:28 +00:00
48fd65d7f8 update satoken 标注为公测 2021-11-26 13:45:12 +08:00
1010ccca4d update 更新 RedisUtils set保留ttl 兼容 5.X redis版本 2021-11-26 13:34:18 +08:00
c21ff85b57 update 增加excel导入样例 2021-11-26 13:02:59 +08:00
c3bb4d2a61 add 新增导入支持开启Validator数据验证,支持开启导入异常行继续读取,支持返回导入回执 2021-11-26 13:01:00 +08:00
d2b7f8ef0f remove 删除无用 js 文件 2021-11-25 19:47:34 +08:00
af25588b88 Merge remote-tracking branch 'ruoyi-vue/master' into dev
# Conflicts:
#	pom.xml
#	ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysProfileController.java
#	ruoyi-framework/src/main/java/com/ruoyi/framework/config/FilterConfig.java
#	ruoyi-generator/pom.xml
#	ruoyi-generator/src/main/java/com/ruoyi/generator/util/VelocityInitializer.java
#	ruoyi-generator/src/main/java/com/ruoyi/generator/util/VelocityUtils.java
#	ruoyi-generator/src/main/resources/vm/js/api.js.vm
#	ruoyi-generator/src/main/resources/vm/vue/index-tree.vue.vm
#	ruoyi-generator/src/main/resources/vm/vue/index.vue.vm
#	ruoyi-generator/src/main/resources/vm/xml/mapper.xml.vm
#	ruoyi-quartz/src/main/java/com/ruoyi/quartz/config/ScheduleConfig.java
#	ruoyi-ui/package.json
#	ruoyi-ui/src/api/monitor/server.js
#	ruoyi-ui/src/components/RuoYi/Doc/index.vue
#	ruoyi-ui/src/components/RuoYi/Git/index.vue
#	ruoyi-ui/src/components/SizeSelect/index.vue
#	ruoyi-ui/src/layout/components/Sidebar/Logo.vue
#	ruoyi-ui/src/layout/components/TagsView/index.vue
#	ruoyi-ui/src/layout/index.vue
#	ruoyi-ui/src/main.js
#	ruoyi-ui/src/plugins/download.js
#	ruoyi-ui/src/router/index.js
#	ruoyi-ui/src/store/modules/permission.js
#	ruoyi-ui/src/store/modules/settings.js
#	ruoyi-ui/src/store/modules/tagsView.js
#	ruoyi-ui/src/store/modules/user.js
#	ruoyi-ui/src/views/login.vue
#	ruoyi-ui/src/views/monitor/job/log.vue
#	ruoyi-ui/src/views/system/dict/data.vue
#	ruoyi-ui/src/views/system/role/index.vue
#	ruoyi-ui/src/views/system/user/authRole.vue
#	ruoyi-ui/src/views/system/user/index.vue
#	ruoyi-ui/src/views/system/user/profile/resetPwd.vue
#	ruoyi-ui/src/views/system/user/profile/userAvatar.vue
#	ruoyi-ui/src/views/system/user/profile/userInfo.vue
2021-11-25 19:39:53 +08:00
7546ef649c update springboot 2.5.6 => 2.5.7 2021-11-25 19:14:52 +08:00
2a3bf1d994 remove 删除无用 redis 依赖配置 2021-11-25 19:14:30 +08: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
7a4f36c00e update 优化时间查询语句 2021-11-24 11:24:15 +08:00
1f3ef4ffe1 update 初始化数据转移到 ApplicationRunner 统一处理 2021-11-24 10:59:18 +08:00
c364836a9d Merge remote-tracking branch 'origin/dev' into dev 2021-11-24 10:58:17 +08:00
97a12075b1 update 初始化数据转移到 ApplicationRunner 统一处理 2021-11-24 10:58:10 +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
d36d944b3a remove 删除 quartz 相关 sql 数据 2021-11-23 21:53:53 +08:00
7af22453ba update 更新 redis.conf 存储策略 aof 与 rdb 配置参数 2021-11-23 20:19:51 +08:00
d0c4b5bc76 add 增加 RedisUtils set 保留 TTL 有效期方法 2021-11-23 10:20:44 +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
65a1245a03 update OSS 模块 整体重命名 消除歧义 2021-11-22 09:48:22 +08:00
486e4f8dd3 update 删除无用字段 2021-11-22 09:46:45 +08:00
4cfbd8a9d2 update OSS 模块 整体重命名 消除歧义 2021-11-22 09:45:46 +08:00
7ab51b8960 update 规范 ICloudStorageStrategy 接口函数 2021-11-22 09:34:26 +08:00
18cbd96280 update satoken 标记生产可用 2021-11-22 09:29:58 +08:00
2cdea69719 add 增加 缓存懒加载 开关 2021-11-22 02:46:13 +08:00
6c053b6266 update 优化 RedisUtils.getCacheObject 的返回值处理 2021-11-22 02:45:50 +08:00
20eea9914e update 基于 DictService 重构 Excel 内字典查询功能 2021-11-22 02:44:46 +08:00
6d3f4f5a04 update 抽象 DictService 通用 字典服务 2021-11-22 02:43:22 +08:00
20e782eb21 update 抽象 ConfigService 通用 参数配置服务 2021-11-22 02:42:59 +08:00
e30fa57ab4 update DictUtils 字典工具类 标记过期 3.5.0 版本移除 使用 DictService 代替 2021-11-22 02:42:14 +08:00
ef0b07d5c4 update 更新 RepeatSubmit 注解 aop 处理 针对特殊参数进行过滤 2021-11-22 00:57:49 +08:00
b9b1ec8f41 Merge remote-tracking branch 'origin/dev' into dev 2021-11-21 01:39:50 +08:00
019526fbe9 update 解耦 LoginUser 与 SysUser 强关联 2021-11-21 01:39:43 +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
5e1d4f215d fix 修复关闭 xss 功能导致可重复读 RepeatableFilter 失效 2021-11-19 13:06:51 +08:00
9a7bb81cd0 fix 修复关闭 xss 功能导致可重复读 RepeatableFilter 失效 2021-11-19 13:01:30 +08:00
321bb010cb update 更新注解参数类型 去除多余警告 2021-11-18 19:28:39 +08:00
e24a79f87b update 调整 bat 脚本 编码格式 2021-11-18 18:54:54 +08:00
2dd0add3e7 remove 删除无用日志配置 2021-11-18 18:49:10 +08:00
ce279ca360 Merge branch 'master' of https://gitee.com/y_project/RuoYi-Vue into dev
 Conflicts:
	ruoyi-generator/src/main/resources/vm/java/serviceImpl.java.vm
	ruoyi-ui/package.json
	ruoyi-ui/src/utils/request.js
2021-11-18 18:43:34 +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
f8487f581b update 补全所有接口 单参数接口文档 2021-11-18 17:01:23 +08:00
40c9559d9e update springboot-admin 2.5.3 => 2.5.4 2021-11-17 20:11:56 +08:00
531e0ef918 remove 删除 quartz 过时页面 2021-11-17 19:42:38 +08:00
2781655b0a update 适配 ruoyi 关于优化导出数据操作 2021-11-17 19:42:14 +08:00
64add90edd Merge branch 'master' of https://gitee.com/y_project/RuoYi-Vue into dev
 Conflicts:
	ruoyi-admin/src/main/java/com/ruoyi/web/controller/common/CaptchaController.java
	ruoyi-admin/src/main/java/com/ruoyi/web/controller/monitor/SysLogininforController.java
	ruoyi-admin/src/main/java/com/ruoyi/web/controller/monitor/SysOperlogController.java
	ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysConfigController.java
	ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysDictDataController.java
	ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysDictTypeController.java
	ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysPostController.java
	ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysRoleController.java
	ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysUserController.java
	ruoyi-common/src/main/java/com/ruoyi/common/config/RuoYiConfig.java
	ruoyi-common/src/main/java/com/ruoyi/common/utils/http/HttpUtils.java
	ruoyi-common/src/main/java/com/ruoyi/common/utils/poi/ExcelUtil.java
	ruoyi-generator/src/main/resources/vm/java/controller.java.vm
	ruoyi-generator/src/main/resources/vm/vue/index.vue.vm
	ruoyi-quartz/src/main/java/com/ruoyi/quartz/controller/SysJobController.java
	ruoyi-quartz/src/main/java/com/ruoyi/quartz/controller/SysJobLogController.java
	ruoyi-quartz/src/main/java/com/ruoyi/quartz/util/JobInvokeUtil.java
	ruoyi-ui/package.json
	ruoyi-ui/src/api/monitor/logininfor.js
	ruoyi-ui/src/api/monitor/operlog.js
	ruoyi-ui/src/api/system/config.js
	ruoyi-ui/src/api/system/dict/data.js
	ruoyi-ui/src/api/system/dict/type.js
	ruoyi-ui/src/api/system/post.js
	ruoyi-ui/src/api/system/role.js
	ruoyi-ui/src/api/system/user.js
	ruoyi-ui/src/main.js
	ruoyi-ui/src/utils/request.js
	ruoyi-ui/src/views/monitor/job/index.vue
	ruoyi-ui/src/views/monitor/job/log.vue
	ruoyi-ui/src/views/monitor/logininfor/index.vue
	ruoyi-ui/src/views/monitor/operlog/index.vue
	ruoyi-ui/src/views/system/config/index.vue
	ruoyi-ui/src/views/system/dict/data.vue
	ruoyi-ui/src/views/system/dict/index.vue
	ruoyi-ui/src/views/system/post/index.vue
	ruoyi-ui/src/views/system/role/index.vue
	ruoyi-ui/src/views/system/user/index.vue
2021-11-17 19:14:03 +08:00
8de93d35ed 代码生成模板缺少事务 2021-11-17 07:56:24 +00:00
eb844e3260 fix 修复 OssFactory 在程序启动未调用api 没有初始化 导致无法订阅配置更改问题 2021-11-17 13:50:58 +08:00
cedd2d1daf 优化导出数据操作 2021-11-17 11:57:17 +08:00
81d04fb31f Merge remote-tracking branch 'origin/dev' into dev 2021-11-17 10:46:18 +08:00
caba6fb01e update 调度中心 集成监控客户端 注册到监控中心 2021-11-17 10:45:58 +08:00
1c8d44b309 update 监控中心 集成监控客户端 实现自监控 2021-11-17 10:45:32 +08:00
984098abce fix: 修复返回参数的数据类型错误的问题 2021-11-16 20:47:26 +08:00
ead6da4760 update 更新页面与文档项目介绍 2021-11-16 18:54:53 +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
b374ff4d6d update 优化字典工具写法 2021-11-15 16:54:34 +08:00
149b136e0b fix 修复用户导入字典使用错误 2021-11-14 22:27:36 +08:00
5389663b72 fix 修复 临时文件存储位置 相对路径问题 2021-11-12 21:16:45 +08:00
f99e24bf82 update 更新文档 演示环境 2021-11-12 20:39:11 +08:00
a610c5c8c6 update 更新文档 演示环境 2021-11-12 20:38:49 +08:00
874cf18566 fix 修复 配置应用前缀路径书写问题 2021-11-12 19:43:49 +08:00
53cb0826bc update 升级 swagger 配置 使用 knife4j 增强模式 2021-11-12 13:15:32 +08:00
6904f38ea2 update 调整代码格式化 2021-11-11 15:31:49 +08:00
223ff4ebff fix 分页工具 排序字段 null 处理 2021-11-11 12:47:26 +08:00
d2ec3e7d9a update 移除 sql 脚本 quartz 相关表数据 2021-11-10 14:10:25 +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
3b574875cb update hutool 5.7.15 => 5.7.16
update okhttp 4.9.1 => 4.9.2
update spring-boot-admin 2.5.2 => 2.5.3
update redisson 3.16.3 => 3.16.4
update tlog 1.3.3 => 1.3.4
2021-11-10 10:07:28 +08:00
4d5048435c fix 修复 ruoyi 关于 配置应用前缀路径的bug 改为配置文件统一配置 2021-11-08 18:17:29 +08:00
57df7f8dfe fix 修复 OSS 七牛云 token 过期未刷新问题 2021-11-08 14:36:07 +08:00
74b36fbd98 !110 提高不同类型数据库的兼容性
Merge pull request !110 from phanes/dev
2021-11-07 12:15:03 +00:00
8ea56d3b22 update 减少使用特定数据库函数 2021-11-07 11:58:35 +08:00
019f585c83 update 补全通用日志服务 注释 2021-11-04 19:01:33 +08:00
c7c9bd6b08 fix 修复 用户逻辑删除 差异问题 2021-11-04 18:49:46 +08:00
b132f04f71 fix 修复 SysLoginController 接口文档书写错误问题 2021-11-04 14:18:38 +08:00
2f21f293c1 update 基于 hutool 封装树构建工具 重构部门与菜单树结构返回 2021-11-04 10:32:18 +08:00
5b3c390e08 remove 移除 MybatisPlusRedisCache 二级缓存 2021-11-03 15:04:10 +08:00
8a93371baa remove 移除 feign 相关代码与依赖 2021-11-03 15:02:29 +08:00
95dcae1a85 remove 移除 quartz 相关代码与依赖 2021-11-03 14:46:12 +08:00
03e2ff587e 同步 ruoyi 2021-11-03 13:58:59 +08:00
1ea73a67ca Merge branch 'master' of https://gitee.com/y_project/RuoYi-Vue into dev
 Conflicts:
	README.md
	ruoyi-common/src/main/java/com/ruoyi/common/constant/Constants.java
	ruoyi-common/src/main/java/com/ruoyi/common/utils/html/EscapeUtil.java
	ruoyi-common/src/main/java/com/ruoyi/common/utils/html/HTMLFilter.java
	ruoyi-common/src/main/java/com/ruoyi/common/utils/uuid/UUID.java
	ruoyi-quartz/src/main/java/com/ruoyi/quartz/controller/SysJobController.java
	ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDeptServiceImpl.java
	ruoyi-ui/src/api/login.js
	ruoyi-ui/src/views/index.vue
2021-11-03 13:58:45 +08:00
1d32420a27 add 增加 ValidatorUtils 校验框架工具 用于在非 Controller 的地方校验对象 2021-11-03 13:50:51 +08:00
9aa8438ced fix 修复通用实体 传参无法接收问题 2021-11-02 22:46:49 +08:00
0b35927b16 fix 修复通用实体 传参无法接收问题 2021-11-02 22:43:53 +08:00
bbbe83b737 添加新群号:101539465 2021-11-02 14:40:21 +08:00
06f06ce390 fix 修复 Linux 清除临时目录 导致上传找不到目录报错问题 2021-11-01 17:44:01 +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
a2c8b0d13e fix 修复 xxl-job-admin 部署问题 2021-11-01 13:51:02 +08:00
c4e17ff847 fix 修复 xxl-job-admin 部署问题 2021-11-01 13:49:11 +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
a8ab3ffd01 update 升级 docker 基础镜像 2021-11-01 09:55:14 +08:00
2c6e1f0db7 fix 修复 SysOss、SysOssConfig 未继承 BaseEntity 基础实体问题 2021-10-31 21:32:25 +08:00
cd0aad10b0 fix 修复 SysOss、SysOssConfig 未继承 BaseEntity 基础实体问题 2021-10-31 21:28:19 +08:00
da2cb61cae update 调整 pr !107 代码格式 2021-10-29 17:37:15 +08:00
e4c691fd5f !107 add 新增 Admin 监控 Bean 初始化 startup trace 监控插件
Merge pull request !107 from shenxinquan/auto-480232-dev-1635497752042
2021-10-29 09:36:13 +00:00
sxq
ea2e560bd9 去掉jfr相关类。 2021-10-29 17:28:33 +08:00
sxq
25321984fa 新增startup trace监控。 2021-10-29 16:55:42 +08:00
13c770b6be 优化一些布尔判断语法 2021-10-27 19:03:29 +08:00
333 changed files with 6003 additions and 6312 deletions

View File

@ -4,41 +4,43 @@
[![License](https://img.shields.io/badge/License-MIT-blue.svg)](https://gitee.com/JavaLionLi/RuoYi-Vue-Plus/blob/master/LICENSE)
[![使用IntelliJ IDEA开发维护](https://img.shields.io/badge/IntelliJ%20IDEA-提供支持-blue.svg)](https://www.jetbrains.com/?from=RuoYi-Vue-Plus)
<br>
[![RuoYi-Vue-Plus](https://img.shields.io/badge/RuoYi_Vue_Plus-3.3.0-success.svg)](https://gitee.com/JavaLionLi/RuoYi-Vue-Plus)
[![RuoYi-Vue-Plus](https://img.shields.io/badge/RuoYi_Vue_Plus-3.5.0-success.svg)](https://gitee.com/JavaLionLi/RuoYi-Vue-Plus)
[![Spring Boot](https://img.shields.io/badge/Spring%20Boot-2.5-blue.svg)]()
[![JDK-8+](https://img.shields.io/badge/JDK-8-green.svg)]()
[![JDK-11](https://img.shields.io/badge/JDK-11-green.svg)]()
[![JDK-17](https://img.shields.io/badge/JDK-17-green.svg)]()
RuoYi-Vue-Plus 是基于 RuoYi-Vue 针对 `分布式集群` 场景升级(不兼容原框架)
> RuoYi-Vue-Plus 是重写 RuoYi-Vue 针对 `分布式集群` 场景全方位升级(不兼容原框架)
> 系统演示: [传送门](https://gitee.com/JavaLionLi/RuoYi-Vue-Plus/wikis/系统演示?sort_id=4836388)
| 功能介绍 | 使用技术 | 文档地址 | 特性注意事项 |
|---|---|---|---|
| 当前框架 | RuoYi-Vue-Plus | [RuoYi-Vue-Plus文档](https://gitee.com/JavaLionLi/RuoYi-Vue-Plus/wikis/pages) | 重写RuoYi-Vue全方位升级(不兼容原框架) |
| satoken分支 | RuoYi-Vue-Plus-satoken | [satoken分支地址](https://gitee.com/JavaLionLi/RuoYi-Vue-Plus/tree/satoken/) | 使用satoken重构权限鉴权(仅供学习不推荐上生产) |
| satoken分支 | RuoYi-Vue-Plus-satoken | [satoken分支地址](https://gitee.com/JavaLionLi/RuoYi-Vue-Plus/tree/satoken/) | 高可读性 扩展性(推荐使用) |
| 单体分支 | RuoYi-Vue-Plus-fast | [fast分支地址](https://gitee.com/JavaLionLi/RuoYi-Vue-Plus/tree/fast/) | 单体应用结构 |
| Vue3分支 | RuoYi-Vue-Plus-UI | [UI地址](https://gitee.com/JavaLionLi/RuoYi-Vue-Plus-UI) | 由于组件还未完善 仅供学习 |
| 原框架 | RuoYi-Vue | [RuoYi-Vue官网](http://ruoyi.vip/) | 定期同步需要的功能 |
| 前端开发框架 | Vue、Element UI | [Element UI官网](https://element.eleme.cn/#/zh-CN) | |
| 后端开发框架 | SpringBoot | [SpringBoot官网](https://spring.io/projects/spring-boot/#learn) | |
| 容器框架 | Undertow | [Undertow官网](https://undertow.io/) | 基于 Netty 的高性能容器 |
| 容器框架 | Undertow | [Undertow官网](https://undertow.io/) | 基于 XNIO 的高性能容器 |
| 权限认证框架 | Spring Security、Jwt | [SpringSecurity官网](https://spring.io/projects/spring-security#learn) | 支持多终端认证系统 |
| 权限认证框架 | Sa-Token、Jwt | [Sa-Token官网](https://sa-token.dev33.cn/) | 强解耦、强扩展 |
| 关系数据库 | MySQL | [MySQL官网](https://dev.mysql.com/) | 适配 8.X 最低 5.7 |
| 缓存数据库 | Redis | [Redis官网](https://redis.io/) | 适配 6.X 最低 4.X |
| 数据库框架 | Mybatis-Plus | [Mybatis-Plus文档](https://baomidou.com/guide/) | 快速 CRUD 增加开发效率 |
| 数据库框架 | p6spy | [p6spy官网](https://p6spy.readthedocs.io/) | 更强劲的 SQL 分析 |
| 多数据源框架 | dynamic-datasource | [dynamic-ds文档](https://www.kancloud.cn/tracy5546/dynamic-datasource/content) | 支持主从与多种类数据库异构 |
| 序列化框架 | Jackson | [Jackson官网](https://github.com/FasterXML/jackson) | 统一使用 jackson 高效可靠 |
| 网络框架 | Feign、OkHttp3 | [Feign官网](https://github.com/OpenFeign/feign) | 接口化管理 HTTP 请求 |
| Redis客户端 | Redisson | [Redisson文档](https://github.com/redisson/redisson/wiki/%E7%9B%AE%E5%BD%95) | 支持单机、集群配置 |
| 分布式限流 | Redisson | [Redisson文档](https://github.com/redisson/redisson/wiki/%E7%9B%AE%E5%BD%95) | 全局、请求IP、集群ID 多种限流 |
| 分布式锁 | Lock4j | [Lock4j官网](https://gitee.com/baomidou/lock4j) | 注解锁、工具锁 多种多样 |
| 分布式幂等 | Lock4j | [Lock4j文档](https://gitee.com/baomidou/lock4j) | 基于分布式锁实现 |
| 分布式幂等 | Redisson | [Lock4j文档](https://gitee.com/baomidou/lock4j) | 拦截重复提交 |
| 分布式日志 | TLog | [TLog文档](https://yomahub.com/tlog/docs) | 支持跟踪链路日志记录、性能分析、链路排查 |
| 分布式任务调度 | Xxl-Job | [Xxl-Job官网](https://www.xuxueli.com/xxl-job/) | 高性能 高可靠 易扩展 |
| 文件存储 | Minio | [Minio文档](https://docs.min.io/) | 本地存储 |
| 文件存储 | 七牛、阿里、腾讯 | [OSS使用文档](https://gitee.com/JavaLionLi/RuoYi-Vue-Plus/wikis/pages?sort_id=4359146&doc_id=1469725) | 云存储 |
| 监控框架 | SpringBoot-Admin | [SpringBoot-Admin文档](https://codecentric.github.io/spring-boot-admin/current/) | 全方位服务监控 |
| 校验框架 | Validation | [Validation文档](https://docs.jboss.org/hibernate/stable/validator/reference/en-US/html_single/) | 增强接口安全性、严谨性 |
| 校验框架 | Validation | [Validation文档](https://docs.jboss.org/hibernate/stable/validator/reference/en-US/html_single/) | 增强接口安全性、严谨性 支持国际化 |
| Excel框架 | Alibaba EasyExcel | [EasyExcel文档](https://www.yuque.com/easyexcel/doc/easyexcel) | 性能优异 扩展性强 |
| 文档框架 | Knife4j | [Knife4j文档](https://doc.xiaominfo.com/knife4j/documentation/) | 美化接口文档 |
| 工具类框架 | Hutool、Lombok | [Hutool文档](https://www.hutool.cn/docs/) | 减少代码冗余 增加安全性 |
@ -61,8 +63,7 @@ RuoYi-Vue-Plus 是基于 RuoYi-Vue 针对 `分布式集群` 场景升级(不兼
## 软件架构图
![Plus部署架构图](https://images.gitee.com/uploads/images/2021/0729/112230_4295e5ce_1766278.png "Plus部署架构图.png")
![Plus部署架构图](https://images.gitee.com/uploads/images/2021/1112/202137_673ac5d2_1766278.png "Plus部署架构图.png")
## 贡献代码
欢迎各路英雄豪杰 `PR` 代码 请提交到 `dev` 开发分支 统一测试发版

115
pom.xml
View File

@ -6,15 +6,15 @@
<groupId>com.ruoyi</groupId>
<artifactId>ruoyi-vue-plus</artifactId>
<version>3.3.0</version>
<version>3.5.0</version>
<name>RuoYi-Vue-Plus</name>
<url>https://gitee.com/JavaLionLi/RuoYi-Vue-Plus</url>
<description>RuoYi-Vue-Plus后台管理系统</description>
<properties>
<ruoyi-vue-plus.version>3.3.0</ruoyi-vue-plus.version>
<spring-boot.version>2.5.6</spring-boot.version>
<ruoyi-vue-plus.version>3.5.0</ruoyi-vue-plus.version>
<spring-boot.version>2.5.8</spring-boot.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
@ -24,29 +24,27 @@
<swagger-annotations.version>1.5.22</swagger-annotations.version>
<poi.version>4.1.2</poi.version>
<easyexcel.version>2.2.11</easyexcel.version>
<velocity.version>1.7</velocity.version>
<jwt.version>0.9.1</jwt.version>
<cglib.version>3.3.0</cglib.version>
<velocity.version>2.3</velocity.version>
<mybatis-plus.version>3.4.3.4</mybatis-plus.version>
<p6spy.version>3.9.1</p6spy.version>
<hutool.version>5.7.15</hutool.version>
<feign.version>3.0.3</feign.version>
<feign-okhttp.version>11.6</feign-okhttp.version>
<okhttp.version>4.9.1</okhttp.version>
<spring-boot-admin.version>2.5.2</spring-boot-admin.version>
<redisson.version>3.16.3</redisson.version>
<hutool.version>5.7.18</hutool.version>
<okhttp.version>4.9.2</okhttp.version>
<spring-boot-admin.version>2.5.5</spring-boot-admin.version>
<redisson.version>3.16.7</redisson.version>
<lock4j.version>2.2.1</lock4j.version>
<dynamic-ds.version>3.4.1</dynamic-ds.version>
<tlog.version>1.3.3</tlog.version>
<dynamic-ds.version>3.5.0</dynamic-ds.version>
<tlog.version>1.3.6</tlog.version>
<xxl-job.version>2.3.0</xxl-job.version>
<!-- jdk11 缺失依赖 jaxb-->
<jaxb.version>3.0.1</jaxb.version>
<!-- OSS 配置 -->
<qiniu.version>7.8.0</qiniu.version>
<qiniu.version>7.9.0</qiniu.version>
<aliyun.oss.version>3.13.1</aliyun.oss.version>
<qcloud.cos.version>5.6.58</qcloud.cos.version>
<minio.version>8.3.3</minio.version>
<minio.version>8.3.4</minio.version>
<!-- docker 配置 -->
<docker.registry.url>localhost</docker.registry.url>
@ -117,20 +115,19 @@
</exclusions>
</dependency>
<dependency>
<groupId>cglib</groupId>
<artifactId>cglib</artifactId>
<version>${cglib.version}</version>
</dependency>
<!-- velocity代码生成使用模板 -->
<dependency>
<groupId>org.apache.velocity</groupId>
<artifactId>velocity</artifactId>
<artifactId>velocity-engine-core</artifactId>
<version>${velocity.version}</version>
</dependency>
<!-- Token生成与解析-->
<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt</artifactId>
<version>${jwt.version}</version>
</dependency>
<!-- jdk11 缺失依赖 jaxb-->
<dependency>
<groupId>com.sun.xml.bind</groupId>
@ -164,27 +161,32 @@
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-all</artifactId>
<artifactId>hutool-core</artifactId>
<version>${hutool.version}</version>
</dependency>
<!-- @deprecated 由于使用人数较少 决定与 3.4.0 版本移除 -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-openfeign</artifactId>
<version>${feign.version}</version>
<exclusions>
<exclusion>
<artifactId>feign-core</artifactId>
<groupId>io.github.openfeign</groupId>
</exclusion>
</exclusions>
<groupId>cn.hutool</groupId>
<artifactId>hutool-http</artifactId>
<version>${hutool.version}</version>
</dependency>
<!-- @deprecated 由于使用人数较少 决定与 3.4.0 版本移除 -->
<dependency>
<groupId>io.github.openfeign</groupId>
<artifactId>feign-okhttp</artifactId>
<version>${feign-okhttp.version}</version>
<groupId>cn.hutool</groupId>
<artifactId>hutool-captcha</artifactId>
<version>${hutool.version}</version>
</dependency>
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-extra</artifactId>
<version>${hutool.version}</version>
</dependency>
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-jwt</artifactId>
<version>${hutool.version}</version>
</dependency>
<dependency>
@ -225,43 +227,14 @@
<dependency>
<groupId>com.yomahub</groupId>
<artifactId>tlog-spring-boot-configuration</artifactId>
<artifactId>tlog-web-spring-boot-starter</artifactId>
<version>${tlog.version}</version>
</dependency>
<dependency>
<groupId>com.yomahub</groupId>
<artifactId>tlog-webroot</artifactId>
<artifactId>tlog-xxljob-spring-boot-starter</artifactId>
<version>${tlog.version}</version>
<exclusions>
<exclusion>
<artifactId>javassist</artifactId>
<groupId>org.javassist</groupId>
</exclusion>
<exclusion>
<artifactId>guava</artifactId>
<groupId>com.google.guava</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.yomahub</groupId>
<artifactId>tlog-feign</artifactId>
<version>${tlog.version}</version>
</dependency>
<dependency>
<groupId>com.yomahub</groupId>
<artifactId>tlog-xxl-job</artifactId>
<version>${tlog.version}</version>
</dependency>
<!-- 定时任务 @deprecated 3.4.0删除 迁移至xxl-job -->
<dependency>
<groupId>com.ruoyi</groupId>
<artifactId>ruoyi-quartz</artifactId>
<version>${ruoyi-vue-plus.version}</version>
</dependency>
<!-- 定时任务 -->
@ -320,7 +293,6 @@
<module>ruoyi-admin</module>
<module>ruoyi-framework</module>
<module>ruoyi-system</module>
<module>ruoyi-quartz</module>
<module>ruoyi-job</module>
<module>ruoyi-generator</module>
<module>ruoyi-common</module>
@ -385,6 +357,7 @@
<!-- 环境标识,需要与配置文件的名称相对应 -->
<profiles.active>local</profiles.active>
<logging.level>debug</logging.level>
<knife4j.production>false</knife4j.production>
<endpoints.include>'*'</endpoints.include>
</properties>
</profile>
@ -394,6 +367,7 @@
<!-- 环境标识,需要与配置文件的名称相对应 -->
<profiles.active>dev</profiles.active>
<logging.level>debug</logging.level>
<knife4j.production>false</knife4j.production>
<endpoints.include>'*'</endpoints.include>
</properties>
<activation>
@ -406,6 +380,7 @@
<properties>
<profiles.active>prod</profiles.active>
<logging.level>warn</logging.level>
<knife4j.production>true</knife4j.production>
<endpoints.include>health, info, logfile</endpoints.include>
</properties>
</profile>

View File

@ -4,6 +4,7 @@ MAINTAINER Lion Li
RUN mkdir -p /ruoyi/server
RUN mkdir -p /ruoyi/server/logs
RUN mkdir -p /ruoyi/server/temp
WORKDIR /ruoyi/server

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>ruoyi-vue-plus</artifactId>
<groupId>com.ruoyi</groupId>
<version>3.3.0</version>
<version>3.5.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<packaging>jar</packaging>
@ -41,12 +41,6 @@
<artifactId>ruoyi-system</artifactId>
</dependency>
<!-- 定时任务 @deprecated 3.4.0删除 迁移至xxl-job -->
<!-- <dependency>-->
<!-- <groupId>com.ruoyi</groupId>-->
<!-- <artifactId>ruoyi-quartz</artifactId>-->
<!-- </dependency>-->
<dependency>
<groupId>com.ruoyi</groupId>
<artifactId>ruoyi-job</artifactId>

View File

@ -2,6 +2,7 @@ package com.ruoyi;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.metrics.buffering.BufferingApplicationStartup;
/**
* 启动程序
@ -14,7 +15,9 @@ public class RuoYiApplication {
public static void main(String[] args) {
System.setProperty("spring.devtools.restart.enabled", "false");
SpringApplication.run(RuoYiApplication.class, args);
SpringApplication application = new SpringApplication(RuoYiApplication.class);
application.setApplicationStartup(new BufferingApplicationStartup(2048));
application.run(args);
System.out.println("(♥◠‿◠)ノ゙ RuoYi-Vue-Plus启动成功 ლ(´ڡ`ლ)゙");
}

View File

@ -3,6 +3,7 @@ package com.ruoyi.web.controller.monitor;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.PageQuery;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
@ -36,14 +37,14 @@ public class SysLogininforController extends BaseController {
@ApiOperation("查询系统访问记录列表")
@PreAuthorize("@ss.hasPermi('monitor:logininfor:list')")
@GetMapping("/list")
public TableDataInfo<SysLogininfor> list(SysLogininfor logininfor) {
return logininforService.selectPageLogininforList(logininfor);
public TableDataInfo<SysLogininfor> list(SysLogininfor logininfor, PageQuery pageQuery) {
return logininforService.selectPageLogininforList(logininfor, pageQuery);
}
@ApiOperation("导出系统访问记录列表")
@Log(title = "登录日志", businessType = BusinessType.EXPORT)
@PreAuthorize("@ss.hasPermi('monitor:logininfor:export')")
@GetMapping("/export")
@PostMapping("/export")
public void export(SysLogininfor logininfor, HttpServletResponse response) {
List<SysLogininfor> list = logininforService.selectLogininforList(logininfor);
ExcelUtil.exportExcel(list, "登录日志", SysLogininfor.class, response);

View File

@ -3,6 +3,7 @@ package com.ruoyi.web.controller.monitor;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.PageQuery;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
@ -36,14 +37,14 @@ public class SysOperlogController extends BaseController {
@ApiOperation("查询操作日志记录列表")
@PreAuthorize("@ss.hasPermi('monitor:operlog:list')")
@GetMapping("/list")
public TableDataInfo<SysOperLog> list(SysOperLog operLog) {
return operLogService.selectPageOperLogList(operLog);
public TableDataInfo<SysOperLog> list(SysOperLog operLog, PageQuery pageQuery) {
return operLogService.selectPageOperLogList(operLog, pageQuery);
}
@ApiOperation("导出操作日志记录列表")
@Log(title = "操作日志", businessType = BusinessType.EXPORT)
@PreAuthorize("@ss.hasPermi('monitor:operlog:export')")
@GetMapping("/export")
@PostMapping("/export")
public void export(SysOperLog operLog, HttpServletResponse response) {
List<SysOperLog> list = operLogService.selectOperLogList(operLog);
ExcelUtil.exportExcel(list, "操作日志", SysOperLog.class, response);

View File

@ -7,7 +7,6 @@ import com.ruoyi.common.core.domain.AjaxResult;
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.PageUtils;
import com.ruoyi.common.utils.RedisUtils;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.system.domain.SysUserOnline;
@ -53,7 +52,7 @@ public class SysUserOnlineController extends BaseController {
if (StringUtils.equals(ipaddr, user.getIpaddr())) {
userOnlineList.add(userOnlineService.selectOnlineByIpaddr(ipaddr, user));
}
} else if (StringUtils.isNotEmpty(userName) && StringUtils.isNotNull(user.getUser())) {
} else if (StringUtils.isNotEmpty(userName)) {
if (StringUtils.equals(userName, user.getUsername())) {
userOnlineList.add(userOnlineService.selectOnlineByUserName(userName, user));
}
@ -63,7 +62,7 @@ public class SysUserOnlineController extends BaseController {
}
Collections.reverse(userOnlineList);
userOnlineList.removeAll(Collections.singleton(null));
return PageUtils.buildDataInfo(userOnlineList);
return TableDataInfo.build(userOnlineList);
}
/**

View File

@ -1,10 +1,10 @@
package com.ruoyi.web.controller.system;
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.domain.PageQuery;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
@ -12,6 +12,7 @@ import com.ruoyi.system.domain.SysConfig;
import com.ruoyi.system.service.ISysConfigService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
@ -41,14 +42,14 @@ public class SysConfigController extends BaseController {
@ApiOperation("获取参数配置列表")
@PreAuthorize("@ss.hasPermi('system:config:list')")
@GetMapping("/list")
public TableDataInfo<SysConfig> list(SysConfig config) {
return configService.selectPageConfigList(config);
public TableDataInfo<SysConfig> list(SysConfig config, PageQuery pageQuery) {
return configService.selectPageConfigList(config, pageQuery);
}
@ApiOperation("导出参数配置列表")
@Log(title = "参数管理", businessType = BusinessType.EXPORT)
@PreAuthorize("@ss.hasPermi('system:config:export')")
@GetMapping("/export")
@PostMapping("/export")
public void export(SysConfig config, HttpServletResponse response) {
List<SysConfig> list = configService.selectConfigList(config);
ExcelUtil.exportExcel(list, "参数数据", SysConfig.class, response);
@ -60,7 +61,7 @@ public class SysConfigController extends BaseController {
@ApiOperation("根据参数编号获取详细信息")
@PreAuthorize("@ss.hasPermi('system:config:query')")
@GetMapping(value = "/{configId}")
public AjaxResult<SysConfig> getInfo(@PathVariable Long configId) {
public AjaxResult<SysConfig> getInfo(@ApiParam("参数ID") @PathVariable Long configId) {
return AjaxResult.success(configService.selectConfigById(configId));
}
@ -69,7 +70,7 @@ public class SysConfigController extends BaseController {
*/
@ApiOperation("根据参数键名查询参数值")
@GetMapping(value = "/configKey/{configKey}")
public AjaxResult<Void> getConfigKey(@PathVariable String configKey) {
public AjaxResult<Void> getConfigKey(@ApiParam("参数Key") @PathVariable String configKey) {
return AjaxResult.success(configService.selectConfigByKey(configKey));
}
@ -80,7 +81,6 @@ public class SysConfigController extends BaseController {
@PreAuthorize("@ss.hasPermi('system:config:add')")
@Log(title = "参数管理", businessType = BusinessType.INSERT)
@PostMapping
@RepeatSubmit
public AjaxResult<Void> add(@Validated @RequestBody SysConfig config) {
if (UserConstants.NOT_UNIQUE.equals(configService.checkConfigKeyUnique(config))) {
return AjaxResult.error("新增参数'" + config.getConfigName() + "'失败,参数键名已存在");
@ -109,7 +109,7 @@ public class SysConfigController extends BaseController {
@PreAuthorize("@ss.hasPermi('system:config:remove')")
@Log(title = "参数管理", businessType = BusinessType.DELETE)
@DeleteMapping("/{configIds}")
public AjaxResult<Void> remove(@PathVariable Long[] configIds) {
public AjaxResult<Void> remove(@ApiParam("参数ID串") @PathVariable Long[] configIds) {
configService.deleteConfigByIds(configIds);
return success();
}

View File

@ -1,17 +1,18 @@
package com.ruoyi.web.controller.system;
import cn.hutool.core.lang.tree.Tree;
import cn.hutool.core.util.ArrayUtil;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.constant.UserConstants;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.TreeSelect;
import com.ruoyi.common.core.domain.entity.SysDept;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.system.service.ISysDeptService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
@ -53,7 +54,7 @@ public class SysDeptController extends BaseController {
@ApiOperation("查询部门列表(排除节点)")
@PreAuthorize("@ss.hasPermi('system:dept:list')")
@GetMapping("/list/exclude/{deptId}")
public AjaxResult<List<SysDept>> excludeChild(@PathVariable(value = "deptId", required = false) Long deptId) {
public AjaxResult<List<SysDept>> excludeChild(@ApiParam("部门ID") @PathVariable(value = "deptId", required = false) Long deptId) {
List<SysDept> depts = deptService.selectDeptList(new SysDept());
depts.removeIf(d -> d.getDeptId().equals(deptId)
|| ArrayUtil.contains(StringUtils.split(d.getAncestors(), ","), deptId + ""));
@ -66,7 +67,7 @@ public class SysDeptController extends BaseController {
@ApiOperation("根据部门编号获取详细信息")
@PreAuthorize("@ss.hasPermi('system:dept:query')")
@GetMapping(value = "/{deptId}")
public AjaxResult<SysDept> getInfo(@PathVariable Long deptId) {
public AjaxResult<SysDept> getInfo(@ApiParam("部门ID") @PathVariable Long deptId) {
deptService.checkDeptDataScope(deptId);
return AjaxResult.success(deptService.selectDeptById(deptId));
}
@ -76,7 +77,7 @@ public class SysDeptController extends BaseController {
*/
@ApiOperation("获取部门下拉树列表")
@GetMapping("/treeselect")
public AjaxResult<List<TreeSelect>> treeselect(SysDept dept) {
public AjaxResult<List<Tree<Long>>> treeselect(SysDept dept) {
List<SysDept> depts = deptService.selectDeptList(dept);
return AjaxResult.success(deptService.buildDeptTreeSelect(depts));
}
@ -86,7 +87,7 @@ public class SysDeptController extends BaseController {
*/
@ApiOperation("加载对应角色部门列表树")
@GetMapping(value = "/roleDeptTreeselect/{roleId}")
public AjaxResult<Map<String, Object>> roleDeptTreeselect(@PathVariable("roleId") Long roleId) {
public AjaxResult<Map<String, Object>> roleDeptTreeselect(@ApiParam("角色ID") @PathVariable("roleId") Long roleId) {
List<SysDept> depts = deptService.selectDeptList(new SysDept());
Map<String, Object> ajax = new HashMap<>();
ajax.put("checkedKeys", deptService.selectDeptListByRoleId(roleId));
@ -134,7 +135,7 @@ public class SysDeptController extends BaseController {
@PreAuthorize("@ss.hasPermi('system:dept:remove')")
@Log(title = "部门管理", businessType = BusinessType.DELETE)
@DeleteMapping("/{deptId}")
public AjaxResult<Void> remove(@PathVariable Long deptId) {
public AjaxResult<Void> remove(@ApiParam("部门ID串") @PathVariable Long deptId) {
if (deptService.hasChildByDeptId(deptId)) {
return AjaxResult.error("存在下级部门,不允许删除");
}

View File

@ -3,6 +3,7 @@ package com.ruoyi.web.controller.system;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.PageQuery;
import com.ruoyi.common.core.domain.entity.SysDictData;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
@ -12,6 +13,7 @@ import com.ruoyi.system.service.ISysDictDataService;
import com.ruoyi.system.service.ISysDictTypeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
@ -40,14 +42,14 @@ public class SysDictDataController extends BaseController {
@ApiOperation("查询字典数据列表")
@PreAuthorize("@ss.hasPermi('system:dict:list')")
@GetMapping("/list")
public TableDataInfo<SysDictData> list(SysDictData dictData) {
return dictDataService.selectPageDictDataList(dictData);
public TableDataInfo<SysDictData> list(SysDictData dictData, PageQuery pageQuery) {
return dictDataService.selectPageDictDataList(dictData, pageQuery);
}
@ApiOperation("导出字典数据列表")
@Log(title = "字典数据", businessType = BusinessType.EXPORT)
@PreAuthorize("@ss.hasPermi('system:dict:export')")
@GetMapping("/export")
@PostMapping("/export")
public void export(SysDictData dictData, HttpServletResponse response) {
List<SysDictData> list = dictDataService.selectDictDataList(dictData);
ExcelUtil.exportExcel(list, "字典数据", SysDictData.class, response);
@ -59,7 +61,7 @@ public class SysDictDataController extends BaseController {
@ApiOperation("查询字典数据详细")
@PreAuthorize("@ss.hasPermi('system:dict:query')")
@GetMapping(value = "/{dictCode}")
public AjaxResult<SysDictData> getInfo(@PathVariable Long dictCode) {
public AjaxResult<SysDictData> getInfo(@ApiParam("字典code") @PathVariable Long dictCode) {
return AjaxResult.success(dictDataService.selectDictDataById(dictCode));
}
@ -68,7 +70,7 @@ public class SysDictDataController extends BaseController {
*/
@ApiOperation("根据字典类型查询字典数据信息")
@GetMapping(value = "/type/{dictType}")
public AjaxResult<List<SysDictData>> dictType(@PathVariable String dictType) {
public AjaxResult<List<SysDictData>> dictType(@ApiParam("字典类型") @PathVariable String dictType) {
List<SysDictData> data = dictTypeService.selectDictDataByType(dictType);
if (StringUtils.isNull(data)) {
data = new ArrayList<>();
@ -105,7 +107,7 @@ public class SysDictDataController extends BaseController {
@PreAuthorize("@ss.hasPermi('system:dict:remove')")
@Log(title = "字典类型", businessType = BusinessType.DELETE)
@DeleteMapping("/{dictCodes}")
public AjaxResult<Void> remove(@PathVariable Long[] dictCodes) {
public AjaxResult<Void> remove(@ApiParam("字典code串") @PathVariable Long[] dictCodes) {
dictDataService.deleteDictDataByIds(dictCodes);
return success();
}

View File

@ -4,6 +4,7 @@ import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.constant.UserConstants;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.PageQuery;
import com.ruoyi.common.core.domain.entity.SysDictType;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
@ -11,6 +12,7 @@ import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.system.service.ISysDictTypeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
@ -37,14 +39,14 @@ public class SysDictTypeController extends BaseController {
@ApiOperation("查询字典类型列表")
@PreAuthorize("@ss.hasPermi('system:dict:list')")
@GetMapping("/list")
public TableDataInfo<SysDictType> list(SysDictType dictType) {
return dictTypeService.selectPageDictTypeList(dictType);
public TableDataInfo<SysDictType> list(SysDictType dictType, PageQuery pageQuery) {
return dictTypeService.selectPageDictTypeList(dictType, pageQuery);
}
@ApiOperation("导出字典类型列表")
@Log(title = "字典类型", businessType = BusinessType.EXPORT)
@PreAuthorize("@ss.hasPermi('system:dict:export')")
@GetMapping("/export")
@PostMapping("/export")
public void export(SysDictType dictType, HttpServletResponse response) {
List<SysDictType> list = dictTypeService.selectDictTypeList(dictType);
ExcelUtil.exportExcel(list, "字典类型", SysDictType.class, response);
@ -56,7 +58,7 @@ public class SysDictTypeController extends BaseController {
@ApiOperation("查询字典类型详细")
@PreAuthorize("@ss.hasPermi('system:dict:query')")
@GetMapping(value = "/{dictId}")
public AjaxResult<SysDictType> getInfo(@PathVariable Long dictId) {
public AjaxResult<SysDictType> getInfo(@ApiParam("字典ID") @PathVariable Long dictId) {
return AjaxResult.success(dictTypeService.selectDictTypeById(dictId));
}
@ -95,7 +97,7 @@ public class SysDictTypeController extends BaseController {
@PreAuthorize("@ss.hasPermi('system:dict:remove')")
@Log(title = "字典类型", businessType = BusinessType.DELETE)
@DeleteMapping("/{dictIds}")
public AjaxResult<Void> remove(@PathVariable Long[] dictIds) {
public AjaxResult<Void> remove(@ApiParam("字典ID串") @PathVariable Long[] dictIds) {
dictTypeService.deleteDictTypeByIds(dictIds);
return success();
}

View File

@ -8,6 +8,7 @@ import com.ruoyi.common.core.domain.model.LoginBody;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.system.domain.vo.RouterVo;
import com.ruoyi.system.service.ISysMenuService;
import com.ruoyi.system.service.ISysUserService;
import com.ruoyi.system.service.SysLoginService;
import com.ruoyi.system.service.SysPermissionService;
import io.swagger.annotations.Api;
@ -31,13 +32,14 @@ import java.util.Set;
* @author Lion Li
*/
@Validated
@Api(value = "数据字典信息控制器", tags = {"数据字典信息管理"})
@Api(value = "登录验证控制器", tags = {"登录验证管理"})
@RequiredArgsConstructor(onConstructor_ = @Autowired)
@RestController
public class SysLoginController {
private final SysLoginService loginService;
private final ISysMenuService menuService;
private final ISysUserService userService;
private final SysPermissionService permissionService;
/**
@ -65,7 +67,7 @@ public class SysLoginController {
@ApiOperation("获取用户信息")
@GetMapping("getInfo")
public AjaxResult<Map<String, Object>> getInfo() {
SysUser user = SecurityUtils.getLoginUser().getUser();
SysUser user = userService.selectUserById(SecurityUtils.getUserId());
// 角色集合
Set<String> roles = permissionService.getRolePermission(user);
// 权限集合

View File

@ -1,16 +1,17 @@
package com.ruoyi.web.controller.system;
import cn.hutool.core.lang.tree.Tree;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.constant.UserConstants;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.TreeSelect;
import com.ruoyi.common.core.domain.entity.SysMenu;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.system.service.ISysMenuService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
@ -52,7 +53,7 @@ public class SysMenuController extends BaseController {
@ApiOperation("根据菜单编号获取详细信息")
@PreAuthorize("@ss.hasPermi('system:menu:query')")
@GetMapping(value = "/{menuId}")
public AjaxResult<SysMenu> getInfo(@PathVariable Long menuId) {
public AjaxResult<SysMenu> getInfo(@ApiParam("菜单ID") @PathVariable Long menuId) {
return AjaxResult.success(menuService.selectMenuById(menuId));
}
@ -61,7 +62,7 @@ public class SysMenuController extends BaseController {
*/
@ApiOperation("获取菜单下拉树列表")
@GetMapping("/treeselect")
public AjaxResult<List<TreeSelect>> treeselect(SysMenu menu) {
public AjaxResult<List<Tree<Long>>> treeselect(SysMenu menu) {
List<SysMenu> menus = menuService.selectMenuList(menu, getUserId());
return AjaxResult.success(menuService.buildMenuTreeSelect(menus));
}
@ -71,7 +72,7 @@ public class SysMenuController extends BaseController {
*/
@ApiOperation("加载对应角色菜单列表树")
@GetMapping(value = "/roleMenuTreeselect/{roleId}")
public AjaxResult<Map<String, Object>> roleMenuTreeselect(@PathVariable("roleId") Long roleId) {
public AjaxResult<Map<String, Object>> roleMenuTreeselect(@ApiParam("角色ID") @PathVariable("roleId") Long roleId) {
List<SysMenu> menus = menuService.selectMenuList(getUserId());
Map<String, Object> ajax = new HashMap<>();
ajax.put("checkedKeys", menuService.selectMenuListByRoleId(roleId));
@ -120,7 +121,7 @@ public class SysMenuController extends BaseController {
@PreAuthorize("@ss.hasPermi('system:menu:remove')")
@Log(title = "菜单管理", businessType = BusinessType.DELETE)
@DeleteMapping("/{menuId}")
public AjaxResult<Void> remove(@PathVariable("menuId") Long menuId) {
public AjaxResult<Void> remove(@ApiParam("菜单ID") @PathVariable("menuId") Long menuId) {
if (menuService.hasChildByMenuId(menuId)) {
return AjaxResult.error("存在子菜单,不允许删除");
}

View File

@ -3,12 +3,14 @@ package com.ruoyi.web.controller.system;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.PageQuery;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.SysNotice;
import com.ruoyi.system.service.ISysNoticeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
@ -35,8 +37,8 @@ public class SysNoticeController extends BaseController {
@ApiOperation("获取通知公告列表")
@PreAuthorize("@ss.hasPermi('system:notice:list')")
@GetMapping("/list")
public TableDataInfo<SysNotice> list(SysNotice notice) {
return noticeService.selectPageNoticeList(notice);
public TableDataInfo<SysNotice> list(SysNotice notice, PageQuery pageQuery) {
return noticeService.selectPageNoticeList(notice, pageQuery);
}
/**
@ -45,7 +47,7 @@ public class SysNoticeController extends BaseController {
@ApiOperation("根据通知公告编号获取详细信息")
@PreAuthorize("@ss.hasPermi('system:notice:query')")
@GetMapping(value = "/{noticeId}")
public AjaxResult<SysNotice> getInfo(@PathVariable Long noticeId) {
public AjaxResult<SysNotice> getInfo(@ApiParam("公告ID") @PathVariable Long noticeId) {
return AjaxResult.success(noticeService.selectNoticeById(noticeId));
}
@ -78,7 +80,7 @@ public class SysNoticeController extends BaseController {
@PreAuthorize("@ss.hasPermi('system:notice:remove')")
@Log(title = "通知公告", businessType = BusinessType.DELETE)
@DeleteMapping("/{noticeIds}")
public AjaxResult<Void> remove(@PathVariable Long[] noticeIds) {
public AjaxResult<Void> remove(@ApiParam("公告ID串") @PathVariable Long[] noticeIds) {
return toAjax(noticeService.deleteNoticeByIds(noticeIds));
}
}

View File

@ -4,6 +4,7 @@ import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.annotation.RepeatSubmit;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.PageQuery;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.core.validate.AddGroup;
import com.ruoyi.common.core.validate.EditGroup;
@ -14,6 +15,7 @@ import com.ruoyi.system.domain.vo.SysOssConfigVo;
import com.ruoyi.system.service.ISysOssConfigService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
@ -46,8 +48,8 @@ public class SysOssConfigController extends BaseController {
@ApiOperation("查询对象存储配置列表")
@PreAuthorize("@ss.hasPermi('system:oss:list')")
@GetMapping("/list")
public TableDataInfo<SysOssConfigVo> list(@Validated(QueryGroup.class) SysOssConfigBo bo) {
return iSysOssConfigService.queryPageList(bo);
public TableDataInfo<SysOssConfigVo> list(@Validated(QueryGroup.class) SysOssConfigBo bo, PageQuery pageQuery) {
return iSysOssConfigService.queryPageList(bo, pageQuery);
}
/**
@ -56,7 +58,8 @@ public class SysOssConfigController extends BaseController {
@ApiOperation("获取对象存储配置详细信息")
@PreAuthorize("@ss.hasPermi('system:oss:query')")
@GetMapping("/{ossConfigId}")
public AjaxResult<SysOssConfigVo> getInfo(@NotNull(message = "主键不能为空")
public AjaxResult<SysOssConfigVo> getInfo(@ApiParam("OSS配置ID")
@NotNull(message = "主键不能为空")
@PathVariable("ossConfigId") Integer ossConfigId) {
return AjaxResult.success(iSysOssConfigService.queryById(ossConfigId));
}
@ -92,7 +95,8 @@ public class SysOssConfigController extends BaseController {
@PreAuthorize("@ss.hasPermi('system:oss:remove')")
@Log(title = "对象存储配置", businessType = BusinessType.DELETE)
@DeleteMapping("/{ossConfigIds}")
public AjaxResult<Void> remove(@NotEmpty(message = "主键不能为空")
public AjaxResult<Void> remove(@ApiParam("OSS配置ID串")
@NotEmpty(message = "主键不能为空")
@PathVariable Long[] ossConfigIds) {
return toAjax(iSysOssConfigService.deleteWithValidByIds(Arrays.asList(ossConfigIds), true) ? 1 : 0);
}

View File

@ -10,23 +10,21 @@ import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.annotation.RepeatSubmit;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.PageQuery;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.core.validate.QueryGroup;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.common.utils.JsonUtils;
import com.ruoyi.common.utils.file.FileUtils;
import com.ruoyi.oss.constant.CloudConstant;
import com.ruoyi.oss.constant.OssConstant;
import com.ruoyi.system.domain.SysConfig;
import com.ruoyi.system.domain.SysOss;
import com.ruoyi.system.domain.bo.SysOssBo;
import com.ruoyi.system.domain.vo.SysOssVo;
import com.ruoyi.system.service.ISysConfigService;
import com.ruoyi.system.service.ISysOssService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.*;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
@ -37,6 +35,7 @@ import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
import javax.validation.constraints.NotEmpty;
import java.io.File;
import java.io.IOException;
import java.util.Arrays;
import java.util.HashMap;
@ -63,8 +62,8 @@ public class SysOssController extends BaseController {
@ApiOperation("查询OSS对象存储列表")
@PreAuthorize("@ss.hasPermi('system:oss:list')")
@GetMapping("/list")
public TableDataInfo<SysOssVo> list(@Validated(QueryGroup.class) SysOssBo bo) {
return iSysOssService.queryPageList(bo);
public TableDataInfo<SysOssVo> list(@Validated(QueryGroup.class) SysOssBo bo, PageQuery pageQuery) {
return iSysOssService.queryPageList(bo, pageQuery);
}
/**
@ -72,7 +71,7 @@ public class SysOssController extends BaseController {
*/
@ApiOperation("上传OSS对象存储")
@ApiImplicitParams({
@ApiImplicitParam(name = "file", value = "文件", dataType = "java.io.File", required = true),
@ApiImplicitParam(name = "file", value = "文件", dataTypeClass = File.class, required = true),
})
@PreAuthorize("@ss.hasPermi('system:oss:upload')")
@Log(title = "OSS对象存储", businessType = BusinessType.INSERT)
@ -92,7 +91,7 @@ public class SysOssController extends BaseController {
@ApiOperation("下载OSS对象存储")
@PreAuthorize("@ss.hasPermi('system:oss:download')")
@GetMapping("/download/{ossId}")
public void download(@PathVariable Long ossId, HttpServletResponse response) throws IOException {
public void download(@ApiParam("OSS对象ID") @PathVariable Long ossId, HttpServletResponse response) throws IOException {
SysOss sysOss = iSysOssService.getById(ossId);
if (ObjectUtil.isNull(sysOss)) {
throw new ServiceException("文件数据不存在!");
@ -120,7 +119,8 @@ public class SysOssController extends BaseController {
@PreAuthorize("@ss.hasPermi('system:oss:remove')")
@Log(title = "OSS对象存储", businessType = BusinessType.DELETE)
@DeleteMapping("/{ossIds}")
public AjaxResult<Void> remove(@NotEmpty(message = "主键不能为空")
public AjaxResult<Void> remove(@ApiParam("OSS对象ID串")
@NotEmpty(message = "主键不能为空")
@PathVariable Long[] ossIds) {
return toAjax(iSysOssService.deleteWithValidByIds(Arrays.asList(ossIds), true) ? 1 : 0);
}
@ -135,7 +135,7 @@ public class SysOssController extends BaseController {
public AjaxResult<Void> changePreviewListResource(@RequestBody String body) {
Map<String, Boolean> map = JsonUtils.parseMap(body);
SysConfig config = iSysConfigService.getOne(new LambdaQueryWrapper<SysConfig>()
.eq(SysConfig::getConfigKey, CloudConstant.PEREVIEW_LIST_RESOURCE_KEY));
.eq(SysConfig::getConfigKey, OssConstant.PEREVIEW_LIST_RESOURCE_KEY));
config.setConfigValue(map.get("previewListResource").toString());
return toAjax(iSysConfigService.updateConfig(config));
}

View File

@ -4,6 +4,7 @@ import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.constant.UserConstants;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.PageQuery;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
@ -11,6 +12,7 @@ import com.ruoyi.system.domain.SysPost;
import com.ruoyi.system.service.ISysPostService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
@ -40,14 +42,14 @@ public class SysPostController extends BaseController {
@ApiOperation("获取岗位列表")
@PreAuthorize("@ss.hasPermi('system:post:list')")
@GetMapping("/list")
public TableDataInfo<SysPost> list(SysPost post) {
return postService.selectPagePostList(post);
public TableDataInfo<SysPost> list(SysPost post, PageQuery pageQuery) {
return postService.selectPagePostList(post, pageQuery);
}
@ApiOperation("导出岗位列表")
@Log(title = "岗位管理", businessType = BusinessType.EXPORT)
@PreAuthorize("@ss.hasPermi('system:post:export')")
@GetMapping("/export")
@PostMapping("/export")
public void export(SysPost post, HttpServletResponse response) {
List<SysPost> list = postService.selectPostList(post);
ExcelUtil.exportExcel(list, "岗位数据", SysPost.class, response);
@ -59,7 +61,7 @@ public class SysPostController extends BaseController {
@ApiOperation("根据岗位编号获取详细信息")
@PreAuthorize("@ss.hasPermi('system:post:query')")
@GetMapping(value = "/{postId}")
public AjaxResult<SysPost> getInfo(@PathVariable Long postId) {
public AjaxResult<SysPost> getInfo(@ApiParam("岗位ID") @PathVariable Long postId) {
return AjaxResult.success(postService.selectPostById(postId));
}
@ -102,7 +104,7 @@ public class SysPostController extends BaseController {
@PreAuthorize("@ss.hasPermi('system:post:remove')")
@Log(title = "岗位管理", businessType = BusinessType.DELETE)
@DeleteMapping("/{postIds}")
public AjaxResult<Void> remove(@PathVariable Long[] postIds) {
public AjaxResult<Void> remove(@ApiParam("岗位ID串") @PathVariable Long[] postIds) {
return toAjax(postService.deletePostByIds(postIds));
}

View File

@ -13,13 +13,17 @@ import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.system.domain.SysOss;
import com.ruoyi.system.service.ISysOssService;
import com.ruoyi.system.service.ISysUserService;
import io.swagger.annotations.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import java.io.File;
import java.util.HashMap;
import java.util.Map;
@ -46,7 +50,7 @@ public class SysProfileController extends BaseController {
@GetMapping
public AjaxResult<Map<String, Object>> profile() {
LoginUser loginUser = getLoginUser();
SysUser user = loginUser.getUser();
SysUser user = userService.selectUserById(loginUser.getUserId());
Map<String, Object> ajax = new HashMap<>();
ajax.put("user", user);
ajax.put("roleGroup", userService.selectUserRoleGroup(loginUser.getUsername()));
@ -70,16 +74,11 @@ public class SysProfileController extends BaseController {
return AjaxResult.error("修改用户'" + user.getUserName() + "'失败,邮箱账号已存在");
}
LoginUser loginUser = getLoginUser();
SysUser sysUser = loginUser.getUser();
SysUser sysUser = userService.selectUserById(loginUser.getUserId());
user.setUserId(sysUser.getUserId());
user.setUserName(null);
user.setPassword(null);
if (userService.updateUserProfile(user) > 0) {
// 更新缓存用户信息
sysUser.setNickName(user.getNickName());
sysUser.setPhonenumber(user.getPhonenumber());
sysUser.setEmail(user.getEmail());
sysUser.setSex(user.getSex());
tokenService.setLoginUser(loginUser);
return AjaxResult.success();
}
return AjaxResult.error("修改个人信息异常,请联系管理员");
@ -89,12 +88,16 @@ public class SysProfileController extends BaseController {
* 重置密码
*/
@ApiOperation("重置密码")
@ApiImplicitParams({
@ApiImplicitParam(name = "oldPassword", value = "旧密码", paramType = "query", dataTypeClass = String.class),
@ApiImplicitParam(name = "newPassword", value = "新密码", paramType = "query", dataTypeClass = String.class)
})
@Log(title = "个人信息", businessType = BusinessType.UPDATE)
@PutMapping("/updatePwd")
public AjaxResult<Void> updatePwd(String oldPassword, String newPassword) {
LoginUser loginUser = getLoginUser();
String userName = loginUser.getUsername();
String password = loginUser.getPassword();
SysUser user = userService.selectUserById(SecurityUtils.getUserId());
String userName = user.getUserName();
String password = user.getPassword();
if (!SecurityUtils.matchesPassword(oldPassword, password)) {
return AjaxResult.error("修改密码失败,旧密码错误");
}
@ -102,9 +105,6 @@ public class SysProfileController extends BaseController {
return AjaxResult.error("新密码不能与旧密码相同");
}
if (userService.resetUserPwd(userName, SecurityUtils.encryptPassword(newPassword)) > 0) {
// 更新缓存用户密码
loginUser.getUser().setPassword(SecurityUtils.encryptPassword(newPassword));
tokenService.setLoginUser(loginUser);
return AjaxResult.success();
}
return AjaxResult.error("修改密码异常,请联系管理员");
@ -115,7 +115,7 @@ public class SysProfileController extends BaseController {
*/
@ApiOperation("头像上传")
@ApiImplicitParams({
@ApiImplicitParam(name = "file", value = "用户头像", dataType = "java.io.File", required = true),
@ApiImplicitParam(name = "avatarfile", value = "用户头像", dataTypeClass = File.class, required = true),
})
@Log(title = "用户头像", businessType = BusinessType.UPDATE)
@PostMapping("/avatar")
@ -127,9 +127,6 @@ public class SysProfileController extends BaseController {
String avatar = oss.getUrl();
if (userService.updateUserAvatar(loginUser.getUsername(), avatar)) {
ajax.put("imgUrl", avatar);
// 更新缓存用户头像
loginUser.getUser().setAvatar(avatar);
tokenService.setLoginUser(loginUser);
return AjaxResult.success(ajax);
}
}

View File

@ -4,6 +4,7 @@ import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.constant.UserConstants;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.PageQuery;
import com.ruoyi.common.core.domain.entity.SysRole;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.core.domain.model.LoginUser;
@ -16,8 +17,7 @@ import com.ruoyi.system.domain.SysUserRole;
import com.ruoyi.system.service.ISysRoleService;
import com.ruoyi.system.service.ISysUserService;
import com.ruoyi.system.service.SysPermissionService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.*;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
@ -47,14 +47,14 @@ public class SysRoleController extends BaseController {
@ApiOperation("查询角色信息列表")
@PreAuthorize("@ss.hasPermi('system:role:list')")
@GetMapping("/list")
public TableDataInfo<SysRole> list(SysRole role) {
return roleService.selectPageRoleList(role);
public TableDataInfo<SysRole> list(SysRole role, PageQuery pageQuery) {
return roleService.selectPageRoleList(role, pageQuery);
}
@ApiOperation("导出角色信息列表")
@Log(title = "角色管理", businessType = BusinessType.EXPORT)
@PreAuthorize("@ss.hasPermi('system:role:export')")
@GetMapping("/export")
@PostMapping("/export")
public void export(SysRole role, HttpServletResponse response) {
List<SysRole> list = roleService.selectRoleList(role);
ExcelUtil.exportExcel(list, "角色数据", SysRole.class, response);
@ -66,7 +66,7 @@ public class SysRoleController extends BaseController {
@ApiOperation("根据角色编号获取详细信息")
@PreAuthorize("@ss.hasPermi('system:role:query')")
@GetMapping(value = "/{roleId}")
public AjaxResult<SysRole> getInfo(@PathVariable Long roleId) {
public AjaxResult<SysRole> getInfo(@ApiParam("角色ID") @PathVariable Long roleId) {
roleService.checkRoleDataScope(roleId);
return AjaxResult.success(roleService.selectRoleById(roleId));
}
@ -106,9 +106,9 @@ public class SysRoleController extends BaseController {
if (roleService.updateRole(role) > 0) {
// 更新缓存用户权限
LoginUser loginUser = getLoginUser();
if (StringUtils.isNotNull(loginUser.getUser()) && !loginUser.getUser().isAdmin()) {
loginUser.setPermissions(permissionService.getMenuPermission(loginUser.getUser()));
loginUser.setUser(userService.selectUserByUserName(loginUser.getUser().getUserName()));
SysUser sysUser = userService.selectUserById(loginUser.getUserId());
if (StringUtils.isNotNull(sysUser) && !sysUser.isAdmin()) {
loginUser.setMenuPermissions(permissionService.getMenuPermission(sysUser));
tokenService.setLoginUser(loginUser);
}
return AjaxResult.success();
@ -147,7 +147,7 @@ public class SysRoleController extends BaseController {
@PreAuthorize("@ss.hasPermi('system:role:remove')")
@Log(title = "角色管理", businessType = BusinessType.DELETE)
@DeleteMapping("/{roleIds}")
public AjaxResult<Void> remove(@PathVariable Long[] roleIds) {
public AjaxResult<Void> remove(@ApiParam("岗位ID串") @PathVariable Long[] roleIds) {
return toAjax(roleService.deleteRoleByIds(roleIds));
}
@ -167,8 +167,8 @@ public class SysRoleController extends BaseController {
@ApiOperation("查询已分配用户角色列表")
@PreAuthorize("@ss.hasPermi('system:role:list')")
@GetMapping("/authUser/allocatedList")
public TableDataInfo<SysUser> allocatedList(SysUser user) {
return userService.selectAllocatedList(user);
public TableDataInfo<SysUser> allocatedList(SysUser user, PageQuery pageQuery) {
return userService.selectAllocatedList(user, pageQuery);
}
/**
@ -177,8 +177,8 @@ public class SysRoleController extends BaseController {
@ApiOperation("查询未分配用户角色列表")
@PreAuthorize("@ss.hasPermi('system:role:list')")
@GetMapping("/authUser/unallocatedList")
public TableDataInfo<SysUser> unallocatedList(SysUser user) {
return userService.selectUnallocatedList(user);
public TableDataInfo<SysUser> unallocatedList(SysUser user, PageQuery pageQuery) {
return userService.selectUnallocatedList(user, pageQuery);
}
/**
@ -196,6 +196,10 @@ public class SysRoleController extends BaseController {
* 批量取消授权用户
*/
@ApiOperation("批量取消授权用户")
@ApiImplicitParams({
@ApiImplicitParam(name = "roleId", value = "角色ID", paramType = "query", dataTypeClass = String.class),
@ApiImplicitParam(name = "userIds", value = "用户ID串", paramType = "query", dataTypeClass = String.class)
})
@PreAuthorize("@ss.hasPermi('system:role:edit')")
@Log(title = "角色管理", businessType = BusinessType.GRANT)
@PutMapping("/authUser/cancelAll")
@ -207,6 +211,10 @@ public class SysRoleController extends BaseController {
* 批量选择用户授权
*/
@ApiOperation("批量选择用户授权")
@ApiImplicitParams({
@ApiImplicitParam(name = "roleId", value = "角色ID", paramType = "query", dataTypeClass = String.class),
@ApiImplicitParam(name = "userIds", value = "用户ID串", paramType = "query", dataTypeClass = String.class)
})
@PreAuthorize("@ss.hasPermi('system:role:edit')")
@Log(title = "角色管理", businessType = BusinessType.GRANT)
@PutMapping("/authUser/selectAll")

View File

@ -7,23 +7,23 @@ import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.constant.UserConstants;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.PageQuery;
import com.ruoyi.common.core.domain.entity.SysDept;
import com.ruoyi.common.core.domain.entity.SysRole;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.excel.ExcelResult;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.system.domain.vo.SysUserExportVo;
import com.ruoyi.system.domain.vo.SysUserImportVo;
import com.ruoyi.system.listener.SysUserImportListener;
import com.ruoyi.system.service.ISysPostService;
import com.ruoyi.system.service.ISysRoleService;
import com.ruoyi.system.service.ISysUserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.*;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
@ -60,14 +60,14 @@ public class SysUserController extends BaseController {
@ApiOperation("获取用户列表")
@PreAuthorize("@ss.hasPermi('system:user:list')")
@GetMapping("/list")
public TableDataInfo<SysUser> list(SysUser user) {
return userService.selectPageUserList(user);
public TableDataInfo<SysUser> list(SysUser user, PageQuery pageQuery) {
return userService.selectPageUserList(user, pageQuery);
}
@ApiOperation("导出用户列表")
@Log(title = "用户管理", businessType = BusinessType.EXPORT)
@PreAuthorize("@ss.hasPermi('system:user:export')")
@GetMapping("/export")
@PostMapping("/export")
public void export(SysUser user, HttpServletResponse response) {
List<SysUser> list = userService.selectUserList(user);
List<SysUserExportVo> listVo = BeanUtil.copyToList(list, SysUserExportVo.class);
@ -90,15 +90,12 @@ public class SysUserController extends BaseController {
@PreAuthorize("@ss.hasPermi('system:user:import')")
@PostMapping("/importData")
public AjaxResult<Void> importData(@RequestPart("file") MultipartFile file, boolean updateSupport) throws Exception {
List<SysUserImportVo> userListVo = ExcelUtil.importExcel(file.getInputStream(), SysUserImportVo.class);
List<SysUser> userList = BeanUtil.copyToList(userListVo, SysUser.class);
String operName = getUsername();
String message = userService.importUser(userList, updateSupport, operName);
return AjaxResult.success(message);
ExcelResult<SysUserImportVo> result = ExcelUtil.importExcel(file.getInputStream(), SysUserImportVo.class, new SysUserImportListener(updateSupport));
return AjaxResult.success(result.getAnalysis());
}
@ApiOperation("下载导入模板")
@GetMapping("/importTemplate")
@PostMapping("/importTemplate")
public void importTemplate(HttpServletResponse response) {
ExcelUtil.exportExcel(new ArrayList<>(), "用户数据", SysUserImportVo.class, response);
}
@ -109,7 +106,7 @@ public class SysUserController extends BaseController {
@ApiOperation("根据用户编号获取详细信息")
@PreAuthorize("@ss.hasPermi('system:user:query')")
@GetMapping(value = {"/", "/{userId}"})
public AjaxResult<Map<String, Object>> getInfo(@PathVariable(value = "userId", required = false) Long userId) {
public AjaxResult<Map<String, Object>> getInfo(@ApiParam("用户ID") @PathVariable(value = "userId", required = false) Long userId) {
userService.checkUserDataScope(userId);
Map<String, Object> ajax = new HashMap<>();
List<SysRole> roles = roleService.selectRoleAll();
@ -170,7 +167,7 @@ public class SysUserController extends BaseController {
@PreAuthorize("@ss.hasPermi('system:user:remove')")
@Log(title = "用户管理", businessType = BusinessType.DELETE)
@DeleteMapping("/{userIds}")
public AjaxResult<Void> remove(@PathVariable Long[] userIds) {
public AjaxResult<Void> remove(@ApiParam("角色ID串") @PathVariable Long[] userIds) {
if (ArrayUtil.contains(userIds, getUserId())) {
return error("当前用户不能删除");
}
@ -208,7 +205,7 @@ public class SysUserController extends BaseController {
@ApiOperation("根据用户编号获取授权角色")
@PreAuthorize("@ss.hasPermi('system:user:query')")
@GetMapping("/authRole/{userId}")
public AjaxResult<Map<String, Object>> authRole(@PathVariable("userId") Long userId) {
public AjaxResult<Map<String, Object>> authRole(@ApiParam("用户ID") @PathVariable("userId") Long userId) {
SysUser user = userService.selectUserById(userId);
List<SysRole> roles = roleService.selectRolesByUserId(userId);
Map<String, Object> ajax = new HashMap<>();
@ -221,6 +218,10 @@ public class SysUserController extends BaseController {
* 用户授权角色
*/
@ApiOperation("用户授权角色")
@ApiImplicitParams({
@ApiImplicitParam(name = "userId", value = "用户Id", paramType = "query", dataTypeClass = String.class),
@ApiImplicitParam(name = "roleIds", value = "角色ID串", paramType = "query", dataTypeClass = String.class)
})
@PreAuthorize("@ss.hasPermi('system:user:edit')")
@Log(title = "用户管理", businessType = BusinessType.GRANT)
@PutMapping("/authRole")

View File

@ -51,7 +51,9 @@ spring:
# 主库数据源
master:
driverClassName: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://localhost:3306/ry-vue?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&autoReconnect=true
# jdbc 所有参数配置参考 https://lionli.blog.csdn.net/article/details/122018562
# rewriteBatchedStatements=true 批处理优化 大幅提升批量插入更新删除性能(对数据库有性能损耗 使用批量操作应考虑性能问题)
url: jdbc:mysql://localhost:3306/ry-vue?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&autoReconnect=true&rewriteBatchedStatements=true
username: root
password: root
# 从库数据源

View File

@ -1,3 +1,10 @@
--- # 配置临时路径存储
spring:
servlet:
multipart:
# 临时文件存储位置 避免临时文件被系统清理报错
location: /ruoyi/server/temp
--- # 监控配置
spring:
boot:
@ -51,7 +58,9 @@ spring:
# 主库数据源
master:
driverClassName: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://172.30.0.36:3306/ry-vue?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&autoReconnect=true
# jdbc 所有参数配置参考 https://lionli.blog.csdn.net/article/details/122018562
# rewriteBatchedStatements=true 批处理优化 大幅提升批量插入更新删除性能(对数据库有性能损耗 使用批量操作应考虑性能问题)
url: jdbc:mysql://172.30.0.36:3306/ry-vue?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&autoReconnect=true&rewriteBatchedStatements=true
username: root
password: root
# 从库数据源

View File

@ -10,6 +10,8 @@ ruoyi:
demoEnabled: true
# 获取ip地址开关
addressEnabled: true
# 缓存懒加载
cacheLazy: false
captcha:
# 页面 <参数设置> 可开启关闭 验证码校验
@ -51,10 +53,6 @@ logging:
org.springframework: warn
config: classpath:logback.xml
# tlog 全局访问性能拦截
tlog:
enable-invoke-time-print: true
# Spring配置
spring:
application:
@ -118,11 +116,11 @@ security:
- /*/api-docs
# druid 监控配置
- /druid/**
# 用户放行
permit-all:
# actuator 监控配置
- /actuator
- /actuator/**
# 用户放行
permit-all:
# 重复提交
repeat-submit:
@ -214,6 +212,22 @@ swagger:
- name: 3.代码生成模块
basePackage: com.ruoyi.generator
knife4j:
# 是否开启Knife4j增强模式
enable: true
# 是否开启生产环境保护策略
production: @knife4j.production@
# 前端Ui的个性化配置属性
setting:
# 默认语言
language: zh-CN
# 是否显示Footer
enableFooter: false
# 是否开启动态参数调试功能
enableDynamicParameter: true
# 是否在每个Debug调试栏后显示刷新变量按钮
enableReloadCacheParameter: true
# 防止XSS攻击
xss:
# 过滤开关
@ -242,22 +256,6 @@ thread-pool:
# ABORT_POLICY 中止
rejectedExecutionHandler: CALLER_RUNS_POLICY
# feign 相关配置
feign:
# 不支持多包, 如有需要可在注解配置 或 提升扫包等级
# 例如 com.**.**.feign
package: com.ruoyi.**.feign
# 开启压缩
compression:
request:
enabled: true
response:
enabled: true
okhttp:
enabled: true
circuitbreaker:
enabled: true
--- # redisson 缓存配置
redisson:
cacheGroup:
@ -293,34 +291,3 @@ management:
endpoint:
logfile:
external-file: ./logs/sys-console.log
--- # 定时任务配置
spring:
quartz:
scheduler-name: RuoyiScheduler
startup-delay: 1s
overwrite-existing-jobs: true
auto-startup: true
job-store-type: jdbc
properties:
org:
quartz:
# Scheduler 相关配置
scheduler:
instanceName: RuoyiScheduler
instanceId: AUTO
# 线程池相关配置
threadPool:
class: org.quartz.simpl.SimpleThreadPool
threadCount: 20
threadPriority: 5
# JobStore 集群配置
jobStore:
class: org.quartz.impl.jdbcjobstore.JobStoreTX
isClustered: true
clusterCheckinInterval: 15000
txIsolationLevelSerializable: true
misfireThreshold: 60000
tablePrefix: QRTZ_
# sqlserver 启用
# selectWithLockSQL: SELECT * FROM {0}LOCKS UPDLOCK WHERE LOCK_NAME = ?

View File

@ -2,12 +2,12 @@
not.null=* 必须填写
user.jcaptcha.error=验证码错误
user.jcaptcha.expire=验证码已失效
user.not.exists=用户不存在/密码错误
user.not.exists=对不起, 您的账号:{0} 不存在.
user.password.not.match=用户不存在/密码错误
user.password.retry.limit.count=密码输入错误{0}次
user.password.retry.limit.exceed=密码输入错误{0}次,帐户锁定10分钟
user.password.delete=对不起,您的账号已被删除
user.blocked=户已封禁,请联系管理员
user.password.retry.limit.exceed=密码错误次数过多,帐户锁定{0}分钟
user.password.delete=对不起,您的账号{0} 已被删除
user.blocked=对不起,您的账号:{0} 已禁用,请联系管理员
role.blocked=角色已封禁,请联系管理员
user.logout.success=退出成功
length.not.valid=长度必须在{min}到{max}个字符之间

View File

@ -2,12 +2,12 @@
not.null=* Required fill in
user.jcaptcha.error=Captcha error
user.jcaptcha.expire=Captcha invalid
user.not.exists=User does not exist/Password error
user.not.exists=Sorry, your account: {0} does not exist
user.password.not.match=User does not exist/Password error
user.password.retry.limit.count=Password input error {0} times
user.password.retry.limit.exceed=Password input error {0} times, account locked for 10 minutes
user.password.delete=Sorry, your account has been deleted
user.blocked=User disabledplease contact administrators
user.password.retry.limit.exceed=Too many password errors, account locked for {0} minutes
user.password.delete=Sorry, your account{0} has been deleted
user.blocked=Sorry, your account: {0} has been disabled. Please contact the administrator
role.blocked=Role disabledplease contact administrators
user.logout.success=Exit successful
length.not.valid=The length must be between {min} and {max} characters

View File

@ -2,12 +2,12 @@
not.null=* 必须填写
user.jcaptcha.error=验证码错误
user.jcaptcha.expire=验证码已失效
user.not.exists=用户不存在/密码错误
user.not.exists=对不起, 您的账号:{0} 不存在.
user.password.not.match=用户不存在/密码错误
user.password.retry.limit.count=密码输入错误{0}次
user.password.retry.limit.exceed=密码输入错误{0}次,帐户锁定10分钟
user.password.delete=对不起,您的账号已被删除
user.blocked=户已封禁,请联系管理员
user.password.retry.limit.exceed=密码错误次数过多,帐户锁定{0}分钟
user.password.delete=对不起,您的账号{0} 已被删除
user.blocked=对不起,您的账号:{0} 已禁用,请联系管理员
role.blocked=角色已封禁,请联系管理员
user.logout.success=退出成功
length.not.valid=长度必须在{min}到{max}个字符之间

View File

@ -31,7 +31,7 @@
<level>INFO</level>
</filter>
</appender>
<!-- 系统日志输出 -->
<appender name="file_info" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${log.path}/sys-info.log</file>
@ -54,7 +54,7 @@
<onMismatch>DENY</onMismatch>
</filter>
</appender>
<appender name="file_error" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${log.path}/sys-error.log</file>
<!-- 循环政策:基于时间创建日志文件 -->
@ -76,21 +76,7 @@
<onMismatch>DENY</onMismatch>
</filter>
</appender>
<!-- 用户访问日志输出 -->
<appender name="sys-user" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${log.path}/sys-user.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- 按天回滚 daily -->
<fileNamePattern>${log.path}/sys-user.%d{yyyy-MM-dd}.log</fileNamePattern>
<!-- 日志最大的历史 60天 -->
<maxHistory>60</maxHistory>
</rollingPolicy>
<encoder class="com.yomahub.tlog.core.enhance.logback.AspectLogbackEncoder">
<pattern>${log.pattern}</pattern>
</encoder>
</appender>
<!-- 系统模块日志级别控制 -->
<logger name="com.ruoyi" level="info" />
<!-- Spring日志级别控制 -->
@ -99,16 +85,12 @@
<root level="info">
<appender-ref ref="console" />
</root>
<!--系统操作日志-->
<root level="info">
<appender-ref ref="file_info" />
<appender-ref ref="file_error" />
<appender-ref ref="file_console" />
</root>
<!--系统用户操作日志-->
<logger name="sys-user" level="info">
<appender-ref ref="sys-user"/>
</logger>
</configuration>
</configuration>

View File

@ -22,5 +22,3 @@ outagedetection=true
outagedetectioninterval=2
# 是否过滤 Log
filter=true
# 过滤 Log 时所排除的表名列表,以逗号分隔
exclude=QRTZ_

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>ruoyi-vue-plus</artifactId>
<groupId>com.ruoyi</groupId>
<version>3.3.0</version>
<version>3.5.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
@ -64,36 +64,23 @@
<artifactId>easyexcel</artifactId>
</dependency>
<dependency>
<groupId>cglib</groupId>
<artifactId>cglib</artifactId>
</dependency>
<!-- yml解析器 -->
<dependency>
<groupId>org.yaml</groupId>
<artifactId>snakeyaml</artifactId>
</dependency>
<!-- Token生成与解析-->
<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt</artifactId>
</dependency>
<!-- jdk11 缺失依赖 jaxb-->
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-impl</artifactId>
</dependency>
<!-- redis 缓存操作 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
</dependency>
<!-- pool 对象池 -->
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-pool2</artifactId>
</dependency>
<!-- servlet包 -->
<dependency>
<groupId>javax.servlet</groupId>
@ -108,32 +95,43 @@
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-extension</artifactId>
</dependency>
<!-- dynamic-datasource 多数据源-->
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>dynamic-datasource-spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-all</artifactId>
<artifactId>hutool-core</artifactId>
</dependency>
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-http</artifactId>
</dependency>
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-captcha</artifactId>
</dependency>
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-jwt</artifactId>
</dependency>
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-extra</artifactId>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</dependency>
<!-- @deprecated 由于使用人数较少 决定与 3.4.0 版本移除 -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-openfeign</artifactId>
</dependency>
<!-- @deprecated 由于使用人数较少 决定与 3.4.0 版本移除 -->
<dependency>
<groupId>io.github.openfeign</groupId>
<artifactId>feign-okhttp</artifactId>
</dependency>
<dependency>
<groupId>de.codecentric</groupId>
<artifactId>spring-boot-admin-starter-client</artifactId>
</dependency>
<dependency>
<groupId>com.github.xiaoymin</groupId>
<artifactId>knife4j-spring-boot-starter</artifactId>
@ -144,10 +142,6 @@
<artifactId>swagger-annotations</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<!-- 自动生成YML配置关联JSON文件 -->
<dependency>
<groupId>org.springframework.boot</groupId>
@ -165,20 +159,6 @@
<artifactId>lock4j-redisson-spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>com.yomahub</groupId>
<artifactId>tlog-spring-boot-configuration</artifactId>
</dependency>
<dependency>
<groupId>com.yomahub</groupId>
<artifactId>tlog-webroot</artifactId>
</dependency>
<dependency>
<groupId>com.yomahub</groupId>
<artifactId>tlog-feign</artifactId>
</dependency>
</dependencies>
</project>

View File

@ -0,0 +1,26 @@
package com.ruoyi.common.annotation;
import java.lang.annotation.*;
/**
* 数据权限
*
* @author Lion Li
* @version 3.5.0
*/
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface DataColumn {
/**
* 占位符关键字
*/
String key() default "deptName";
/**
* 占位符替换值
*/
String value() default "dept_id";
}

View File

@ -0,0 +1,18 @@
package com.ruoyi.common.annotation;
import java.lang.annotation.*;
/**
* 数据权限组
*
* @author Lion Li
* @version 3.5.0
*/
@Target({ElementType.METHOD, ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface DataPermission {
DataColumn[] value();
}

View File

@ -6,11 +6,14 @@ import java.lang.annotation.*;
* 数据权限过滤注解
*
* @author ruoyi
* @deprecated 3.6.0 移除 {@link com.ruoyi.common.annotation.DataPermission}
*/
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Deprecated
public @interface DataScope {
/**
* 部门表的别名
*/
@ -25,4 +28,5 @@ public @interface DataScope {
* 是否过滤用户权限
*/
boolean isUser() default false;
}

View File

@ -10,11 +10,13 @@ import java.lang.annotation.*;
* 优先级:先方法,后类,如果方法覆盖了类上的数据源类型,以方法的为准,否则以类上的为准
*
* @author ruoyi
* @deprecated 3.6.0 移除 使用原生注解处理 方法更全 {@link com.baomidou.dynamic.datasource.annotation.DS}
*/
@Target({ElementType.METHOD, ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Inherited
@Deprecated
public @interface DataSource {
/**
* 切换数据源名称

View File

@ -38,6 +38,11 @@ public class RuoYiConfig {
*/
private boolean demoEnabled;
/**
* 缓存懒加载
*/
private boolean cacheLazy;
/**
* 获取地址开关
*/

View File

@ -1,145 +1,151 @@
package com.ruoyi.common.constant;
import io.jsonwebtoken.Claims;
/**
* 通用常量信息
*
* @author ruoyi
*/
public class Constants {
public interface Constants {
/**
* UTF-8 字符集
*/
public static final String UTF8 = "UTF-8";
String UTF8 = "UTF-8";
/**
* GBK 字符集
*/
public static final String GBK = "GBK";
String GBK = "GBK";
/**
* http请求
*/
public static final String HTTP = "http://";
String HTTP = "http://";
/**
* https请求
*/
public static final String HTTPS = "https://";
String HTTPS = "https://";
/**
* 通用成功标识
*/
public static final String SUCCESS = "0";
String SUCCESS = "0";
/**
* 通用失败标识
*/
public static final String FAIL = "1";
String FAIL = "1";
/**
* 登录成功
*/
public static final String LOGIN_SUCCESS = "Success";
String LOGIN_SUCCESS = "Success";
/**
* 注销
*/
public static final String LOGOUT = "Logout";
String LOGOUT = "Logout";
/**
* 注册
*/
public static final String REGISTER = "Register";
String REGISTER = "Register";
/**
* 登录失败
*/
public static final String LOGIN_FAIL = "Error";
String LOGIN_FAIL = "Error";
/**
* 验证码 redis key
*/
public static final String CAPTCHA_CODE_KEY = "captcha_codes:";
String CAPTCHA_CODE_KEY = "captcha_codes:";
/**
* 登录用户 redis key
*/
public static final String LOGIN_TOKEN_KEY = "login_tokens:";
String LOGIN_TOKEN_KEY = "login_tokens:";
/**
* 防重提交 redis key
*/
public static final String REPEAT_SUBMIT_KEY = "repeat_submit:";
String REPEAT_SUBMIT_KEY = "repeat_submit:";
/**
* 限流 redis key
*/
public static final String RATE_LIMIT_KEY = "rate_limit:";
String RATE_LIMIT_KEY = "rate_limit:";
/**
* 验证码有效期(分钟)
*/
public static final Integer CAPTCHA_EXPIRATION = 2;
Integer CAPTCHA_EXPIRATION = 2;
/**
* 登陆错误 redis key
*/
String LOGIN_ERROR = "login_error:";
/**
* 登录错误次数
*/
Integer LOGIN_ERROR_NUMBER = 5;
/**
* 登录错误限制时间(分钟)
*/
Integer LOGIN_ERROR_LIMIT_TIME = 10;
/**
* 令牌
*/
public static final String TOKEN = "token";
String TOKEN = "token";
/**
* 令牌前缀
*/
public static final String TOKEN_PREFIX = "Bearer ";
String TOKEN_PREFIX = "Bearer ";
/**
* 令牌前缀
*/
public static final String LOGIN_USER_KEY = "login_user_key";
String LOGIN_USER_KEY = "login_user_key";
/**
* 用户ID
*/
public static final String JWT_USERID = "userid";
String JWT_USERID = "userid";
/**
* 用户名称
*/
public static final String JWT_USERNAME = Claims.SUBJECT;
String JWT_USERNAME = "sub";
/**
* 用户头像
*/
public static final String JWT_AVATAR = "avatar";
String JWT_AVATAR = "avatar";
/**
* 创建时间
*/
public static final String JWT_CREATED = "created";
String JWT_CREATED = "created";
/**
* 用户权限
*/
public static final String JWT_AUTHORITIES = "authorities";
String JWT_AUTHORITIES = "authorities";
/**
* 参数管理 cache key
*/
public static final String SYS_CONFIG_KEY = "sys_config:";
String SYS_CONFIG_KEY = "sys_config:";
/**
* 字典管理 cache key
*/
public static final String SYS_DICT_KEY = "sys_dict:";
String SYS_DICT_KEY = "sys_dict:";
/**
* RMI 远程方法调用
*/
public static final String LOOKUP_RMI = "rmi://";
/**
* LDAP 远程方法调用
*/
public static final String LOOKUP_LDAP = "ldap://";
}

View File

@ -5,184 +5,184 @@ package com.ruoyi.common.constant;
*
* @author ruoyi
*/
public class GenConstants {
public interface GenConstants {
/**
* 单表(增删改查)
*/
public static final String TPL_CRUD = "crud";
String TPL_CRUD = "crud";
/**
* 树表(增删改查)
*/
public static final String TPL_TREE = "tree";
String TPL_TREE = "tree";
/**
* 主子表(增删改查)
*/
public static final String TPL_SUB = "sub";
String TPL_SUB = "sub";
/**
* 树编码字段
*/
public static final String TREE_CODE = "treeCode";
String TREE_CODE = "treeCode";
/**
* 树父编码字段
*/
public static final String TREE_PARENT_CODE = "treeParentCode";
String TREE_PARENT_CODE = "treeParentCode";
/**
* 树名称字段
*/
public static final String TREE_NAME = "treeName";
String TREE_NAME = "treeName";
/**
* 上级菜单ID字段
*/
public static final String PARENT_MENU_ID = "parentMenuId";
String PARENT_MENU_ID = "parentMenuId";
/**
* 上级菜单名称字段
*/
public static final String PARENT_MENU_NAME = "parentMenuName";
String PARENT_MENU_NAME = "parentMenuName";
/**
* 数据库字符串类型
*/
public static final String[] COLUMNTYPE_STR = {"char", "varchar", "nvarchar", "varchar2"};
String[] COLUMNTYPE_STR = {"char", "varchar", "nvarchar", "varchar2"};
/**
* 数据库文本类型
*/
public static final String[] COLUMNTYPE_TEXT = {"tinytext", "text", "mediumtext", "longtext"};
String[] COLUMNTYPE_TEXT = {"tinytext", "text", "mediumtext", "longtext"};
/**
* 数据库时间类型
*/
public static final String[] COLUMNTYPE_TIME = {"datetime", "time", "date", "timestamp"};
String[] COLUMNTYPE_TIME = {"datetime", "time", "date", "timestamp"};
/**
* 数据库数字类型
*/
public static final String[] COLUMNTYPE_NUMBER = {"tinyint", "smallint", "mediumint", "int", "number", "integer",
"bit", "bigint", "float", "double", "decimal"};
String[] COLUMNTYPE_NUMBER = {"tinyint", "smallint", "mediumint", "int", "number", "integer",
"bit", "bigint", "float", "double", "decimal"};
/**
* BO对象 不需要添加字段
*/
public static final String[] COLUMNNAME_NOT_ADD = {"create_by", "create_time", "del_flag", "update_by",
"update_time", "version"};
String[] COLUMNNAME_NOT_ADD = {"create_by", "create_time", "del_flag", "update_by",
"update_time", "version"};
/**
* BO对象 不需要编辑字段
*/
public static final String[] COLUMNNAME_NOT_EDIT = {"create_by", "create_time", "del_flag", "update_by",
"update_time", "version"};
String[] COLUMNNAME_NOT_EDIT = {"create_by", "create_time", "del_flag", "update_by",
"update_time", "version"};
/**
* VO对象 不需要返回字段
*/
public static final String[] COLUMNNAME_NOT_LIST = {"create_by", "create_time", "del_flag", "update_by",
"update_time", "version"};
String[] COLUMNNAME_NOT_LIST = {"create_by", "create_time", "del_flag", "update_by",
"update_time", "version"};
/**
* BO对象 不需要查询字段
*/
public static final String[] COLUMNNAME_NOT_QUERY = {"id", "create_by", "create_time", "del_flag", "update_by",
"update_time", "remark", "version"};
String[] COLUMNNAME_NOT_QUERY = {"id", "create_by", "create_time", "del_flag", "update_by",
"update_time", "remark", "version"};
/**
* Entity基类字段
*/
public static final String[] BASE_ENTITY = {"createBy", "createTime", "updateBy", "updateTime"};
String[] BASE_ENTITY = {"createBy", "createTime", "updateBy", "updateTime"};
/**
* Tree基类字段
*/
public static final String[] TREE_ENTITY = {"parentName", "parentId", "children"};
String[] TREE_ENTITY = {"parentName", "parentId", "children"};
/**
* 文本框
*/
public static final String HTML_INPUT = "input";
String HTML_INPUT = "input";
/**
* 文本域
*/
public static final String HTML_TEXTAREA = "textarea";
String HTML_TEXTAREA = "textarea";
/**
* 下拉框
*/
public static final String HTML_SELECT = "select";
String HTML_SELECT = "select";
/**
* 单选框
*/
public static final String HTML_RADIO = "radio";
String HTML_RADIO = "radio";
/**
* 复选框
*/
public static final String HTML_CHECKBOX = "checkbox";
String HTML_CHECKBOX = "checkbox";
/**
* 日期控件
*/
public static final String HTML_DATETIME = "datetime";
String HTML_DATETIME = "datetime";
/**
* 图片上传控件
*/
public static final String HTML_IMAGE_UPLOAD = "imageUpload";
String HTML_IMAGE_UPLOAD = "imageUpload";
/**
* 文件上传控件
*/
public static final String HTML_FILE_UPLOAD = "fileUpload";
String HTML_FILE_UPLOAD = "fileUpload";
/**
* 富文本控件
*/
public static final String HTML_EDITOR = "editor";
String HTML_EDITOR = "editor";
/**
* 字符串类型
*/
public static final String TYPE_STRING = "String";
String TYPE_STRING = "String";
/**
* 整型
*/
public static final String TYPE_INTEGER = "Integer";
String TYPE_INTEGER = "Integer";
/**
* 长整型
*/
public static final String TYPE_LONG = "Long";
String TYPE_LONG = "Long";
/**
* 浮点型
*/
public static final String TYPE_DOUBLE = "Double";
String TYPE_DOUBLE = "Double";
/**
* 高精度计算类型
*/
public static final String TYPE_BIGDECIMAL = "BigDecimal";
String TYPE_BIGDECIMAL = "BigDecimal";
/**
* 时间类型
*/
public static final String TYPE_DATE = "Date";
String TYPE_DATE = "Date";
/**
* 模糊查询
*/
public static final String QUERY_LIKE = "LIKE";
String QUERY_LIKE = "LIKE";
/**
* 需要
*/
public static final String REQUIRE = "1";
String REQUIRE = "1";
}

View File

@ -1,51 +0,0 @@
package com.ruoyi.common.constant;
/**
* 任务调度通用常量
*
* @deprecated 3.4.0删除 迁移至xxl-job
* @author ruoyi
*/
public class ScheduleConstants
{
public static final String TASK_CLASS_NAME = "TASK_CLASS_NAME";
/** 执行目标key */
public static final String TASK_PROPERTIES = "TASK_PROPERTIES";
/** 默认 */
public static final String MISFIRE_DEFAULT = "0";
/** 立即触发执行 */
public static final String MISFIRE_IGNORE_MISFIRES = "1";
/** 触发一次执行 */
public static final String MISFIRE_FIRE_AND_PROCEED = "2";
/** 不触发立即执行 */
public static final String MISFIRE_DO_NOTHING = "3";
public enum Status
{
/**
* 正常
*/
NORMAL("0"),
/**
* 暂停
*/
PAUSE("1");
private String value;
private Status(String value)
{
this.value = value;
}
public String getValue()
{
return value;
}
}
}

View File

@ -5,108 +5,108 @@ package com.ruoyi.common.constant;
*
* @author ruoyi
*/
public class UserConstants {
public interface UserConstants {
/**
* 平台内系统用户的唯一标志
*/
public static final String SYS_USER = "SYS_USER";
String SYS_USER = "SYS_USER";
/**
* 正常状态
*/
public static final String NORMAL = "0";
String NORMAL = "0";
/**
* 异常状态
*/
public static final String EXCEPTION = "1";
String EXCEPTION = "1";
/**
* 用户封禁状态
*/
public static final String USER_DISABLE = "1";
String USER_DISABLE = "1";
/**
* 角色封禁状态
*/
public static final String ROLE_DISABLE = "1";
String ROLE_DISABLE = "1";
/**
* 部门正常状态
*/
public static final String DEPT_NORMAL = "0";
String DEPT_NORMAL = "0";
/**
* 部门停用状态
*/
public static final String DEPT_DISABLE = "1";
String DEPT_DISABLE = "1";
/**
* 字典正常状态
*/
public static final String DICT_NORMAL = "0";
String DICT_NORMAL = "0";
/**
* 是否为系统默认(是)
*/
public static final String YES = "Y";
String YES = "Y";
/**
* 是否菜单外链(是)
*/
public static final String YES_FRAME = "0";
String YES_FRAME = "0";
/**
* 是否菜单外链(否)
*/
public static final String NO_FRAME = "1";
String NO_FRAME = "1";
/**
* 菜单类型(目录)
*/
public static final String TYPE_DIR = "M";
String TYPE_DIR = "M";
/**
* 菜单类型(菜单)
*/
public static final String TYPE_MENU = "C";
String TYPE_MENU = "C";
/**
* 菜单类型(按钮)
*/
public static final String TYPE_BUTTON = "F";
String TYPE_BUTTON = "F";
/**
* Layout组件标识
*/
public final static String LAYOUT = "Layout";
String LAYOUT = "Layout";
/**
* ParentView组件标识
*/
public final static String PARENT_VIEW = "ParentView";
String PARENT_VIEW = "ParentView";
/**
* InnerLink组件标识
*/
public final static String INNER_LINK = "InnerLink";
String INNER_LINK = "InnerLink";
/**
* 校验返回结果码
*/
public final static String UNIQUE = "0";
public final static String NOT_UNIQUE = "1";
String UNIQUE = "0";
String NOT_UNIQUE = "1";
/**
* 用户名长度限制
*/
public static final int USERNAME_MIN_LENGTH = 2;
public static final int USERNAME_MAX_LENGTH = 20;
int USERNAME_MIN_LENGTH = 2;
int USERNAME_MAX_LENGTH = 20;
/**
* 密码长度限制
*/
public static final int PASSWORD_MIN_LENGTH = 5;
public static final int PASSWORD_MAX_LENGTH = 20;
int PASSWORD_MIN_LENGTH = 5;
int PASSWORD_MAX_LENGTH = 20;
}

View File

@ -8,8 +8,10 @@ import com.alibaba.excel.metadata.CellData;
import com.alibaba.excel.metadata.GlobalConfiguration;
import com.alibaba.excel.metadata.property.ExcelContentProperty;
import com.ruoyi.common.annotation.ExcelDictFormat;
import com.ruoyi.common.core.service.DictService;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.utils.spring.SpringUtils;
import lombok.extern.slf4j.Slf4j;
import java.lang.reflect.Field;
@ -41,7 +43,7 @@ public class ExcelDictConvert implements Converter<Object> {
if (StringUtils.isBlank(type)) {
value = ExcelUtil.reverseByExp(label, anno.readConverterExp(), anno.separator());
} else {
value = ExcelUtil.reverseDictByExp(label, type, anno.separator());
value = SpringUtils.getBean(DictService.class).getDictValue(type, label, anno.separator());
}
return Convert.convert(contentProperty.getField().getType(), value);
}
@ -58,7 +60,7 @@ public class ExcelDictConvert implements Converter<Object> {
if (StringUtils.isBlank(type)) {
label = ExcelUtil.convertByExp(value, anno.readConverterExp(), anno.separator());
} else {
label = ExcelUtil.convertDictByExp(value, type, anno.separator());
label = SpringUtils.getBean(DictService.class).getDictLabel(type, value, anno.separator());
}
return new CellData<>(label);
}

View File

@ -2,7 +2,6 @@ package com.ruoyi.common.core.domain;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.fasterxml.jackson.annotation.JsonIgnore;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;
@ -62,7 +61,6 @@ public class BaseEntity implements Serializable {
/**
* 请求参数
*/
@JsonIgnore
@ApiModelProperty(value = "请求参数")
@TableField(exist = false)
private Map<String, Object> params = new HashMap<>();

View File

@ -0,0 +1,93 @@
package com.ruoyi.common.core.domain;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.metadata.OrderItem;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.sql.SqlUtil;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;
import java.io.Serializable;
/**
* 分页查询实体类
*
* @author Lion Li
*/
@Data
@Accessors(chain = true)
public class PageQuery implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 分页大小
*/
@ApiModelProperty("分页大小")
private Integer pageSize;
/**
* 当前页数
*/
@ApiModelProperty("当前页数")
private Integer pageNum;
/**
* 排序列
*/
@ApiModelProperty("排序列")
private String orderByColumn;
/**
* 排序的方向desc或者asc
*/
@ApiModelProperty(value = "排序的方向", example = "asc,desc")
private String isAsc;
/**
* 当前记录起始索引 默认值
*/
public static final int DEFAULT_PAGE_NUM = 1;
/**
* 每页显示记录数 默认值 默认查全部
*/
public static final int DEFAULT_PAGE_SIZE = Integer.MAX_VALUE;
public <T> Page<T> build() {
Integer pageNum = ObjectUtil.defaultIfNull(getPageNum(), DEFAULT_PAGE_NUM);
Integer pageSize = ObjectUtil.defaultIfNull(getPageSize(), DEFAULT_PAGE_SIZE);
if (pageNum <= 0) {
pageNum = DEFAULT_PAGE_NUM;
}
Page<T> page = new Page<>(pageNum, pageSize);
OrderItem orderItem = buildOrderItem();
if (ObjectUtil.isNotNull(orderItem)) {
page.addOrder(orderItem);
}
return page;
}
private OrderItem buildOrderItem() {
// 兼容前端排序类型
if ("ascending".equals(isAsc)) {
isAsc = "asc";
} else if ("descending".equals(isAsc)) {
isAsc = "desc";
}
if (StringUtils.isNotBlank(orderByColumn)) {
String orderBy = SqlUtil.escapeOrderBySql(orderByColumn);
orderBy = StringUtils.toUnderScoreCase(orderBy);
if ("asc".equals(isAsc)) {
return OrderItem.asc(orderBy);
} else if ("desc".equals(isAsc)) {
return OrderItem.desc(orderBy);
}
}
return null;
}
}

View File

@ -1,67 +0,0 @@
package com.ruoyi.common.core.domain;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.ruoyi.common.core.domain.entity.SysDept;
import com.ruoyi.common.core.domain.entity.SysMenu;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import java.io.Serializable;
import java.util.List;
import java.util.stream.Collectors;
/**
* Treeselect树结构实体类
*
* @author Lion Li
*/
@Data
@NoArgsConstructor
@Accessors(chain = true)
@ApiModel("树结构实体类")
public class TreeSelect implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 节点ID
*/
@ApiModelProperty(value = "节点ID")
private Long id;
/**
* 节点名称
*/
@ApiModelProperty(value = "节点名称")
private String label;
/**
* 子节点
*/
@ApiModelProperty(value = "子节点")
@JsonInclude(JsonInclude.Include.NON_EMPTY)
private List<TreeSelect> children;
public TreeSelect(SysDept dept) {
this.id = dept.getDeptId();
this.label = dept.getDeptName();
this.children = dept.getChildren()
.stream()
.map(d -> new TreeSelect((SysDept) d))
.collect(Collectors.toList());
}
public TreeSelect(SysMenu menu) {
this.id = menu.getMenuId();
this.label = menu.getMenuName();
this.children = menu.getChildren()
.stream()
.map(d -> new TreeSelect((SysMenu) d))
.collect(Collectors.toList());
}
}

View File

@ -1,5 +1,6 @@
package com.ruoyi.common.core.domain.entity;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.ruoyi.common.core.domain.TreeEntity;
@ -65,6 +66,7 @@ public class SysMenu extends TreeEntity {
* 路由参数
*/
@ApiModelProperty(value = "路由参数")
@TableField("`query`")
private String query;
/**

View File

@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.ruoyi.common.core.domain.BaseEntity;
import com.ruoyi.common.xss.Xss;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@ -48,15 +49,17 @@ public class SysUser extends BaseEntity {
* 用户账号
*/
@ApiModelProperty(value = "用户账号")
@NotBlank(message = "用户账号不能为空")
@Xss(message = "用户账号不能包含脚本字符")
@NotBlank(message = "用户账号不能为空")
@Size(min = 0, max = 30, message = "用户账号长度不能超过30个字符")
private String userName;
/**
* 用户昵称
*/
@ApiModelProperty(value = "用户昵称")
@Size(min = 0, max = 30, message = "用户昵称长度不能超过30个字符")
@ApiModelProperty(value = "用户昵称")
@Xss(message = "用户昵称不能包含脚本字符")
@Size(min = 0, max = 30, message = "用户昵称长度不能超过30个字符")
private String nickName;
/**
@ -162,7 +165,7 @@ public class SysUser extends BaseEntity {
private Long[] postIds;
/**
* 角色ID
* 数据权限 当前角色ID
*/
@ApiModelProperty(value = "角色ID")
@TableField(exist = false)

View File

@ -1,7 +1,6 @@
package com.ruoyi.common.core.domain.model;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.ruoyi.common.core.domain.entity.SysUser;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
@ -70,36 +69,34 @@ public class LoginUser implements UserDetails {
private String os;
/**
* 权限列表
* 菜单权限
*/
private Set<String> permissions;
private Set<String> menuPermissions;
/**
* 用户信息
* 角色权限
*/
private SysUser user;
private Set<String> rolePermissions;
public LoginUser(SysUser user, Set<String> permissions) {
this.user = user;
this.permissions = permissions;
}
/**
* 用户名
*/
private String username;
public LoginUser(Long userId, Long deptId, SysUser user, Set<String> permissions) {
this.userId = userId;
this.deptId = deptId;
this.user = user;
this.permissions = permissions;
}
/**
* 密码
*/
private String password;
@JsonIgnore
@Override
public String getPassword() {
return user.getPassword();
return password;
}
@Override
public String getUsername() {
return user.getUserName();
return username;
}
/**

View File

@ -1,91 +0,0 @@
package com.ruoyi.common.core.mybatisplus.cache;
import cn.hutool.extra.spring.SpringUtil;
import com.ruoyi.common.utils.RedisUtils;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.cache.Cache;
import org.springframework.data.redis.connection.RedisServerCommands;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.util.CollectionUtils;
import java.util.Collection;
import java.util.concurrent.locks.ReadWriteLock;
import java.util.concurrent.locks.ReentrantReadWriteLock;
/**
* mybatis-redis 二级缓存
*
* 使用方法 配置文件开启 mybatis-plus 二级缓存
* 在 XxxMapper.java 类上添加注解 @CacheNamespace(implementation = MybatisPlusRedisCache.class, eviction = MybatisPlusRedisCache.class)
*
* @deprecated 3.4.0删除 推荐使用spirng-cache
* @author Lion Li
*/
@Slf4j
public class MybatisPlusRedisCache implements Cache {
private final ReadWriteLock readWriteLock = new ReentrantReadWriteLock(true);
private String id;
public MybatisPlusRedisCache(final String id) {
if (id == null) {
throw new IllegalArgumentException("Cache instances require an ID");
}
this.id = id;
}
@Override
public String getId() {
return this.id;
}
@Override
public void putObject(Object key, Object value) {
if (value != null) {
RedisUtils.setCacheObject(key.toString(), value);
}
}
@Override
public Object getObject(Object key) {
try {
if (key != null) {
return RedisUtils.getCacheObject(key.toString());
}
} catch (Exception e) {
e.printStackTrace();
log.error("缓存出错");
}
return null;
}
@Override
public Object removeObject(Object key) {
if (key != null) {
RedisUtils.deleteObject(key.toString());
}
return null;
}
@Override
public void clear() {
log.debug("清空缓存");
Collection<String> keys = RedisUtils.keys("*:" + this.id + "*");
if (!CollectionUtils.isEmpty(keys)) {
RedisUtils.deleteObject(keys);
}
}
@Override
public int getSize() {
RedisTemplate<String, Object> redisTemplate = SpringUtil.getBean("redisTemplate");
Long size = redisTemplate.execute(RedisServerCommands::dbSize);
return size.intValue();
}
@Override
public ReadWriteLock getReadWriteLock() {
return this.readWriteLock;
}
}

View File

@ -1,9 +1,18 @@
package com.ruoyi.common.core.mybatisplus.core;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruoyi.common.utils.BeanCopyUtils;
import org.apache.ibatis.annotations.Param;
import java.io.Serializable;
import java.util.Collection;
import java.util.List;
import java.util.Map;
/**
* 自定义 Mapper 接口, 实现 自定义扩展
@ -18,4 +27,72 @@ public interface BaseMapperPlus<T> extends BaseMapper<T> {
*/
int insertAll(@Param("list") Collection<T> batchList);
/**
* 根据 ID 查询
*/
default <V> V selectVoById(Serializable id, Class<V> voClass){
T obj = this.selectById(id);
if (ObjectUtil.isNull(obj)) {
return null;
}
return BeanCopyUtils.copy(obj, voClass);
}
/**
* 查询根据ID 批量查询)
*/
default <V> List<V> selectVoBatchIds(Collection<? extends Serializable> idList, Class<V> voClass){
List<T> list = this.selectBatchIds(idList);
if (CollUtil.isEmpty(list)) {
return CollUtil.newArrayList();
}
return BeanCopyUtils.copyList(list, voClass);
}
/**
* 查询(根据 columnMap 条件)
*/
default <V> List<V> selectVoByMap(Map<String, Object> map, Class<V> voClass){
List<T> list = this.selectByMap(map);
if (CollUtil.isEmpty(list)) {
return CollUtil.newArrayList();
}
return BeanCopyUtils.copyList(list, voClass);
}
/**
* 根据 entity 条件,查询一条记录
*/
default <V> V selectVoOne(Wrapper<T> wrapper, Class<V> voClass) {
T obj = this.selectOne(wrapper);
if (ObjectUtil.isNull(obj)) {
return null;
}
return BeanCopyUtils.copy(obj, voClass);
}
/**
* 根据 entity 条件,查询全部记录
*/
default <V> List<V> selectVoList(Wrapper<T> wrapper, Class<V> voClass) {
List<T> list = this.selectList(wrapper);
if (CollUtil.isEmpty(list)) {
return CollUtil.newArrayList();
}
return BeanCopyUtils.copyList(list, voClass);
}
/**
* 分页查询VO
*/
default <V, P extends IPage<V>> P selectVoPage(IPage<T> page, Wrapper<T> wrapper, Class<V> voClass) {
IPage<T> pageData = this.selectPage(page, wrapper);
IPage<V> voPage = new Page<>(pageData.getCurrent(), pageData.getSize(), pageData.getTotal());
if (CollUtil.isEmpty(pageData.getRecords())) {
return (P) voPage;
}
voPage.setRecords(BeanCopyUtils.copyList(pageData.getRecords(), voClass));
return (P) voPage;
}
}

View File

@ -1,7 +1,7 @@
package com.ruoyi.common.core.mybatisplus.core;
import cn.hutool.core.bean.copier.CopyOptions;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.IService;
import com.ruoyi.common.core.page.PagePlus;
@ -23,14 +23,9 @@ public interface IServicePlus<T, V> extends IService<T> {
/**
* @param id 主键id
* @param copyOptions copy条件
* @return V对象
*/
V getVoById(Serializable id, CopyOptions copyOptions);
default V getVoById(Serializable id) {
return getVoById(id, new CopyOptions());
}
V getVoById(Serializable id);
/**
* @param convertor 自定义转换器
@ -41,14 +36,9 @@ public interface IServicePlus<T, V> extends IService<T> {
/**
* @param idList id列表
* @param copyOptions copy条件
* @return V对象
*/
List<V> listVoByIds(Collection<? extends Serializable> idList, CopyOptions copyOptions);
default List<V> listVoByIds(Collection<? extends Serializable> idList) {
return listVoByIds(idList, new CopyOptions());
}
List<V> listVoByIds(Collection<? extends Serializable> idList);
/**
* @param convertor 自定义转换器
@ -64,14 +54,9 @@ public interface IServicePlus<T, V> extends IService<T> {
/**
* @param columnMap 表字段 map 对象
* @param copyOptions copy条件
* @return V对象
*/
List<V> listVoByMap(Map<String, Object> columnMap, CopyOptions copyOptions);
default List<V> listVoByMap(Map<String, Object> columnMap) {
return listVoByMap(columnMap, new CopyOptions());
}
List<V> listVoByMap(Map<String, Object> columnMap);
/**
* @param convertor 自定义转换器
@ -87,14 +72,9 @@ public interface IServicePlus<T, V> extends IService<T> {
/**
* @param queryWrapper 查询条件
* @param copyOptions copy条件
* @return V对象
*/
V getVoOne(Wrapper<T> queryWrapper, CopyOptions copyOptions);
default V getVoOne(Wrapper<T> queryWrapper) {
return getVoOne(queryWrapper, new CopyOptions());
}
V getVoOne(Wrapper<T> queryWrapper);
/**
* @param convertor 自定义转换器
@ -105,14 +85,9 @@ public interface IServicePlus<T, V> extends IService<T> {
/**
* @param queryWrapper 查询条件
* @param copyOptions copy条件
* @return V对象
*/
List<V> listVo(Wrapper<T> queryWrapper, CopyOptions copyOptions);
default List<V> listVo(Wrapper<T> queryWrapper) {
return listVo(queryWrapper, new CopyOptions());
}
List<V> listVo(Wrapper<T> queryWrapper);
/**
* @param convertor 自定义转换器
@ -139,31 +114,36 @@ public interface IServicePlus<T, V> extends IService<T> {
/**
* @param page 分页对象
* @param queryWrapper 查询条件
* @param copyOptions copy条件
* @return V对象
* @deprecated 3.6.0 移除 请使用 {@link ServicePlusImpl#pageVo(IPage, Wrapper)}
*/
PagePlus<T, V> pageVo(PagePlus<T, V> page, Wrapper<T> queryWrapper, CopyOptions copyOptions);
@Deprecated
PagePlus<T, V> pageVo(PagePlus<T, V> page, Wrapper<T> queryWrapper);
default PagePlus<T, V> pageVo(PagePlus<T, V> page, Wrapper<T> queryWrapper) {
return pageVo(page, queryWrapper, new CopyOptions());
}
/**
* @param convertor 自定义转换器
*/
/**
* @param convertor 自定义转换器
* @deprecated 3.6.0 移除 请使用 {@link ServicePlusImpl#pageVo(IPage, Wrapper)}
*/
@Deprecated
default PagePlus<T, V> pageVo(PagePlus<T, V> page, Wrapper<T> queryWrapper,
Function<Collection<T>, List<V>> convertor) {
PagePlus<T, V> result = getBaseMapper().selectPage(page, queryWrapper);
return result.setRecordsVo(convertor.apply(result.getRecords()));
}
/**
* @deprecated 3.6.0 移除 请使用 {@link ServicePlusImpl#pageVo(IPage, Wrapper)}
*/
@Deprecated
default PagePlus<T, V> pageVo(PagePlus<T, V> page) {
return pageVo(page, Wrappers.emptyWrapper());
}
/**
* @param convertor 自定义转换器
* @deprecated 3.6.0 移除 请使用 {@link ServicePlusImpl#pageVo(IPage, Wrapper)}
*/
@Deprecated
default PagePlus<T, V> pageVo(PagePlus<T, V> page, Function<Collection<T>, List<V>> convertor) {
return pageVo(page, Wrappers.emptyWrapper(), convertor);
}

View File

@ -1,9 +1,9 @@
package com.ruoyi.common.core.mybatisplus.core;
import cn.hutool.core.bean.copier.CopyOptions;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.metadata.TableInfo;
import com.baomidou.mybatisplus.core.metadata.TableInfoHelper;
import com.baomidou.mybatisplus.core.toolkit.Assert;
@ -161,81 +161,66 @@ public class ServicePlusImpl<M extends BaseMapperPlus<T>, T, V> extends ServiceI
/**
* 根据 ID 查询
*
* @param id 主键ID
*/
@Override
public V getVoById(Serializable id, CopyOptions copyOptions) {
T t = getBaseMapper().selectById(id);
return BeanCopyUtils.oneCopy(t, copyOptions, voClass);
public V getVoById(Serializable id) {
return getBaseMapper().selectVoById(id, voClass);
}
/**
* 查询根据ID 批量查询)
*
* @param idList 主键ID列表
*/
@Override
public List<V> listVoByIds(Collection<? extends Serializable> idList, CopyOptions copyOptions) {
List<T> list = getBaseMapper().selectBatchIds(idList);
if (list == null) {
return null;
}
return BeanCopyUtils.listCopy(list, copyOptions, voClass);
public List<V> listVoByIds(Collection<? extends Serializable> idList) {
return getBaseMapper().selectVoBatchIds(idList, voClass);
}
/**
* 查询(根据 columnMap 条件)
*
* @param columnMap 表字段 map 对象
*/
@Override
public List<V> listVoByMap(Map<String, Object> columnMap, CopyOptions copyOptions) {
List<T> list = getBaseMapper().selectByMap(columnMap);
if (list == null) {
return null;
}
return BeanCopyUtils.listCopy(list, copyOptions, voClass);
public List<V> listVoByMap(Map<String, Object> columnMap) {
return getBaseMapper().selectVoByMap(columnMap, voClass);
}
/**
* 根据 Wrapper查询一条记录 <br/>
* <p>结果集,如果是多个会抛出异常,随机取一条加上限制条件 wrapper.last("LIMIT 1")</p>
*
* @param queryWrapper 实体对象封装操作类 {@link com.baomidou.mybatisplus.core.conditions.query.QueryWrapper}
*/
@Override
public V getVoOne(Wrapper<T> queryWrapper, CopyOptions copyOptions) {
T t = getOne(queryWrapper, true);
return BeanCopyUtils.oneCopy(t, copyOptions, voClass);
public V getVoOne(Wrapper<T> queryWrapper) {
return getBaseMapper().selectVoOne(queryWrapper, voClass);
}
/**
* 查询列表
*
* @param queryWrapper 实体对象封装操作类 {@link com.baomidou.mybatisplus.core.conditions.query.QueryWrapper}
*/
@Override
public List<V> listVo(Wrapper<T> queryWrapper, CopyOptions copyOptions) {
List<T> list = getBaseMapper().selectList(queryWrapper);
if (list == null) {
return null;
}
return BeanCopyUtils.listCopy(list, copyOptions, voClass);
public List<V> listVo(Wrapper<T> queryWrapper) {
return getBaseMapper().selectVoList(queryWrapper, voClass);
}
/**
* 翻页查询
*
* @param page 翻页对象
* @param queryWrapper 实体对象封装操作类
* @deprecated 3.6.0 移除 请使用 {@link #pageVo(IPage, Wrapper)}
*/
@Override
public PagePlus<T, V> pageVo(PagePlus<T, V> page, Wrapper<T> queryWrapper, CopyOptions copyOptions) {
@Deprecated
public PagePlus<T, V> pageVo(PagePlus<T, V> page, Wrapper<T> queryWrapper) {
PagePlus<T, V> result = getBaseMapper().selectPage(page, queryWrapper);
List<V> volist = BeanCopyUtils.listCopy(result.getRecords(), copyOptions, voClass);
List<V> volist = BeanCopyUtils.copyList(result.getRecords(), voClass);
result.setRecordsVo(volist);
return result;
}
/**
* 翻页查询
*
* @param page 翻页对象
* @param queryWrapper 实体对象封装操作类
*/
public <P extends IPage<V>> P pageVo(IPage<T> page, Wrapper<T> queryWrapper) {
return getBaseMapper().selectVoPage(page, queryWrapper, voClass);
}
}

View File

@ -16,9 +16,11 @@ import java.util.List;
* @param <T> 数据库实体
* @param <K> vo实体
* @author Lion Li
* @deprecated 3.6.0 删除 请使用 {@link com.ruoyi.common.core.domain.PageQuery#build()}
*/
@Data
@Accessors(chain = true)
@Deprecated
public class PagePlus<T,K> implements IPage<T> {
/**

View File

@ -1,5 +1,7 @@
package com.ruoyi.common.core.page;
import cn.hutool.http.HttpStatus;
import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@ -57,4 +59,29 @@ public class TableDataInfo<T> implements Serializable {
this.total = total;
}
public static <T> TableDataInfo<T> build(IPage<T> page) {
TableDataInfo<T> rspData = new TableDataInfo<>();
rspData.setCode(HttpStatus.HTTP_OK);
rspData.setMsg("查询成功");
rspData.setRows(page.getRecords());
rspData.setTotal(page.getTotal());
return rspData;
}
public static <T> TableDataInfo<T> build(List<T> list) {
TableDataInfo<T> rspData = new TableDataInfo<>();
rspData.setCode(HttpStatus.HTTP_OK);
rspData.setMsg("查询成功");
rspData.setRows(list);
rspData.setTotal(list.size());
return rspData;
}
public static <T> TableDataInfo<T> build() {
TableDataInfo<T> rspData = new TableDataInfo<>();
rspData.setCode(HttpStatus.HTTP_OK);
rspData.setMsg("查询成功");
return rspData;
}
}

View File

@ -0,0 +1,18 @@
package com.ruoyi.common.core.service;
/**
* 通用 参数配置服务
*
* @author Lion Li
*/
public interface ConfigService {
/**
* 根据参数 key 获取参数值
*
* @param configKey 参数 key
* @return 参数值
*/
String getConfigValue(String configKey);
}

View File

@ -0,0 +1,57 @@
package com.ruoyi.common.core.service;
/**
* 通用 字典服务
*
* @author Lion Li
*/
public interface DictService {
/**
* 分隔符
*/
String SEPARATOR = ",";
/**
* 根据字典类型和字典值获取字典标签
*
* @param dictType 字典类型
* @param dictValue 字典值
* @return 字典标签
*/
default String getDictLabel(String dictType, String dictValue) {
return getDictLabel(dictType, dictValue, SEPARATOR);
}
/**
* 根据字典类型和字典标签获取字典值
*
* @param dictType 字典类型
* @param dictLabel 字典标签
* @return 字典值
*/
default String getDictValue(String dictType, String dictLabel) {
return getDictValue(dictType, dictLabel, SEPARATOR);
}
/**
* 根据字典类型和字典值获取字典标签
*
* @param dictType 字典类型
* @param dictValue 字典值
* @param separator 分隔符
* @return 字典标签
*/
String getDictLabel(String dictType, String dictValue, String separator);
/**
* 根据字典类型和字典标签获取字典值
*
* @param dictType 字典类型
* @param dictLabel 字典标签
* @param separator 分隔符
* @return 字典值
*/
String getDictValue(String dictType, String dictLabel, String separator);
}

View File

@ -2,6 +2,11 @@ package com.ruoyi.common.core.service;
import javax.servlet.http.HttpServletRequest;
/**
* 通用 系统访问日志
*
* @author Lion Li
*/
public interface LogininforService {
void recordLogininfor(String username, String status, String message,

View File

@ -3,7 +3,13 @@ package com.ruoyi.common.core.service;
import com.ruoyi.common.core.domain.dto.OperLogDTO;
import org.springframework.scheduling.annotation.Async;
/**
* 通用 操作日志
*
* @author Lion Li
*/
public interface OperLogService {
@Async
void recordOper(OperLogDTO operLogDTO);
}

View File

@ -0,0 +1,28 @@
package com.ruoyi.common.core.service;
import com.ruoyi.common.core.domain.entity.SysUser;
/**
* 通用 用户业务
*
* @author Lion Li
*/
public interface UserService {
/**
* 通过用户名查询用户
*
* @param userName 用户名
* @return 用户对象信息
*/
SysUser selectUserByUserName(String userName);
/**
* 通过用户ID查询用户
*
* @param userId 用户ID
* @return 用户对象信息
*/
SysUser selectUserById(Long userId);
}

View File

@ -0,0 +1,72 @@
package com.ruoyi.common.enums;
import com.ruoyi.common.utils.StringUtils;
import lombok.AllArgsConstructor;
import lombok.Getter;
/**
* 数据权限类型
*
* 语法支持 spel 模板表达式
*
* 内置数据 user 当前用户 内容参考 SysUser
* 如需扩展数据 可使用 {@link com.ruoyi.common.helper.DataPermissionHelper} 操作
* 内置服务 sdss 系统数据权限服务 内容参考 SysDataScopeService
* 如需扩展更多自定义服务 可以参考 sdss 自行编写
*
* @author Lion Li
* @version 3.5.0
*/
@Getter
@AllArgsConstructor
public enum DataScopeType {
/**
* 全部数据权限
*/
ALL("1", "", ""),
/**
* 自定数据权限
*/
CUSTOM("2", " #{#deptName} IN ( #{@sdss.getRoleCustom( #user.roleId )} ) ", ""),
/**
* 部门数据权限
*/
DEPT("3", " #{#deptName} = #{#user.deptId} ", ""),
/**
* 部门及以下数据权限
*/
DEPT_AND_CHILD("4", " #{#deptName} IN ( #{@sdss.getDeptAndChild( #user.deptId )} )", ""),
/**
* 仅本人数据权限
*/
SELF("5", " #{#userName} = #{#user.userId} " , " 1 = 0 ");
private final String code;
/**
* 语法 采用 spel 模板表达式
*/
private final String sqlTemplate;
/**
* 不满足 sqlTemplate 则填充
*/
private final String elseSql;
public static DataScopeType findCode(String code) {
if (StringUtils.isBlank(code)) {
return null;
}
for (DataScopeType type : values()) {
if (type.getCode().equals(code)) {
return type;
}
}
return null;
}
}

View File

@ -7,8 +7,10 @@ import lombok.Getter;
* 数据源
*
* @author Lion Li
* @deprecated 3.6.0 移除
*/
@AllArgsConstructor
@Deprecated
public enum DataSourceType {
/**
* 主库

View File

@ -0,0 +1,108 @@
package com.ruoyi.common.excel;
import cn.hutool.core.util.StrUtil;
import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.event.AnalysisEventListener;
import com.alibaba.excel.exception.ExcelAnalysisException;
import com.alibaba.excel.exception.ExcelDataConvertException;
import com.ruoyi.common.utils.JsonUtils;
import com.ruoyi.common.utils.ValidatorUtils;
import lombok.NoArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import javax.validation.ConstraintViolation;
import javax.validation.ConstraintViolationException;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
/**
* Excel 导入监听
*
* @author Yjoioooo
* @author Lion Li
*/
@Slf4j
@NoArgsConstructor
public class DefaultExcelListener<T> extends AnalysisEventListener<T> implements ExcelListener<T> {
/**
* 是否Validator检验默认为是
*/
private Boolean isValidate = Boolean.TRUE;
/**
* excel 表头数据
*/
private Map<Integer, String> headMap;
/**
* 导入回执
*/
private ExcelResult<T> excelResult;
public DefaultExcelListener(boolean isValidate) {
this.excelResult = new DefautExcelResult<>();
this.isValidate = isValidate;
}
/**
* 处理异常
*
* @param exception ExcelDataConvertException
* @param context Excel 上下文
*/
@Override
public void onException(Exception exception, AnalysisContext context) throws Exception {
String errMsg = null;
if (exception instanceof ExcelDataConvertException) {
// 如果是某一个单元格的转换异常 能获取到具体行号
ExcelDataConvertException excelDataConvertException = (ExcelDataConvertException) exception;
Integer rowIndex = excelDataConvertException.getRowIndex();
Integer columnIndex = excelDataConvertException.getColumnIndex();
errMsg = StrUtil.format("第{}行-第{}列-表头{}: 解析异常<br/>",
rowIndex + 1, columnIndex + 1, headMap.get(columnIndex));
if (log.isDebugEnabled()) {
log.error(errMsg);
}
}
if (exception instanceof ConstraintViolationException) {
ConstraintViolationException constraintViolationException = (ConstraintViolationException) exception;
Set<ConstraintViolation<?>> constraintViolations = constraintViolationException.getConstraintViolations();
String constraintViolationsMsg = constraintViolations.stream()
.map(ConstraintViolation::getMessage)
.collect(Collectors.joining(", "));
errMsg = StrUtil.format("第{}行数据校验异常: {}", context.readRowHolder().getRowIndex() + 1, constraintViolationsMsg);
if (log.isDebugEnabled()) {
log.error(errMsg);
}
}
excelResult.getErrorList().add(errMsg);
throw new ExcelAnalysisException(errMsg);
}
@Override
public void invokeHeadMap(Map<Integer, String> headMap, AnalysisContext context) {
this.headMap = headMap;
log.debug("解析到一条表头数据: {}", JsonUtils.toJsonString(headMap));
}
@Override
public void invoke(T data, AnalysisContext context) {
if (isValidate) {
ValidatorUtils.validate(data);
}
excelResult.getList().add(data);
}
@Override
public void doAfterAllAnalysed(AnalysisContext context) {
log.debug("所有数据解析完成!");
}
@Override
public ExcelResult<T> getExcelResult() {
return excelResult;
}
}

View File

@ -0,0 +1,73 @@
package com.ruoyi.common.excel;
import cn.hutool.core.util.StrUtil;
import lombok.Setter;
import java.util.ArrayList;
import java.util.List;
/**
* 默认excel返回对象
*
* @author Yjoioooo
* @author Lion Li
*/
public class DefautExcelResult<T> implements ExcelResult<T> {
/**
* 数据对象list
*/
@Setter
private List<T> list;
/**
* 错误信息列表
*/
@Setter
private List<String> errorList;
public DefautExcelResult() {
this.list = new ArrayList<>();
this.errorList = new ArrayList<>();
}
public DefautExcelResult(List<T> list, List<String> errorList) {
this.list = list;
this.errorList = errorList;
}
public DefautExcelResult(ExcelResult<T> excelResult) {
this.list = excelResult.getList();
this.errorList = excelResult.getErrorList();
}
@Override
public List<T> getList() {
return list;
}
@Override
public List<String> getErrorList() {
return errorList;
}
/**
* 获取导入回执
*
* @return 导入回执
*/
@Override
public String getAnalysis() {
int successCount = list.size();
int errorCount = errorList.size();
if (successCount == 0) {
return "读取失败,未解析到数据";
} else {
if (errorCount == 0) {
return StrUtil.format("恭喜您,全部读取成功!共{}条", successCount);
} else {
return "";
}
}
}
}

View File

@ -0,0 +1,14 @@
package com.ruoyi.common.excel;
import com.alibaba.excel.read.listener.ReadListener;
/**
* Excel 导入监听
*
* @author Lion Li
*/
public interface ExcelListener<T> extends ReadListener<T> {
ExcelResult<T> getExcelResult();
}

View File

@ -0,0 +1,26 @@
package com.ruoyi.common.excel;
import java.util.List;
/**
* excel返回对象
*
* @author Lion Li
*/
public interface ExcelResult<T> {
/**
* 对象列表
*/
List<T> getList();
/**
* 错误列表
*/
List<String> getErrorList();
/**
* 导入回执
*/
String getAnalysis();
}

View File

@ -1,61 +0,0 @@
package com.ruoyi.common.exception.file;
import lombok.*;
import org.apache.commons.fileupload.FileUploadException;
import java.util.Arrays;
/**
* 文件上传 误异常类
*
* @author ruoyi
*/
@Data
@EqualsAndHashCode(callSuper = true)
@NoArgsConstructor
public class InvalidExtensionException extends FileUploadException {
private static final long serialVersionUID = 1L;
private String[] allowedExtension;
private String extension;
private String filename;
public InvalidExtensionException(String[] allowedExtension, String extension, String filename) {
super("filename : [" + filename + "], extension : [" + extension + "], allowed extension : [" + Arrays.toString(allowedExtension) + "]");
this.allowedExtension = allowedExtension;
this.extension = extension;
this.filename = filename;
}
public static class InvalidImageExtensionException extends InvalidExtensionException {
private static final long serialVersionUID = 1L;
public InvalidImageExtensionException(String[] allowedExtension, String extension, String filename) {
super(allowedExtension, extension, filename);
}
}
public static class InvalidFlashExtensionException extends InvalidExtensionException {
private static final long serialVersionUID = 1L;
public InvalidFlashExtensionException(String[] allowedExtension, String extension, String filename) {
super(allowedExtension, extension, filename);
}
}
public static class InvalidMediaExtensionException extends InvalidExtensionException {
private static final long serialVersionUID = 1L;
public InvalidMediaExtensionException(String[] allowedExtension, String extension, String filename) {
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,35 +0,0 @@
package com.ruoyi.common.exception.job;
/**
* 计划策略异常
*
* @deprecated 3.4.0删除 迁移至xxl-job
* @author ruoyi
*/
public class TaskException extends Exception
{
private static final long serialVersionUID = 1L;
private Code code;
public TaskException(String msg, Code code)
{
this(msg, code, null);
}
public TaskException(String msg, Code code, Exception nestedEx)
{
super(msg, nestedEx);
this.code = code;
}
public Code getCode()
{
return code;
}
public enum Code
{
TASK_EXISTS, NO_TASK_EXISTS, TASK_ALREADY_STARTED, UNKNOWN, CONFIG_ERROR, TASK_NODE_NOT_AVAILABLE
}
}

View File

@ -9,6 +9,6 @@ public class CaptchaException extends UserException {
private static final long serialVersionUID = 1L;
public CaptchaException() {
super("user.jcaptcha.error", null);
super("user.jcaptcha.error");
}
}

View File

@ -9,6 +9,6 @@ public class CaptchaExpireException extends UserException {
private static final long serialVersionUID = 1L;
public CaptchaExpireException() {
super("user.jcaptcha.expire", null);
super("user.jcaptcha.expire");
}
}

View File

@ -10,7 +10,7 @@ import com.ruoyi.common.exception.base.BaseException;
public class UserException extends BaseException {
private static final long serialVersionUID = 1L;
public UserException(String code, Object[] args) {
public UserException(String code, Object... args) {
super("user", code, args, null);
}
}

View File

@ -9,6 +9,6 @@ public class UserPasswordNotMatchException extends UserException {
private static final long serialVersionUID = 1L;
public UserPasswordNotMatchException() {
super("user.password.not.match", null);
super("user.password.not.match");
}
}

View File

@ -0,0 +1,45 @@
package com.ruoyi.common.helper;
import cn.hutool.core.util.ObjectUtil;
import com.ruoyi.common.utils.ServletUtils;
import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.Map;
/**
* 数据权限助手
*
* @author Lion Li
* @version 3.5.0
*/
@SuppressWarnings("unchecked cast")
public class DataPermissionHelper {
private static final String DATA_PERMISSION_KEY = "data:permission";
public static <T> T getVariable(String key) {
Map<String, Object> context = getContext();
return (T) context.get(key);
}
public static void setVariable(String key, Object value) {
Map<String, Object> context = getContext();
context.put(key, value);
}
public static Map<String, Object> getContext() {
HttpServletRequest request = ServletUtils.getRequest();
Object attribute = request.getAttribute(DATA_PERMISSION_KEY);
if (ObjectUtil.isNull(attribute)) {
request.setAttribute(DATA_PERMISSION_KEY, new HashMap<>());
attribute = request.getAttribute(DATA_PERMISSION_KEY);
}
if (attribute instanceof Map) {
return (Map<String, Object>) attribute;
}
throw new NullPointerException("data permission context type exception");
}
}

View File

@ -1,66 +1,120 @@
package com.ruoyi.common.utils;
import cn.hutool.core.bean.copier.BeanCopier;
import cn.hutool.core.bean.copier.CopyOptions;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.map.MapUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.ReflectUtil;
import cn.hutool.extra.cglib.CglibUtil;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import java.util.List;
import java.util.stream.Collectors;
import java.util.Map;
/**
* bean深拷贝工具
* bean深拷贝工具(基于 cglib 性能优异)
*
* @author Lion Li
*/
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public class BeanCopyUtils {
/**
* 单对象基于class创建拷贝
*
* @param source 数据来源实体
* @param copyOptions copy条件
* @param desc 描述对象 转换后的对象
* @param source 数据来源实体
* @param desc 描述对象 转换后的对象
* @return desc
*/
public static <T, V> V oneCopy(T source, CopyOptions copyOptions, Class<V> desc) {
V v = ReflectUtil.newInstanceIfPossible(desc);
return oneCopy(source, copyOptions, v);
public static <T, V> V copy(T source, Class<V> desc) {
if (ObjectUtil.isNull(source)) {
return null;
}
if (ObjectUtil.isNull(desc)) {
return null;
}
return CglibUtil.copy(source, desc);
}
/**
* 单对象基于对象创建拷贝
*
* @param source 数据来源实体
* @param copyOptions copy条件
* @param desc 转换后的对象
* @param source 数据来源实体
* @param desc 转换后的对象
* @return desc
*/
public static <T, V> V oneCopy(T source, CopyOptions copyOptions, V desc) {
public static <T, V> V copy(T source, V desc) {
if (ObjectUtil.isNull(source)) {
return null;
}
return BeanCopier.create(source, desc, copyOptions).copy();
if (ObjectUtil.isNull(desc)) {
return null;
}
CglibUtil.copy(source, desc);
return desc;
}
/**
* 列表对象基于class创建拷贝
*
* @param sourceList 数据来源实体列表
* @param copyOptions copy条件
* @param desc 描述对象 转换后的对象
* @param sourceList 数据来源实体列表
* @param desc 描述对象 转换后的对象
* @return desc
*/
public static <T, V> List<V> listCopy(List<T> sourceList, CopyOptions copyOptions, Class<V> desc) {
public static <T, V> List<V> copyList(List<T> sourceList, Class<V> desc) {
if (ObjectUtil.isNull(sourceList)) {
return null;
}
if (CollUtil.isEmpty(sourceList)) {
return CollUtil.newArrayList();
}
return sourceList.stream()
.map(source -> oneCopy(source, copyOptions, desc))
.collect(Collectors.toList());
return CglibUtil.copyList(sourceList, () -> ReflectUtil.newInstanceIfPossible(desc));
}
/**
* bean拷贝到map
*
* @param bean 数据来源实体
* @return map对象
*/
public static <T> Map<String, Object> copyToMap(T bean) {
if (ObjectUtil.isNull(bean)) {
return null;
}
return CglibUtil.toMap(bean);
}
/**
* map拷贝到bean
*
* @param map 数据来源
* @param beanClass bean类
* @return bean对象
*/
public static <T> T mapToBean(Map<String, Object> map, Class<T> beanClass) {
if (MapUtil.isEmpty(map)) {
return null;
}
if (ObjectUtil.isNull(beanClass)) {
return null;
}
return CglibUtil.toBean(map, beanClass);
}
/**
* map拷贝到bean
*
* @param map 数据来源
* @param bean bean对象
* @return bean对象
*/
public static <T> T mapToBean(Map<String, Object> map, T bean) {
if (MapUtil.isEmpty(map)) {
return null;
}
if (ObjectUtil.isNull(bean)) {
return null;
}
return CglibUtil.fillBean(map, bean);
}
}

View File

@ -1,5 +1,7 @@
package com.ruoyi.common.utils;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import org.apache.commons.lang3.time.DateFormatUtils;
import java.lang.management.ManagementFactory;
@ -12,6 +14,7 @@ import java.util.Date;
*
* @author ruoyi
*/
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public class DateUtils extends org.apache.commons.lang3.time.DateUtils {
public static String YYYY = "yyyy";

View File

@ -1,157 +0,0 @@
package com.ruoyi.common.utils;
import cn.hutool.core.collection.CollUtil;
import com.ruoyi.common.constant.Constants;
import com.ruoyi.common.core.domain.entity.SysDictData;
import java.util.Collection;
import java.util.List;
/**
* 字典工具类
*
* @author ruoyi
*/
public class DictUtils {
/**
* 分隔符
*/
public static final String SEPARATOR = ",";
/**
* 设置字典缓存
*
* @param key 参数键
* @param dictDatas 字典数据列表
*/
public static void setDictCache(String key, List<SysDictData> dictDatas) {
RedisUtils.setCacheObject(getCacheKey(key), dictDatas);
}
/**
* 获取字典缓存
*
* @param key 参数键
* @return dictDatas 字典数据列表
*/
public static List<SysDictData> getDictCache(String key) {
Object cacheObj = RedisUtils.getCacheObject(getCacheKey(key));
if (StringUtils.isNotNull(cacheObj)) {
List<SysDictData> dictDatas = (List<SysDictData>) cacheObj;
return dictDatas;
}
return null;
}
/**
* 根据字典类型和字典值获取字典标签
*
* @param dictType 字典类型
* @param dictValue 字典值
* @return 字典标签
*/
public static String getDictLabel(String dictType, String dictValue) {
return getDictLabel(dictType, dictValue, SEPARATOR);
}
/**
* 根据字典类型和字典标签获取字典值
*
* @param dictType 字典类型
* @param dictLabel 字典标签
* @return 字典值
*/
public static String getDictValue(String dictType, String dictLabel) {
return getDictValue(dictType, dictLabel, SEPARATOR);
}
/**
* 根据字典类型和字典值获取字典标签
*
* @param dictType 字典类型
* @param dictValue 字典值
* @param separator 分隔符
* @return 字典标签
*/
public static String getDictLabel(String dictType, String dictValue, String separator) {
StringBuilder propertyString = new StringBuilder();
List<SysDictData> datas = getDictCache(dictType);
if (StringUtils.containsAny(dictValue, separator) && CollUtil.isNotEmpty(datas)) {
for (SysDictData dict : datas) {
for (String value : dictValue.split(separator)) {
if (value.equals(dict.getDictValue())) {
propertyString.append(dict.getDictLabel() + separator);
break;
}
}
}
} else {
for (SysDictData dict : datas) {
if (dictValue.equals(dict.getDictValue())) {
return dict.getDictLabel();
}
}
}
return StringUtils.stripEnd(propertyString.toString(), separator);
}
/**
* 根据字典类型和字典标签获取字典值
*
* @param dictType 字典类型
* @param dictLabel 字典标签
* @param separator 分隔符
* @return 字典值
*/
public static String getDictValue(String dictType, String dictLabel, String separator) {
StringBuilder propertyString = new StringBuilder();
List<SysDictData> datas = getDictCache(dictType);
if (StringUtils.containsAny(dictLabel, separator) && CollUtil.isNotEmpty(datas)) {
for (SysDictData dict : datas) {
for (String label : dictLabel.split(separator)) {
if (label.equals(dict.getDictLabel())) {
propertyString.append(dict.getDictValue() + separator);
break;
}
}
}
} else {
for (SysDictData dict : datas) {
if (dictLabel.equals(dict.getDictLabel())) {
return dict.getDictValue();
}
}
}
return StringUtils.stripEnd(propertyString.toString(), separator);
}
/**
* 删除指定字典缓存
*
* @param key 字典键
*/
public static void removeDictCache(String key) {
RedisUtils.deleteObject(getCacheKey(key));
}
/**
* 清空字典缓存
*/
public static void clearDictCache() {
Collection<String> keys = RedisUtils.keys(Constants.SYS_DICT_KEY + "*");
RedisUtils.deleteObject(keys);
}
/**
* 设置cache key
*
* @param configKey 参数键
* @return 缓存键key
*/
public static String getCacheKey(String configKey) {
return Constants.SYS_DICT_KEY + configKey;
}
}

View File

@ -21,14 +21,18 @@ import java.util.Map;
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public class JsonUtils {
private static ObjectMapper objectMapper = SpringUtils.getBean(ObjectMapper.class);
private static final ObjectMapper OBJECT_MAPPER = SpringUtils.getBean(ObjectMapper.class);
public static ObjectMapper getObjectMapper() {
return OBJECT_MAPPER;
}
public static String toJsonString(Object object) {
if (StringUtils.isNull(object)) {
return null;
}
try {
return objectMapper.writeValueAsString(object);
return OBJECT_MAPPER.writeValueAsString(object);
} catch (JsonProcessingException e) {
throw new RuntimeException(e);
}
@ -39,7 +43,7 @@ public class JsonUtils {
return null;
}
try {
return objectMapper.readValue(text, clazz);
return OBJECT_MAPPER.readValue(text, clazz);
} catch (IOException e) {
throw new RuntimeException(e);
}
@ -50,7 +54,7 @@ public class JsonUtils {
return null;
}
try {
return objectMapper.readValue(bytes, clazz);
return OBJECT_MAPPER.readValue(bytes, clazz);
} catch (IOException e) {
throw new RuntimeException(e);
}
@ -61,7 +65,7 @@ public class JsonUtils {
return null;
}
try {
return objectMapper.readValue(text, typeReference);
return OBJECT_MAPPER.readValue(text, typeReference);
} catch (IOException e) {
throw new RuntimeException(e);
}
@ -72,7 +76,7 @@ public class JsonUtils {
return null;
}
try {
return objectMapper.readValue(text, new TypeReference<Map<String, T>>() {
return OBJECT_MAPPER.readValue(text, new TypeReference<Map<String, T>>() {
});
} catch (IOException e) {
throw new RuntimeException(e);
@ -84,7 +88,7 @@ public class JsonUtils {
return new ArrayList<>();
}
try {
return objectMapper.readValue(text, objectMapper.getTypeFactory().constructCollectionType(List.class, clazz));
return OBJECT_MAPPER.readValue(text, OBJECT_MAPPER.getTypeFactory().constructCollectionType(List.class, clazz));
} catch (IOException e) {
throw new RuntimeException(e);
}

View File

@ -1,15 +1,21 @@
package com.ruoyi.common.utils;
import com.ruoyi.common.utils.spring.SpringUtils;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import org.springframework.context.MessageSource;
import org.springframework.context.i18n.LocaleContextHolder;
/**
* 获取i18n资源文件
*
* @author ruoyi
* @author Lion Li
*/
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public class MessageUtils {
private static final MessageSource MESSAGE_SOURCE = SpringUtils.getBean(MessageSource.class);
/**
* 根据消息键和参数 获取消息 委托给spring messageSource
*
@ -18,7 +24,6 @@ public class MessageUtils {
* @return 获取国际化翻译值
*/
public static String message(String code, Object... args) {
MessageSource messageSource = SpringUtils.getBean(MessageSource.class);
return messageSource.getMessage(code, args, LocaleContextHolder.getLocale());
return MESSAGE_SOURCE.getMessage(code, args, LocaleContextHolder.getLocale());
}
}

View File

@ -1,11 +1,16 @@
package com.ruoyi.common.utils;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.http.HttpStatus;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.metadata.OrderItem;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruoyi.common.core.domain.PageQuery;
import com.ruoyi.common.core.page.PagePlus;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.utils.sql.SqlUtil;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import java.util.List;
@ -13,37 +18,46 @@ import java.util.List;
* 分页工具
*
* @author Lion Li
* @deprecated 3.6.0 删除 请使用 {@link PageQuery} 与 {@link TableDataInfo}
*/
@Deprecated
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public class PageUtils {
/**
* 当前记录起始索引
*/
@Deprecated
public static final String PAGE_NUM = "pageNum";
/**
* 每页显示记录数
*/
@Deprecated
public static final String PAGE_SIZE = "pageSize";
/**
* 排序列
*/
@Deprecated
public static final String ORDER_BY_COLUMN = "orderByColumn";
/**
* 排序的方向 "desc" 或者 "asc".
*/
@Deprecated
public static final String IS_ASC = "isAsc";
/**
* 当前记录起始索引 默认值
*/
@Deprecated
public static final int DEFAULT_PAGE_NUM = 1;
/**
* 每页显示记录数 默认值 默认查全部
*/
@Deprecated
public static final int DEFAULT_PAGE_SIZE = Integer.MAX_VALUE;
/**
@ -52,7 +66,10 @@ public class PageUtils {
* @param <T> domain 实体
* @param <K> vo 实体
* @return 分页对象
* @deprecated 3.6.0 删除 请使用 {@link PageQuery#build()}
* 由于使用 Servlet 获取只能从 param 获取 灵活性降低 故将传参操作交给用户
*/
@Deprecated
public static <T, K> PagePlus<T, K> buildPagePlus() {
Integer pageNum = ServletUtils.getParameterToInt(PAGE_NUM, DEFAULT_PAGE_NUM);
Integer pageSize = ServletUtils.getParameterToInt(PAGE_SIZE, DEFAULT_PAGE_SIZE);
@ -63,10 +80,13 @@ public class PageUtils {
}
PagePlus<T, K> page = new PagePlus<>(pageNum, pageSize);
OrderItem orderItem = buildOrderItem(orderByColumn, isAsc);
page.addOrder(orderItem);
if (ObjectUtil.isNotNull(orderItem)) {
page.addOrder(orderItem);
}
return page;
}
@Deprecated
public static <T> Page<T> buildPage() {
return buildPage(null, null);
}
@ -76,7 +96,10 @@ public class PageUtils {
*
* @param <T> domain 实体
* @return 分页对象
* @deprecated 3.6.0 删除 请使用 {@link PageQuery#build()}
* 由于使用 Servlet 获取只能从 param 获取 灵活性降低 故将传参操作交给用户
*/
@Deprecated
public static <T> Page<T> buildPage(String defaultOrderByColumn, String defaultIsAsc) {
Integer pageNum = ServletUtils.getParameterToInt(PAGE_NUM, DEFAULT_PAGE_NUM);
Integer pageSize = ServletUtils.getParameterToInt(PAGE_SIZE, DEFAULT_PAGE_SIZE);
@ -87,7 +110,9 @@ public class PageUtils {
}
Page<T> page = new Page<>(pageNum, pageSize);
OrderItem orderItem = buildOrderItem(orderByColumn, isAsc);
page.addOrder(orderItem);
if (ObjectUtil.isNotNull(orderItem)) {
page.addOrder(orderItem);
}
return page;
}
@ -110,6 +135,15 @@ public class PageUtils {
return null;
}
/**
* 构建 MP 普通分页对象
*
* @param <T> domain 实体
* @return 分页对象
* @deprecated 3.6.0 删除 请使用 {@link PageQuery#build()}
* 由于使用 Servlet 获取只能从 param 获取 灵活性降低 故将传参操作交给用户
*/
@Deprecated
public static <T, K> TableDataInfo<K> buildDataInfo(PagePlus<T, K> page) {
TableDataInfo<K> rspData = new TableDataInfo<>();
rspData.setCode(HttpStatus.HTTP_OK);
@ -119,6 +153,10 @@ public class PageUtils {
return rspData;
}
/**
* @deprecated 3.6.0 删除 请使用 {@link TableDataInfo#build(IPage)}
*/
@Deprecated
public static <T> TableDataInfo<T> buildDataInfo(Page<T> page) {
TableDataInfo<T> rspData = new TableDataInfo<>();
rspData.setCode(HttpStatus.HTTP_OK);
@ -128,6 +166,10 @@ public class PageUtils {
return rspData;
}
/**
* @deprecated 3.6.0 删除 请使用 {@link TableDataInfo#build(List)}
*/
@Deprecated
public static <T> TableDataInfo<T> buildDataInfo(List<T> list) {
TableDataInfo<T> rspData = new TableDataInfo<>();
rspData.setCode(HttpStatus.HTTP_OK);
@ -137,6 +179,10 @@ public class PageUtils {
return rspData;
}
/**
* @deprecated 3.6.0 删除 请使用 {@link TableDataInfo#build()}
*/
@Deprecated
public static <T> TableDataInfo<T> buildDataInfo() {
TableDataInfo<T> rspData = new TableDataInfo<>();
rspData.setCode(HttpStatus.HTTP_OK);

View File

@ -1,6 +1,6 @@
package com.ruoyi.common.utils;
import com.google.common.collect.Lists;
import cn.hutool.core.collection.IterUtil;
import com.ruoyi.common.utils.spring.SpringUtils;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
@ -23,7 +23,7 @@ import java.util.function.Consumer;
@SuppressWarnings(value = {"unchecked", "rawtypes"})
public class RedisUtils {
private static RedissonClient client = SpringUtils.getBean(RedissonClient.class);
private static final RedissonClient CLIENT = SpringUtils.getBean(RedissonClient.class);
/**
* 限流
@ -35,7 +35,7 @@ public class RedisUtils {
* @return -1 表示失败
*/
public static long rateLimiter(String key, RateType rateType, int rate, int rateInterval) {
RRateLimiter rateLimiter = client.getRateLimiter(key);
RRateLimiter rateLimiter = CLIENT.getRateLimiter(key);
rateLimiter.trySetRate(rateType, rate, rateInterval, RateIntervalUnit.SECONDS);
if (rateLimiter.tryAcquire()) {
return rateLimiter.availablePermits();
@ -45,10 +45,10 @@ public class RedisUtils {
}
/**
* 获取实例id
* 获取客户端实例
*/
public static String getClientId() {
return client.getId();
public static RedissonClient getClient() {
return CLIENT;
}
/**
@ -59,13 +59,13 @@ public class RedisUtils {
* @param consumer 自定义处理
*/
public static <T> void publish(String channelKey, T msg, Consumer<T> consumer) {
RTopic topic = client.getTopic(channelKey);
RTopic topic = CLIENT.getTopic(channelKey);
topic.publish(msg);
consumer.accept(msg);
}
public static <T> void publish(String channelKey, T msg) {
RTopic topic = client.getTopic(channelKey);
RTopic topic = CLIENT.getTopic(channelKey);
topic.publish(msg);
}
@ -77,7 +77,7 @@ public class RedisUtils {
* @param consumer 自定义处理
*/
public static <T> void subscribe(String channelKey, Class<T> clazz, Consumer<T> consumer) {
RTopic topic = client.getTopic(channelKey);
RTopic topic = CLIENT.getTopic(channelKey);
topic.addListener(clazz, (channel, msg) -> consumer.accept(msg));
}
@ -88,7 +88,30 @@ public class RedisUtils {
* @param value 缓存的值
*/
public static <T> void setCacheObject(final String key, final T value) {
client.getBucket(key).set(value);
setCacheObject(key, value, false);
}
/**
* 缓存基本的对象,保留当前对象 TTL 有效期
*
* @param key 缓存的键值
* @param value 缓存的值
* @param isSaveTtl 是否保留TTL有效期(例如: set之前ttl剩余90 set之后还是为90)
* @since Redis 6.X 以上使用 setAndKeepTTL 兼容 5.X 方案
*/
public static <T> void setCacheObject(final String key, final T value, final boolean isSaveTtl) {
RBucket<Object> bucket = CLIENT.getBucket(key);
if (isSaveTtl) {
try {
bucket.setAndKeepTTL(value);
} catch (Exception e) {
long timeToLive = bucket.remainTimeToLive();
bucket.set(value);
bucket.expire(timeToLive, TimeUnit.MILLISECONDS);
}
} else {
bucket.set(value);
}
}
/**
@ -99,12 +122,25 @@ public class RedisUtils {
* @param timeout 时间
* @param timeUnit 时间颗粒度
*/
public static <T> void setCacheObject(final String key, final T value, final Integer timeout, final TimeUnit timeUnit) {
RBucket<T> result = client.getBucket(key);
public static <T> void setCacheObject(final String key, final T value, final long timeout, final TimeUnit timeUnit) {
RBucket<T> result = CLIENT.getBucket(key);
result.set(value);
result.expire(timeout, timeUnit);
}
/**
* 注册对象监听器
*
* key 监听器需开启 `notify-keyspace-events` 等 redis 相关配置
*
* @param key 缓存的键值
* @param listener 监听器配置
*/
public static <T> void addObjectListener(final String key, final ObjectListener listener) {
RBucket<T> result = CLIENT.getBucket(key);
result.addListener(listener);
}
/**
* 设置有效时间
*
@ -125,7 +161,7 @@ public class RedisUtils {
* @return true=设置成功false=设置失败
*/
public static boolean expire(final String key, final long timeout, final TimeUnit unit) {
RBucket rBucket = client.getBucket(key);
RBucket rBucket = CLIENT.getBucket(key);
return rBucket.expire(timeout, unit);
}
@ -136,29 +172,37 @@ public class RedisUtils {
* @return 缓存键值对应的数据
*/
public static <T> T getCacheObject(final String key) {
RBucket<T> rBucket = client.getBucket(key);
RBucket<T> rBucket = CLIENT.getBucket(key);
return rBucket.get();
}
/**
* 获得key剩余存活时间
*
* @param key 缓存键值
* @return 剩余存活时间
*/
public static <T> long getTimeToLive(final String key) {
RBucket<T> rBucket = CLIENT.getBucket(key);
return rBucket.remainTimeToLive();
}
/**
* 删除单个对象
*
* @param key
* @param key 缓存的键值
*/
public static boolean deleteObject(final String key) {
return client.getBucket(key).delete();
return CLIENT.getBucket(key).delete();
}
/* */
/**
* 删除集合对象
*
* @param collection 多个对象
* @return
*/
public static void deleteObject(final Collection collection) {
RBatch batch = client.createBatch();
RBatch batch = CLIENT.createBatch();
collection.forEach(t -> {
batch.getBucket(t.toString()).deleteAsync();
});
@ -173,10 +217,23 @@ public class RedisUtils {
* @return 缓存的对象
*/
public static <T> boolean setCacheList(final String key, final List<T> dataList) {
RList<T> rList = client.getList(key);
RList<T> rList = CLIENT.getList(key);
return rList.addAll(dataList);
}
/**
* 注册List监听器
*
* key 监听器需开启 `notify-keyspace-events` 等 redis 相关配置
*
* @param key 缓存的键值
* @param listener 监听器配置
*/
public static <T> void addListListener(final String key, final ObjectListener listener) {
RList<T> rList = CLIENT.getList(key);
rList.addListener(listener);
}
/**
* 获得缓存的list对象
*
@ -184,7 +241,7 @@ public class RedisUtils {
* @return 缓存键值对应的数据
*/
public static <T> List<T> getCacheList(final String key) {
RList<T> rList = client.getList(key);
RList<T> rList = CLIENT.getList(key);
return rList.readAll();
}
@ -196,42 +253,68 @@ public class RedisUtils {
* @return 缓存数据的对象
*/
public static <T> boolean setCacheSet(final String key, final Set<T> dataSet) {
RSet<T> rSet = client.getSet(key);
RSet<T> rSet = CLIENT.getSet(key);
return rSet.addAll(dataSet);
}
/**
* 注册Set监听器
*
* key 监听器需开启 `notify-keyspace-events` 等 redis 相关配置
*
* @param key 缓存的键值
* @param listener 监听器配置
*/
public static <T> void addSetListener(final String key, final ObjectListener listener) {
RSet<T> rSet = CLIENT.getSet(key);
rSet.addListener(listener);
}
/**
* 获得缓存的set
*
* @param key
* @return
* @param key 缓存的key
* @return set对象
*/
public static <T> Set<T> getCacheSet(final String key) {
RSet<T> rSet = client.getSet(key);
RSet<T> rSet = CLIENT.getSet(key);
return rSet.readAll();
}
/**
* 缓存Map
*
* @param key
* @param dataMap
* @param key 缓存的键值
* @param dataMap 缓存的数据
*/
public static <T> void setCacheMap(final String key, final Map<String, T> dataMap) {
if (dataMap != null) {
RMap<String, T> rMap = client.getMap(key);
RMap<String, T> rMap = CLIENT.getMap(key);
rMap.putAll(dataMap);
}
}
/**
* 注册Map监听器
*
* key 监听器需开启 `notify-keyspace-events` 等 redis 相关配置
*
* @param key 缓存的键值
* @param listener 监听器配置
*/
public static <T> void addMapListener(final String key, final ObjectListener listener) {
RMap<String, T> rMap = CLIENT.getMap(key);
rMap.addListener(listener);
}
/**
* 获得缓存的Map
*
* @param key
* @return
* @param key 缓存的键值
* @return map对象
*/
public static <T> Map<String, T> getCacheMap(final String key) {
RMap<String, T> rMap = client.getMap(key);
RMap<String, T> rMap = CLIENT.getMap(key);
return rMap.getAll(rMap.keySet());
}
@ -243,7 +326,7 @@ public class RedisUtils {
* @param value 值
*/
public static <T> void setCacheMapValue(final String key, final String hKey, final T value) {
RMap<String, T> rMap = client.getMap(key);
RMap<String, T> rMap = CLIENT.getMap(key);
rMap.put(hKey, value);
}
@ -255,7 +338,7 @@ public class RedisUtils {
* @return Hash中的对象
*/
public static <T> T getCacheMapValue(final String key, final String hKey) {
RMap<String, T> rMap = client.getMap(key);
RMap<String, T> rMap = CLIENT.getMap(key);
return rMap.get(hKey);
}
@ -267,7 +350,7 @@ public class RedisUtils {
* @return Hash中的对象
*/
public static <T> T delCacheMapValue(final String key, final String hKey) {
RMap<String, T> rMap = client.getMap(key);
RMap<String, T> rMap = CLIENT.getMap(key);
return rMap.remove(hKey);
}
@ -279,7 +362,7 @@ public class RedisUtils {
* @return Hash对象集合
*/
public static <K, V> Map<K, V> getMultiCacheMapValue(final String key, final Set<K> hKeys) {
RMap<K, V> rMap = client.getMap(key);
RMap<K, V> rMap = CLIENT.getMap(key);
return rMap.getAll(hKeys);
}
@ -290,7 +373,7 @@ public class RedisUtils {
* @return 对象列表
*/
public static Collection<String> keys(final String pattern) {
Iterable<String> iterable = client.getKeys().getKeysByPattern(pattern);
return Lists.newArrayList(iterable);
Iterable<String> iterable = CLIENT.getKeys().getKeysByPattern(pattern);
return IterUtil.toList(iterable);
}
}

View File

@ -3,6 +3,8 @@ package com.ruoyi.common.utils;
import cn.hutool.http.HttpStatus;
import com.ruoyi.common.core.domain.model.LoginUser;
import com.ruoyi.common.exception.ServiceException;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
@ -12,6 +14,7 @@ import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
*
* @author ruoyi
*/
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public class SecurityUtils {
/**

View File

@ -3,6 +3,8 @@ package com.ruoyi.common.utils;
import cn.hutool.core.convert.Convert;
import cn.hutool.extra.servlet.ServletUtil;
import cn.hutool.http.HttpStatus;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import org.springframework.http.MediaType;
import org.springframework.web.context.request.RequestAttributes;
import org.springframework.web.context.request.RequestContextHolder;
@ -19,6 +21,7 @@ import java.nio.charset.StandardCharsets;
*
* @author ruoyi
*/
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public class ServletUtils extends ServletUtil {
/**

View File

@ -7,6 +7,8 @@ import cn.hutool.core.util.ArrayUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.ReUtil;
import cn.hutool.core.util.StrUtil;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import java.util.*;
@ -15,6 +17,7 @@ import java.util.*;
*
* @author Lion Li
*/
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public class StringUtils extends org.apache.commons.lang3.StringUtils {
/**

View File

@ -1,7 +1,8 @@
package com.ruoyi.common.utils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import java.util.concurrent.*;
@ -10,8 +11,9 @@ import java.util.concurrent.*;
*
* @author ruoyi
*/
@Slf4j
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public class Threads {
private static final Logger logger = LoggerFactory.getLogger(Threads.class);
/**
* sleep等待,单位为毫秒
@ -38,7 +40,7 @@ public class Threads {
if (!pool.awaitTermination(120, TimeUnit.SECONDS)) {
pool.shutdownNow();
if (!pool.awaitTermination(120, TimeUnit.SECONDS)) {
logger.info("Pool did not terminate");
log.info("Pool did not terminate");
}
}
} catch (InterruptedException ie) {
@ -67,7 +69,7 @@ public class Threads {
}
}
if (t != null) {
logger.error(t.getMessage(), t);
log.error(t.getMessage(), t);
}
}
}

View File

@ -0,0 +1,29 @@
package com.ruoyi.common.utils;
import cn.hutool.core.lang.tree.Tree;
import cn.hutool.core.lang.tree.TreeNodeConfig;
import cn.hutool.core.lang.tree.TreeUtil;
import cn.hutool.core.lang.tree.parser.NodeParser;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import java.util.List;
/**
* 扩展 hutool TreeUtil 封装系统树构建
*
* @author Lion Li
*/
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public class TreeBuildUtils extends TreeUtil {
/**
* 根据前端定制差异化字段
*/
public static final TreeNodeConfig DEFAULT_CONFIG = TreeNodeConfig.DEFAULT_CONFIG.setNameKey("label");
public static <T> List<Tree<Long>> build(List<T> list, Long parentId, NodeParser<T, Long> nodeParser) {
return TreeUtil.build(list, parentId, DEFAULT_CONFIG, nodeParser);
}
}

View File

@ -0,0 +1,29 @@
package com.ruoyi.common.utils;
import com.ruoyi.common.utils.spring.SpringUtils;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import javax.validation.ConstraintViolation;
import javax.validation.ConstraintViolationException;
import javax.validation.Validator;
import java.util.Set;
/**
* Validator 校验框架工具
*
* @author Lion Li
*/
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public class ValidatorUtils {
private static final Validator VALID = SpringUtils.getBean(Validator.class);
public static <T> void validate(T object, Class<?>... groups) {
Set<ConstraintViolation<T>> validate = VALID.validate(object, groups);
if (!validate.isEmpty()) {
throw new ConstraintViolationException("参数校验异常", validate);
}
}
}

View File

@ -1,6 +1,8 @@
package com.ruoyi.common.utils.file;
import cn.hutool.core.io.FileUtil;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import javax.servlet.http.HttpServletResponse;
import java.io.UnsupportedEncodingException;
@ -12,6 +14,7 @@ import java.nio.charset.StandardCharsets;
*
* @author Lion Li
*/
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public class FileUtils extends FileUtil {
/**

View File

@ -7,6 +7,8 @@ import com.ruoyi.common.config.RuoYiConfig;
import com.ruoyi.common.constant.Constants;
import com.ruoyi.common.utils.JsonUtils;
import com.ruoyi.common.utils.StringUtils;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import java.util.Map;
@ -17,6 +19,7 @@ import java.util.Map;
* @author Lion Li
*/
@Slf4j
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public class AddressUtils {
// IP地址查询

View File

@ -4,9 +4,13 @@ import cn.hutool.core.util.IdUtil;
import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.write.style.column.LongestMatchColumnWidthStyleStrategy;
import com.ruoyi.common.convert.ExcelBigNumberConvert;
import com.ruoyi.common.utils.DictUtils;
import com.ruoyi.common.excel.DefaultExcelListener;
import com.ruoyi.common.excel.ExcelListener;
import com.ruoyi.common.excel.ExcelResult;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.file.FileUtils;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
@ -19,131 +23,136 @@ import java.util.List;
*
* @author Lion Li
*/
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public class ExcelUtil {
/**
* 对excel表单默认第一个索引名转换成listEasyExcel
*
* @param is 输入流
* @return 转换后集合
*/
public static <T> List<T> importExcel(InputStream is, Class<T> clazz) {
return EasyExcel.read(is).head(clazz).autoCloseStream(false).sheet().doReadSync();
}
/**
* 同步导入(适用于小数据量)
*
* @param is 输入流
* @return 转换后集合
*/
public static <T> List<T> importExcel(InputStream is, Class<T> clazz) {
return EasyExcel.read(is).head(clazz).autoCloseStream(false).sheet().doReadSync();
}
/**
* 对list数据源将其里面的数据导入到excel表单EasyExcel
*
* @param list 导出数据集合
* @param sheetName 工作表的名称
* @return 结果
*/
public static <T> void exportExcel(List<T> list, String sheetName, Class<T> clazz, HttpServletResponse response) {
try {
String filename = encodingFilename(sheetName);
response.reset();
FileUtils.setAttachmentResponseHeader(response, filename);
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=UTF-8");
ServletOutputStream os = response.getOutputStream();
EasyExcel.write(os, clazz)
.autoCloseStream(false)
// 自动适配
.registerWriteHandler(new LongestMatchColumnWidthStyleStrategy())
// 大数值自动转换 防止失真
.registerConverter(new ExcelBigNumberConvert())
.sheet(sheetName).doWrite(list);
} catch (IOException e) {
throw new RuntimeException("导出Excel异常");
}
}
/**
* 解析导出值 0=男,1=女,2=未知
*
* @param propertyValue 参数值
* @param converterExp 翻译注解
* @param separator 分隔符
* @return 解析后值
*/
public static String convertByExp(String propertyValue, String converterExp, String separator) {
StringBuilder propertyString = new StringBuilder();
String[] convertSource = converterExp.split(",");
for (String item : convertSource) {
String[] itemArray = item.split("=");
if (StringUtils.containsAny(separator, propertyValue)) {
for (String value : propertyValue.split(separator)) {
if (itemArray[0].equals(value)) {
propertyString.append(itemArray[1] + separator);
break;
}
}
} else {
if (itemArray[0].equals(propertyValue)) {
return itemArray[1];
}
}
}
return StringUtils.stripEnd(propertyString.toString(), separator);
}
/**
* 使用校验监听器 异步导入 同步返回
*
* @param is 输入流
* @param clazz 对象类型
* @param isValidate 是否 Validator 检验 默认为是
* @return 转换后集合
*/
public static <T> ExcelResult<T> importExcel(InputStream is, Class<T> clazz, boolean isValidate) {
DefaultExcelListener<T> listener = new DefaultExcelListener<>(isValidate);
EasyExcel.read(is, clazz, listener).sheet().doRead();
return listener.getExcelResult();
}
/**
* 反向解析值 男=0,女=1,未知=2
*
* @param propertyValue 参数值
* @param converterExp 翻译注解
* @param separator 分隔符
* @return 解析后值
*/
public static String reverseByExp(String propertyValue, String converterExp, String separator) {
StringBuilder propertyString = new StringBuilder();
String[] convertSource = converterExp.split(",");
for (String item : convertSource) {
String[] itemArray = item.split("=");
if (StringUtils.containsAny(separator, propertyValue)) {
for (String value : propertyValue.split(separator)) {
if (itemArray[1].equals(value)) {
propertyString.append(itemArray[0] + separator);
break;
}
}
} else {
if (itemArray[1].equals(propertyValue)) {
return itemArray[0];
}
}
}
return StringUtils.stripEnd(propertyString.toString(), separator);
}
/**
* 使用自定义监听器 异步导入 自定义返回
*
* @param is 输入流
* @param clazz 对象类型
* @param listener 自定义监听器
* @return 转换后集合
*/
public static <T> ExcelResult<T> importExcel(InputStream is, Class<T> clazz, ExcelListener<T> listener) {
EasyExcel.read(is, clazz, listener).sheet().doRead();
return listener.getExcelResult();
}
/**
* 解析字典值
*
* @param dictValue 字典值
* @param dictType 字典类型
* @param separator 分隔符
* @return 字典标签
*/
public static String convertDictByExp(String dictValue, String dictType, String separator) {
return DictUtils.getDictLabel(dictType, dictValue, separator);
}
/**
* 导出excel
*
* @param list 导出数据集合
* @param sheetName 工作表的名称
* @return 结果
*/
public static <T> void exportExcel(List<T> list, String sheetName, Class<T> clazz, HttpServletResponse response) {
try {
String filename = encodingFilename(sheetName);
response.reset();
FileUtils.setAttachmentResponseHeader(response, filename);
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=UTF-8");
ServletOutputStream os = response.getOutputStream();
EasyExcel.write(os, clazz)
.autoCloseStream(false)
// 自动适配
.registerWriteHandler(new LongestMatchColumnWidthStyleStrategy())
// 大数值自动转换 防止失真
.registerConverter(new ExcelBigNumberConvert())
.sheet(sheetName).doWrite(list);
} catch (IOException e) {
throw new RuntimeException("导出Excel异常");
}
}
/**
* 反向解析值字典值
*
* @param dictLabel 字典标签
* @param dictType 字典类型
* @param separator 分隔符
* @return 字典
*/
public static String reverseDictByExp(String dictLabel, String dictType, String separator) {
return DictUtils.getDictValue(dictType, dictLabel, separator);
}
/**
* 解析导出值 0=男,1=女,2=未知
*
* @param propertyValue 参数值
* @param converterExp 翻译注解
* @param separator 分隔符
* @return 解析后
*/
public static String convertByExp(String propertyValue, String converterExp, String separator) {
StringBuilder propertyString = new StringBuilder();
String[] convertSource = converterExp.split(",");
for (String item : convertSource) {
String[] itemArray = item.split("=");
if (StringUtils.containsAny(separator, propertyValue)) {
for (String value : propertyValue.split(separator)) {
if (itemArray[0].equals(value)) {
propertyString.append(itemArray[1] + separator);
break;
}
}
} else {
if (itemArray[0].equals(propertyValue)) {
return itemArray[1];
}
}
}
return StringUtils.stripEnd(propertyString.toString(), separator);
}
/**
* 编码文件名
*/
public static String encodingFilename(String filename) {
return IdUtil.fastSimpleUUID() + "_" + filename + ".xlsx";
}
/**
* 反向解析值 男=0,女=1,未知=2
*
* @param propertyValue 参数值
* @param converterExp 翻译注解
* @param separator 分隔符
* @return 解析后值
*/
public static String reverseByExp(String propertyValue, String converterExp, String separator) {
StringBuilder propertyString = new StringBuilder();
String[] convertSource = converterExp.split(",");
for (String item : convertSource) {
String[] itemArray = item.split("=");
if (StringUtils.containsAny(separator, propertyValue)) {
for (String value : propertyValue.split(separator)) {
if (itemArray[1].equals(value)) {
propertyString.append(itemArray[0] + separator);
break;
}
}
} else {
if (itemArray[1].equals(propertyValue)) {
return itemArray[0];
}
}
}
return StringUtils.stripEnd(propertyString.toString(), separator);
}
/**
* 编码文件名
*/
public static String encodingFilename(String filename) {
return IdUtil.fastSimpleUUID() + "_" + filename + ".xlsx";
}
}

View File

@ -2,6 +2,8 @@ package com.ruoyi.common.utils.reflect;
import cn.hutool.core.util.ReflectUtil;
import com.ruoyi.common.utils.StringUtils;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import java.lang.reflect.Method;
@ -11,6 +13,7 @@ import java.lang.reflect.Method;
* @author Lion Li
*/
@SuppressWarnings("rawtypes")
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public class ReflectUtils extends ReflectUtil {
private static final String SETTER_PREFIX = "set";

View File

@ -2,17 +2,26 @@ package com.ruoyi.common.utils.sql;
import com.ruoyi.common.exception.UtilException;
import com.ruoyi.common.utils.StringUtils;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
/**
* sql操作工具类
*
* @author ruoyi
*/
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public class SqlUtil {
/**
* 定义常用的 sql关键字
*/
public static String SQL_REGEX = "select |insert |delete |update |drop |count |exec |chr |mid |master |truncate |char |and |declare ";
/**
* 仅支持字母、数字、下划线、空格、逗号、小数点(支持多个字段排序)
*/
public static String SQL_PATTERN = "[a-zA-Z0-9_\\ \\,\\.]+";
public static final String SQL_PATTERN = "[a-zA-Z0-9_\\ \\,\\.]+";
/**
* 检查字符,防止注入绕过
@ -30,4 +39,19 @@ public class SqlUtil {
public static boolean isValidOrderBySql(String value) {
return value.matches(SQL_PATTERN);
}
/**
* SQL关键字检查
*/
public static void filterKeyword(String value) {
if (StringUtils.isEmpty(value)) {
return;
}
String[] sqlKeywords = StringUtils.split(SQL_REGEX, "\\|");
for (String sqlKeyword : sqlKeywords) {
if (StringUtils.indexOfIgnoreCase(value, sqlKeyword) > -1) {
throw new UtilException("参数存在SQL注入风险");
}
}
}
}

View File

@ -0,0 +1,26 @@
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 Lion Li
*/
@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,21 @@
package com.ruoyi.common.xss;
import cn.hutool.core.util.ReUtil;
import cn.hutool.http.HtmlUtil;
import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;
/**
* 自定义xss校验注解实现
*
* @author Lion Li
*/
public class XssValidator implements ConstraintValidator<Xss, String> {
@Override
public boolean isValid(String value, ConstraintValidatorContext constraintValidatorContext) {
return !ReUtil.contains(HtmlUtil.RE_HTML_MARK, value);
}
}

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>ruoyi-vue-plus</artifactId>
<groupId>com.ruoyi</groupId>
<version>3.3.0</version>
<version>3.5.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -1,37 +0,0 @@
package com.ruoyi.demo.controller;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.demo.feign.FeignTestService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* feign测试controller
*
* @author Lion Li
* @deprecated 由于使用人数较少 决定与 3.4.0 版本移除
*/
@Api(value = "feign测试", tags = {"feign测试"})
@RequiredArgsConstructor(onConstructor_ = @Autowired)
@RestController
@RequestMapping("/feign/test")
public class FeignTestController {
private final FeignTestService feignTestService;
/**
* 搜索数据
*/
@ApiOperation("测试使用feign请求数据")
@GetMapping("/search/{wd}")
public AjaxResult search(@PathVariable String wd) {
String search = feignTestService.search(wd);
return AjaxResult.success("操作成功",search);
}
}

View File

@ -28,75 +28,75 @@ import java.util.concurrent.TimeUnit;
@RequestMapping("/demo/cache")
public class RedisCacheController {
/**
* 测试 @Cacheable
*
* 表示这个方法有了缓存的功能,方法的返回值会被缓存下来
* 下一次调用该方法前,会去检查是否缓存中已经有值
* 如果有就直接返回,不调用方法
* 如果没有,就调用方法,然后把结果缓存起来
* 这个注解「一般用在查询方法上」
*
* 重点说明: 缓存注解严谨与其他筛选数据功能一起使用
* 例如: 数据权限注解 会造成 缓存击穿 与 数据不一致问题
*
* cacheNames 为配置文件内 groupId
*/
@ApiOperation("测试 @Cacheable")
@Cacheable(cacheNames = "redissonCacheMap", key = "#key", condition = "#key != null")
@GetMapping("/test1")
public AjaxResult<String> test1(String key, String value){
return AjaxResult.success("操作成功", value);
}
/**
* 测试 @Cacheable
* <p>
* 表示这个方法有了缓存的功能,方法的返回值会被缓存下来
* 下一次调用该方法前,会去检查是否缓存中已经有值
* 如果有就直接返回,不调用方法
* 如果没有,就调用方法,然后把结果缓存起来
* 这个注解「一般用在查询方法上」
* <p>
* 重点说明: 缓存注解严谨与其他筛选数据功能一起使用
* 例如: 数据权限注解 会造成 缓存击穿 与 数据不一致问题
* <p>
* cacheNames 为配置文件内 groupId
*/
@ApiOperation("测试 @Cacheable")
@Cacheable(cacheNames = "redissonCacheMap", key = "#key", condition = "#key != null")
@GetMapping("/test1")
public AjaxResult<String> test1(String key, String value) {
return AjaxResult.success("操作成功", value);
}
/**
* 测试 @CachePut
*
* 加了@CachePut注解的方法,会把方法的返回值put到缓存里面缓存起来,供其它地方使用
* 它「通常用在新增方法上」
*
* cacheNames 为 配置文件内 groupId
*/
@ApiOperation("测试 @CachePut")
@CachePut(cacheNames = "redissonCacheMap", key = "#key", condition = "#key != null")
@GetMapping("/test2")
public AjaxResult<String> test2(String key, String value){
return AjaxResult.success("操作成功", value);
}
/**
* 测试 @CachePut
* <p>
* 加了@CachePut注解的方法,会把方法的返回值put到缓存里面缓存起来,供其它地方使用
* 它「通常用在新增方法上」
* <p>
* cacheNames 为 配置文件内 groupId
*/
@ApiOperation("测试 @CachePut")
@CachePut(cacheNames = "redissonCacheMap", key = "#key", condition = "#key != null")
@GetMapping("/test2")
public AjaxResult<String> test2(String key, String value) {
return AjaxResult.success("操作成功", value);
}
/**
* 测试 @CacheEvict
*
* 使用了CacheEvict注解的方法,会清空指定缓存
* 「一般用在更新或者删除的方法上」
*
* cacheNames 为 配置文件内 groupId
*/
@ApiOperation("测试 @CacheEvict")
@CacheEvict(cacheNames = "redissonCacheMap", key = "#key", condition = "#key != null")
@GetMapping("/test3")
public AjaxResult<String> test3(String key, String value){
return AjaxResult.success("操作成功", value);
}
/**
* 测试 @CacheEvict
* <p>
* 使用了CacheEvict注解的方法,会清空指定缓存
* 「一般用在更新或者删除的方法上」
* <p>
* cacheNames 为 配置文件内 groupId
*/
@ApiOperation("测试 @CacheEvict")
@CacheEvict(cacheNames = "redissonCacheMap", key = "#key", condition = "#key != null")
@GetMapping("/test3")
public AjaxResult<String> test3(String key, String value) {
return AjaxResult.success("操作成功", value);
}
/**
* 测试设置过期时间
* 手动设置过期时间10秒
* 11秒后获取 判断是否相等
*/
@ApiOperation("测试设置过期时间")
@GetMapping("/test6")
public AjaxResult<Boolean> test6(String key, String value){
RedisUtils.setCacheObject(key, value);
boolean flag = RedisUtils.expire(key, 10, TimeUnit.SECONDS);
System.out.println("***********" + flag);
try {
Thread.sleep(11 * 1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
Object obj = RedisUtils.getCacheObject(key);
return AjaxResult.success("操作成功", value.equals(obj));
}
/**
* 测试设置过期时间
* 手动设置过期时间10秒
* 11秒后获取 判断是否相等
*/
@ApiOperation("测试设置过期时间")
@GetMapping("/test6")
public AjaxResult<Boolean> test6(String key, String value) {
RedisUtils.setCacheObject(key, value);
boolean flag = RedisUtils.expire(key, 10, TimeUnit.SECONDS);
System.out.println("***********" + flag);
try {
Thread.sleep(11 * 1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
Object obj = RedisUtils.getCacheObject(key);
return AjaxResult.success("操作成功", value.equals(obj));
}
}

View File

@ -9,7 +9,6 @@ import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@ -28,59 +27,50 @@ import java.time.LocalTime;
@RequestMapping("/demo/redisLock")
public class RedisLockController {
@Autowired
private LockTemplate lockTemplate;
@Autowired
private LockTemplate lockTemplate;
/**
* 测试lock4j 注解
*/
@ApiOperation("测试lock4j 注解")
@Lock4j(keys = {"#key"})
@GetMapping("/testLock4j")
public AjaxResult<String> testLock4j(String key,String value){
System.out.println("start:"+key+",time:"+ LocalTime.now().toString());
try {
Thread.sleep(10000);
} catch (InterruptedException e) {
e.printStackTrace();
}
System.out.println("end :"+key+",time:"+LocalTime.now().toString());
return AjaxResult.success("操作成功",value);
}
/**
* 测试lock4j 注解
*/
@ApiOperation("测试lock4j 注解")
@Lock4j(keys = {"#key"})
@GetMapping("/testLock4j")
public AjaxResult<String> testLock4j(String key, String value) {
System.out.println("start:" + key + ",time:" + LocalTime.now().toString());
try {
Thread.sleep(10000);
} catch (InterruptedException e) {
e.printStackTrace();
}
System.out.println("end :" + key + ",time:" + LocalTime.now().toString());
return AjaxResult.success("操作成功", value);
}
/**
* 测试lock4j 工具
*/
@ApiOperation("测试lock4j 工具")
@GetMapping("/testLock4jLockTemaplate")
public AjaxResult<String> testLock4jLockTemaplate(String key,String value){
final LockInfo lockInfo = lockTemplate.lock(key, 30000L, 5000L, RedissonLockExecutor.class);
if (null == lockInfo) {
throw new RuntimeException("业务处理中,请稍后再试");
}
// 获取锁成功,处理业务
try {
try {
Thread.sleep(8000);
} catch (InterruptedException e) {
//
}
System.out.println("执行简单方法1 , 当前线程:" + Thread.currentThread().getName());
} finally {
//释放锁
lockTemplate.releaseLock(lockInfo);
}
//结束
return AjaxResult.success("操作成功",value);
}
/**
* 测试lock4j 工具
*/
@ApiOperation("测试lock4j 工具")
@GetMapping("/testLock4jLockTemaplate")
public AjaxResult<String> testLock4jLockTemaplate(String key, String value) {
final LockInfo lockInfo = lockTemplate.lock(key, 30000L, 5000L, RedissonLockExecutor.class);
if (null == lockInfo) {
throw new RuntimeException("业务处理中,请稍后再试");
}
// 获取锁成功,处理业务
try {
try {
Thread.sleep(8000);
} catch (InterruptedException e) {
//
}
System.out.println("执行简单方法1 , 当前线程:" + Thread.currentThread().getName());
} finally {
//释放锁
lockTemplate.releaseLock(lockInfo);
}
//结束
return AjaxResult.success("操作成功", value);
}
/**
* 测试spring-cache注解
*/
@ApiOperation("测试spring-cache注解")
@Cacheable(value = "test", key = "#key")
@GetMapping("/testCache")
public AjaxResult<String> testCache(String key) {
return AjaxResult.success("操作成功", key);
}
}

View File

@ -4,6 +4,7 @@ import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.RedisUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
@ -21,22 +22,22 @@ import org.springframework.web.bind.annotation.RestController;
@RequestMapping("/demo/redis/pubsub")
public class RedisPubSubController {
@ApiOperation("发布消息")
@GetMapping("/pub")
public AjaxResult<Void> pub(String key, String value){
RedisUtils.publish(key, value, consumer -> {
System.out.println("发布通道 => " + key + ", 发送值 => " + value);
});
return AjaxResult.success("操作成功");
}
@ApiOperation("发布消息")
@GetMapping("/pub")
public AjaxResult<Void> pub(@ApiParam("通道Key") String key, @ApiParam("发送内容") String value) {
RedisUtils.publish(key, value, consumer -> {
System.out.println("发布通道 => " + key + ", 发送值 => " + value);
});
return AjaxResult.success("操作成功");
}
@ApiOperation("订阅消息")
@GetMapping("/sub")
public AjaxResult<Void> sub(String key){
RedisUtils.subscribe(key, String.class, msg -> {
System.out.println("订阅通道 => " + key + ", 接收值 => " + msg);
});
return AjaxResult.success("操作成功");
}
@ApiOperation("订阅消息")
@GetMapping("/sub")
public AjaxResult<Void> sub(@ApiParam("通道Key") String key) {
RedisUtils.subscribe(key, String.class, msg -> {
System.out.println("订阅通道 => " + key + ", 接收值 => " + msg);
});
return AjaxResult.success("操作成功");
}
}

View File

@ -22,37 +22,37 @@ import org.springframework.web.bind.annotation.RestController;
@RequestMapping("/demo/rateLimiter")
public class RedisRateLimiterController {
/**
* 测试全局限流
* 全局影响
*/
@ApiOperation("测试全局限流")
@RateLimiter(count = 2, time = 10)
@GetMapping("/test")
public AjaxResult<String> test(String value){
return AjaxResult.success("操作成功",value);
}
/**
* 测试全局限流
* 全局影响
*/
@ApiOperation("测试全局限流")
@RateLimiter(count = 2, time = 10)
@GetMapping("/test")
public AjaxResult<String> test(String value) {
return AjaxResult.success("操作成功", value);
}
/**
* 测试请求IP限流
* 同一IP请求受影响
*/
@ApiOperation("测试请求IP限流")
@RateLimiter(count = 2, time = 10, limitType = LimitType.IP)
@GetMapping("/testip")
public AjaxResult<String> testip(String value){
return AjaxResult.success("操作成功",value);
}
/**
* 测试请求IP限流
* 同一IP请求受影响
*/
@ApiOperation("测试请求IP限流")
@RateLimiter(count = 2, time = 10, limitType = LimitType.IP)
@GetMapping("/testip")
public AjaxResult<String> testip(String value) {
return AjaxResult.success("操作成功", value);
}
/**
* 测试集群实例限流
* 启动两个后端服务互不影响
*/
@ApiOperation("测试集群实例限流")
@RateLimiter(count = 2, time = 10, limitType = LimitType.CLUSTER)
@GetMapping("/testcluster")
public AjaxResult<String> testcluster(String value){
return AjaxResult.success("操作成功",value);
}
/**
* 测试集群实例限流
* 启动两个后端服务互不影响
*/
@ApiOperation("测试集群实例限流")
@RateLimiter(count = 2, time = 10, limitType = LimitType.CLUSTER)
@GetMapping("/testcluster")
public AjaxResult<String> testcluster(String value) {
return AjaxResult.success("操作成功", value);
}
}

View File

@ -21,18 +21,18 @@ import org.springframework.web.multipart.MultipartFile;
@RequestMapping("/swagger/demo")
public class Swagger3DemoController {
/**
* 上传请求
* 必须使用 @RequestPart 注解标注为文件
* dataType 必须为 "java.io.File"
*/
@ApiOperation(value = "通用上传请求")
@ApiImplicitParams({
@ApiImplicitParam(name = "file", value = "文件", dataType = "java.io.File", required = true),
})
@PostMapping(value = "/upload")
public AjaxResult<String> upload(@RequestPart("file") MultipartFile file) {
return AjaxResult.success("操作成功", file.getOriginalFilename());
}
/**
* 上传请求
* 必须使用 @RequestPart 注解标注为文件
* dataType 必须为 "java.io.File"
*/
@ApiOperation(value = "通用上传请求")
@ApiImplicitParams({
@ApiImplicitParam(name = "file", value = "文件", dataType = "java.io.File", required = true),
})
@PostMapping(value = "/upload")
public AjaxResult<String> upload(@RequestPart("file") MultipartFile file) {
return AjaxResult.success("操作成功", file.getOriginalFilename());
}
}

View File

@ -33,49 +33,53 @@ public class TestBatchController extends BaseController {
/**
* 新增批量方法 可完美替代 saveBatch 秒级插入上万数据 (对mysql负荷较大)
*
* 3.5.0 版本 增加 rewriteBatchedStatements=true 批处理参数 使 MP 原生批处理可以达到同样的速度
*/
@ApiOperation(value = "新增批量方法")
@ApiOperation(value = "新增批量方法")
@PostMapping("/add")
// @DataSource(DataSourceType.SLAVE)
// @DS("slave")
public AjaxResult<Void> add() {
List<TestDemo> list = new ArrayList<>();
for (int i = 0; i < 1000; i++) {
list.add(new TestDemo().setOrderNum(-1L).setTestKey("批量新增").setValue("测试新增"));
}
List<TestDemo> list = new ArrayList<>();
for (int i = 0; i < 1000; i++) {
list.add(new TestDemo().setOrderNum(-1L).setTestKey("批量新增").setValue("测试新增"));
}
return toAjax(iTestDemoService.saveAll(list) ? 1 : 0);
}
/**
* 新增或更新 可完美替代 saveOrUpdateBatch 高性能
*/
@ApiOperation(value = "新增或更新批量方法")
@PostMapping("/addOrUpdate")
// @DataSource(DataSourceType.SLAVE)
public AjaxResult<Void> addOrUpdate() {
List<TestDemo> list = new ArrayList<>();
for (int i = 0; i < 1000; i++) {
list.add(new TestDemo().setOrderNum(-1L).setTestKey("批量新增").setValue("测试新增"));
}
iTestDemoService.saveAll(list);
for (int i = 0; i < list.size(); i++) {
TestDemo testDemo = list.get(i);
testDemo.setTestKey("批量新增或修改").setValue("批量新增或修改");
if (i % 2 == 0) {
testDemo.setId(null);
}
}
return toAjax(iTestDemoService.saveOrUpdateAll(list) ? 1 : 0);
}
/**
* 新增或更新 可完美替代 saveOrUpdateBatch 高性能
*
* 3.5.0 版本 增加 rewriteBatchedStatements=true 批处理参数 使 MP 原生批处理可以达到同样的速度
*/
@ApiOperation(value = "新增或更新批量方法")
@PostMapping("/addOrUpdate")
// @DS("slave")
public AjaxResult<Void> addOrUpdate() {
List<TestDemo> list = new ArrayList<>();
for (int i = 0; i < 1000; i++) {
list.add(new TestDemo().setOrderNum(-1L).setTestKey("批量新增").setValue("测试新增"));
}
iTestDemoService.saveAll(list);
for (int i = 0; i < list.size(); i++) {
TestDemo testDemo = list.get(i);
testDemo.setTestKey("批量新增或修改").setValue("批量新增或修改");
if (i % 2 == 0) {
testDemo.setId(null);
}
}
return toAjax(iTestDemoService.saveOrUpdateAll(list) ? 1 : 0);
}
/**
* 删除批量方法
*/
@ApiOperation(value = "删除批量方法")
@ApiOperation(value = "删除批量方法")
@DeleteMapping()
// @DataSource(DataSourceType.SLAVE)
// @DS("slave")
public AjaxResult<Void> remove() {
return toAjax(iTestDemoService.remove(new LambdaQueryWrapper<TestDemo>()
.eq(TestDemo::getOrderNum, -1L)) ? 1 : 0);
.eq(TestDemo::getOrderNum, -1L)) ? 1 : 0);
}
}

View File

@ -1,25 +1,31 @@
package com.ruoyi.demo.controller;
import cn.hutool.core.bean.BeanUtil;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.annotation.RepeatSubmit;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.PageQuery;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.core.validate.AddGroup;
import com.ruoyi.common.core.validate.EditGroup;
import com.ruoyi.common.core.validate.QueryGroup;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.ValidatorUtils;
import com.ruoyi.common.excel.ExcelResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.demo.domain.TestDemo;
import com.ruoyi.demo.domain.bo.TestDemoBo;
import com.ruoyi.demo.domain.bo.TestDemoImportVo;
import com.ruoyi.demo.domain.vo.TestDemoVo;
import com.ruoyi.demo.service.ITestDemoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.*;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
import javax.validation.constraints.NotEmpty;
@ -49,34 +55,49 @@ public class TestDemoController extends BaseController {
@ApiOperation("查询测试单表列表")
@PreAuthorize("@ss.hasPermi('demo:demo:list')")
@GetMapping("/list")
public TableDataInfo<TestDemoVo> list(@Validated(QueryGroup.class) TestDemoBo bo) {
return iTestDemoService.queryPageList(bo);
public TableDataInfo<TestDemoVo> list(@Validated(QueryGroup.class) TestDemoBo bo, PageQuery pageQuery) {
return iTestDemoService.queryPageList(bo, pageQuery);
}
/**
* 自定义分页查询
*/
@ApiOperation("自定义分页查询")
@PreAuthorize("@ss.hasPermi('demo:demo:list')")
@GetMapping("/page")
public TableDataInfo<TestDemoVo> page(@Validated(QueryGroup.class) TestDemoBo bo) {
return iTestDemoService.customPageList(bo);
}
/**
* 自定义分页查询
*/
@ApiOperation("自定义分页查询")
@PreAuthorize("@ss.hasPermi('demo:demo:list')")
@GetMapping("/page")
public TableDataInfo<TestDemoVo> page(@Validated(QueryGroup.class) TestDemoBo bo, PageQuery pageQuery) {
return iTestDemoService.customPageList(bo, pageQuery);
}
/**
@ApiOperation("导入测试-校验")
@ApiImplicitParams({
@ApiImplicitParam(name = "file", value = "导入文件", dataType = "java.io.File", required = true),
})
@Log(title = "测试单表", businessType = BusinessType.IMPORT)
@PreAuthorize("@ss.hasPermi('demo:demo:import')")
@PostMapping("/importData")
public AjaxResult<Void> importData(@RequestPart("file") MultipartFile file) throws Exception {
ExcelResult<TestDemoImportVo> excelResult = ExcelUtil.importExcel(file.getInputStream(), TestDemoImportVo.class, true);
List<TestDemoImportVo> volist = excelResult.getList();
List<TestDemo> list = BeanUtil.copyToList(volist, TestDemo.class);
iTestDemoService.saveAll(list);
return AjaxResult.success(excelResult.getAnalysis());
}
/**
* 导出测试单表列表
*/
@ApiOperation("导出测试单表列表")
@PreAuthorize("@ss.hasPermi('demo:demo:export')")
@Log(title = "测试单表", businessType = BusinessType.EXPORT)
@GetMapping("/export")
@PostMapping("/export")
public void export(@Validated TestDemoBo bo, HttpServletResponse response) {
List<TestDemoVo> list = iTestDemoService.queryList(bo);
// 测试雪花id导出
// 测试雪花id导出
// for (TestDemoVo vo : list) {
// vo.setId(1234567891234567893L);
// }
ExcelUtil.exportExcel(list, "测试单表", TestDemoVo.class, response);
ExcelUtil.exportExcel(list, "测试单表", TestDemoVo.class, response);
}
/**
@ -85,8 +106,9 @@ public class TestDemoController extends BaseController {
@ApiOperation("获取测试单表详细信息")
@PreAuthorize("@ss.hasPermi('demo:demo:query')")
@GetMapping("/{id}")
public AjaxResult<TestDemoVo> getInfo(@NotNull(message = "主键不能为空")
@PathVariable("id") Long id) {
public AjaxResult<TestDemoVo> getInfo(@ApiParam("测试ID")
@NotNull(message = "主键不能为空")
@PathVariable("id") Long id) {
return AjaxResult.success(iTestDemoService.queryById(id));
}
@ -98,7 +120,10 @@ public class TestDemoController extends BaseController {
@Log(title = "测试单表", businessType = BusinessType.INSERT)
@RepeatSubmit(interval = 2, timeUnit = TimeUnit.SECONDS, message = "不允许重复提交")
@PostMapping()
public AjaxResult<Void> add(@Validated(AddGroup.class) @RequestBody TestDemoBo bo) {
public AjaxResult<Void> add(@RequestBody TestDemoBo bo) {
// 使用校验工具对标 @Validated(AddGroup.class) 注解
// 用于在非 Controller 的地方校验对象
ValidatorUtils.validate(bo, AddGroup.class);
return toAjax(iTestDemoService.insertByBo(bo) ? 1 : 0);
}
@ -119,10 +144,11 @@ public class TestDemoController extends BaseController {
*/
@ApiOperation("删除测试单表")
@PreAuthorize("@ss.hasPermi('demo:demo:remove')")
@Log(title = "测试单表" , businessType = BusinessType.DELETE)
@Log(title = "测试单表", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult<Void> remove(@NotEmpty(message = "主键不能为空")
@PathVariable Long[] ids) {
public AjaxResult<Void> remove(@ApiParam("测试ID串")
@NotEmpty(message = "主键不能为空")
@PathVariable Long[] ids) {
return toAjax(iTestDemoService.deleteWithValidByIds(Arrays.asList(ids), true) ? 1 : 0);
}
}

View File

@ -4,16 +4,24 @@ import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.MessageUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.Data;
import org.hibernate.validator.constraints.Range;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
/**
* 测试国际化
*
* @author Lion Li
*/
@Validated
@Api(value = "测试国际化控制器", tags = {"测试国际化管理"})
@RestController
@RequestMapping("/demo/i18n")
@ -27,7 +35,42 @@ public class TestI18nController {
*/
@ApiOperation("通过code获取国际化内容")
@GetMapping()
public AjaxResult<Void> get(String code) {
public AjaxResult<Void> get(@ApiParam("国际化code") String code) {
return AjaxResult.success(MessageUtils.message(code));
}
/**
* Validator 校验国际化
* 不传值 分别查看异常返回
*
* 测试使用 not.null
*/
@ApiOperation("Validator 校验国际化")
@GetMapping("/test1")
public AjaxResult<Void> test1(@NotBlank(message = "{not.null}") String str) {
return AjaxResult.success(str);
}
/**
* Bean 校验国际化
* 不传值 分别查看异常返回
*
* 测试使用 not.null
*/
@ApiOperation("Bean 校验国际化")
@GetMapping("/test2")
public AjaxResult<TestI18nBo> test2(@Validated TestI18nBo bo) {
return AjaxResult.success(bo);
}
@Data
public static class TestI18nBo {
@NotBlank(message = "{not.null}")
private String name;
@NotNull(message = "{not.null}")
@Range(min = 0, max = 100, message = "{length.not.valid}")
private Integer age;
}
}

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