303 Commits

Author SHA1 Message Date
9b57c67d3e Merge remote-tracking branch 'origin/dev' into 4.X 2022-06-28 09:44:10 +08:00
7545323eba 😘 发布 4.2.0 2022-06-28 09:39:34 +08:00
5eff9a50b6 update 优化 nginx 限制外网访问内网 actuator 相关路径 2022-06-27 23:02:20 +08:00
7dc33c9247 update springboot 2.6.8 => 2.6.9
update easyexcel 3.1.0 => 3.1.1
update hutool 5.8.2 => 5.8.3
update redisson 3.17.2 => 3.17.4
update aws-java-sdk-s3 1.12.215 => 1.12.248
update tencentcloud-sdk-java 3.1.500 => 3.1.537
2022-06-27 11:03:27 +08:00
f25a9832b8 update 优化 logback 删除无用配置 2022-06-20 14:48:55 +08:00
11d5e2cdbb update 优化 代码生成 业务接口 增加事务回滚 2022-06-17 10:35:43 +08:00
15f7a7db65 fix 修复 代码生成表字段类型不匹配 导致查询不准确问题 2022-06-17 10:23:40 +08:00
aec194ba61 update druid 1.2.9 => 1.2.11 2022-06-15 18:22:50 +08:00
63eb145772 update 同步 ruoyi 2022-06-15 18:18:51 +08:00
db5fea922f 升级fastjson到最新版2.0.7 2022-06-15 17:08:29 +08:00
0214d93299 删除多余的salt字段 2022-06-15 17:08:06 +08:00
1124a203cc 升级druid到最新版本1.2.11 2022-06-14 21:29:06 +08:00
e8fbf5fdbd reset babel 2022-06-14 21:26:14 +08:00
8fd4ae1282 优化druid开启wall过滤器出现的异常问题 2022-06-13 21:43:31 +08:00
eab1b450d5 优化代码 2022-06-13 21:43:11 +08:00
98fc30786e !504 update 优化新增用户与角色信息、用户与岗位信息逻辑
Merge pull request !504 from 疯狂的狮子Li/N/A
2022-06-13 13:26:04 +00:00
4cb8e239ae !186 fix: 修复用户注销时,没有记录注销日志
Merge pull request !186 from 沫离/dev
2022-06-13 09:31:45 +00:00
ea781293df fix: 修复用户注销时,没有记录注销日志 2022-06-13 17:23:59 +08:00
0a2979360e update 优化 替换 MP 过期常量 2022-06-10 11:48:38 +08:00
0c75048e70 update tlog 1.4.0 => 1.4.3 2022-06-09 10:36:11 +08:00
a07c004983 update 补全导包 2022-06-09 10:35:45 +08:00
1018a0eda6 update 满足用户需求 2022-06-09 00:47:47 +08:00
d1e4898924 update 简化生成代码注释 2022-06-09 00:45:06 +08:00
a46c4bf04e update 优化新增用户与角色信息、用户与岗位信息逻辑 2022-06-08 13:53:08 +00:00
d40667a798 !182 优化新增用户与角色信息、用户与岗位信息逻辑
Merge pull request !182 from zendwang/dev
2022-06-08 13:45:44 +00:00
0eca9e7401 update 优化新增用户与角色信息、用户与岗位信息逻辑 2022-06-08 15:37:40 +08:00
b76af31155 update 更新 readme 版本号错误问题 2022-06-07 11:06:23 +08:00
426aeb0a7f 发布 4.2.0-beta1 公测版 2022-06-07 11:04:43 +08:00
8a222df60e update docker mysql 8.0.27 => 8.0.29
update docker nginx 1.21.3 => 1.21.6
update docker redis 6.2.6 => 6.2.7
update docker minio 2021-10-27 => 2022-05-26
2022-06-07 11:04:00 +08:00
4c79fcb6ed update 优化 单表案例 导入接口文档注解写法 2022-06-06 16:16:57 +08:00
b27e55f4de add 增加 Excel 模板导出 测试类 2022-06-06 15:16:20 +08:00
a246cd044e add 增加 ExcelUtil 模板导出方法 支持 单列表/多列表 2022-06-06 15:16:07 +08:00
880101f338 remove 删除无用依赖 2022-06-06 13:48:14 +08:00
a2d0ff1328 update poi 4.1.2 => 5.2.2 性能大幅提升 2022-06-06 13:46:09 +08:00
5479b4db2b update 使用 SaStorage 优化 LoginHelper 一级缓存 避免 ThreadLocal 清理不干净问题 2022-06-03 00:02:55 +08:00
da0c86dd54 update mybatis-plus 3.5.1 => 3.5.2 解决新版本兼容性问题 关键字冲突修改 2022-06-01 13:06:42 +08:00
e9f29cd147 update hutool 5.8.1 => 5.8.2 2022-06-01 13:03:59 +08:00
263448faa2 remove 移除不需要的依赖 2022-06-01 13:03:33 +08:00
34396de03a update 优化 ExcelUtil 工具支持合并处理器 2022-05-31 13:37:16 +08:00
f6fa17a3a8 add 新增 easyexcel 单元格合并注解与处理器 2022-05-31 13:36:55 +08:00
1dceadba4c update 用户头像上传限制只能为图片格式 2022-05-28 23:47:16 +08:00
666c80877c update 修改 代码生成 controller 去除查询校验 由用户自行选择是否校验 2022-05-28 23:30:58 +08:00
4cb9aab9ce update 优化 验证码 登录 登出 注册 等接口 使用匿名注解放行 2022-05-28 23:23:39 +08:00
51593aafb2 update 支持注解配置匿名访问 2022-05-28 23:10:45 +08:00
5ced7e05f5 Merge branch 'master' of https://gitee.com/y_project/RuoYi-Vue into dev
 Conflicts:
	README.md
	pom.xml
	ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysProfileController.java
	ruoyi-admin/src/main/java/com/ruoyi/web/controller/tool/TestController.java
	ruoyi-common/pom.xml
	ruoyi-common/src/main/java/com/ruoyi/common/core/domain/R.java
	ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/SysUser.java
	ruoyi-common/src/main/java/com/ruoyi/common/core/domain/model/LoginUser.java
	ruoyi-common/src/main/java/com/ruoyi/common/core/text/Convert.java
	ruoyi-common/src/main/java/com/ruoyi/common/exception/file/InvalidExtensionException.java
	ruoyi-common/src/main/java/com/ruoyi/common/utils/DictUtils.java
	ruoyi-common/src/main/java/com/ruoyi/common/utils/ip/AddressUtils.java
	ruoyi-common/src/main/java/com/ruoyi/common/utils/spring/SpringUtils.java
	ruoyi-framework/src/main/java/com/ruoyi/framework/aspectj/LogAspect.java
	ruoyi-framework/src/main/java/com/ruoyi/framework/config/FastJson2JsonRedisSerializer.java
	ruoyi-framework/src/main/java/com/ruoyi/framework/config/RedisConfig.java
	ruoyi-framework/src/main/java/com/ruoyi/framework/config/SecurityConfig.java
	ruoyi-framework/src/main/java/com/ruoyi/framework/interceptor/RepeatSubmitInterceptor.java
	ruoyi-framework/src/main/java/com/ruoyi/framework/interceptor/impl/SameUrlDataInterceptor.java
	ruoyi-framework/src/main/java/com/ruoyi/framework/security/handle/AuthenticationEntryPointImpl.java
	ruoyi-framework/src/main/java/com/ruoyi/framework/security/handle/LogoutSuccessHandlerImpl.java
	ruoyi-generator/src/main/java/com/ruoyi/generator/service/GenTableServiceImpl.java
	ruoyi-generator/src/main/java/com/ruoyi/generator/util/VelocityUtils.java
	ruoyi-system/src/main/resources/mapper/system/SysOperLogMapper.xml
	ruoyi-system/src/main/resources/mapper/system/SysUserMapper.xml
	ruoyi-ui/src/views/index.vue
2022-05-28 22:30:06 +08:00
b97a662f2e 新增Anonymous匿名访问不鉴权注解 2022-05-28 09:34:05 +08:00
9639c096ba 用户列表查询不显示密码字段 2022-05-27 17:50:49 +08:00
e4af41e89a !497 增加对空字符串参数的过滤
Merge pull request !497 from root/master
2022-05-27 08:53:42 +00:00
52e1717014 增加对空字符串参数的过滤 2022-05-27 12:06:27 +08:00
0ced5d2eaa update 优化 oss 回显查询 使用 redis 缓存 2022-05-27 09:58:34 +08:00
ab8111bdeb fix 修复 登录未选部门报空问题 2022-05-27 09:32:18 +08:00
8dc23ea1ce update 修改PR规范 2022-05-27 09:29:37 +08:00
8a2e3d13f2 表单构建按钮不显示正则校验 2022-05-27 09:18:26 +08:00
a29a0648ad 升级spring-boot到最新版本2.5.14 2022-05-27 08:37:34 +08:00
63d471ec94 修复字典导出序列化报错问题 2022-05-27 08:37:14 +08:00
9fa3eac3aa 升级fastjson到最新版2.0.4 2022-05-26 09:02:32 +08:00
a3ba78d7bd fix 修复脱敏实现逻辑问题 2022-05-25 10:37:33 +08:00
4b07be6bfd update redisson 3.17.0 => 3.17.2 2022-05-25 09:45:09 +08:00
e320c50e49 !492 fastjson 版本升级
Merge pull request !492 from abbfun/N/A
2022-05-24 01:54:24 +00:00
524ad4e6dd fastjson 版本升级
fastjson <= 1.2.80 存在反序列化任意代码执行漏洞
2022-05-23 07:36:18 +00:00
e515d6f776 update 手动配置 Undertow 缓冲池 消除运行警告 2022-05-23 13:47:19 +08:00
c137965dec update 增加 redis 无密码使用说明 2022-05-23 11:23:14 +08:00
a9e68e13a8 update 优化 getLoginUser 获取 使用一级缓存 2022-05-23 10:56:41 +08:00
77fffda10e 添加新群号:139821253 2022-05-23 09:38:52 +08:00
88fe5c641f update 优化 redis 与 jackson 使用自动装配定制器简化配置 2022-05-23 02:06:38 +08:00
da0309eb09 用户头像上传限制只能为图片格式 2022-05-22 18:21:26 +08:00
4e6f47d50a update springboot 2.6.7 => 2.6.8 2022-05-22 14:13:53 +08:00
7e626ea219 update xxl-job 2.3.0 => 2.3.1 2022-05-22 13:07:36 +08:00
8a6ccabffb update easyexcel 3.0.5 => 3.1.0 去除cglib 支持jdk17
update hutool 5.8.0 => 5.8.1
2022-05-22 12:50:43 +08:00
f546ba85aa update 优化 DataPermissionHelper 上下文存储 使用 SaToken 的请求存储器 2022-05-22 12:39:01 +08:00
73e1d3b046 !180 把SysRoleController的remove的@Param岗位id串改成了角色id串
Merge pull request !180 from water/dev
2022-05-20 09:15:11 +00:00
b2c8062131 style 修改一个错误的参数注释
public R<Void> remove(@ApiParam("岗位ID串") @PathVariable Long[] roleIds) {
        return toAjax(roleService.deleteRoleByIds(roleIds));
    }

    public R<Void> remove(@ApiParam("角色ID串") @PathVariable Long[] roleIds) {
        return toAjax(roleService.deleteRoleByIds(roleIds));
    }


这个service上的注释是这样的
    /**
     * 批量删除角色信息
     *
     * @param roleIds 需要删除的角色ID
     * @return 结果
     */
    int deleteRoleByIds(Long[] roleIds);
2022-05-20 09:09:28 +00:00
6805a96e53 接口使用泛型使其看到响应属性字段 2022-05-20 16:25:51 +08:00
a92667c000 新增获取配置文件中的属性值方法 2022-05-20 16:23:52 +08:00
4a0619cadb 优化switch case条件 2022-05-20 16:23:36 +08:00
a7e16d582d !488 修复操作日志列表查询业务类型时的bug
Merge pull request !488 from 也曾为你、像超人/N/A
2022-05-20 07:56:27 +00:00
b3a4da5e4d fix 修复 postgres 数据库 菜单部分字段类型无法转换问题 2022-05-19 21:54:23 +08:00
5ea298a238 reset 重置错误修改 2022-05-19 21:48:21 +08:00
859c0915fb fix 修复 菜单部分字段 类型与数据库不匹配问题 2022-05-19 21:27:58 +08:00
45fd96cd0d fix 修复 编辑 OssConfig 在 postgres 字段重复报错 补全 remark 字段 2022-05-18 10:05:36 +08:00
ffe2b3c24d fix 修复 S3 协议 minio 使用 localhost 问题 采用 127.0.0.1 代替 2022-05-18 01:50:26 +08:00
b5b8d941f3 update ruoyi-system/src/main/resources/mapper/system/SysOperLogMapper.xml.
问题:查业务类型为其他(businessType = 0)的数据时,会查到所有数据

原因:当参数为 Integer 类型 0 时,MyBatis 会把 0 当做空字符串处理
2022-05-17 02:08:37 +00:00
970561b956 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/SysDept.java
	ruoyi-common/src/main/java/com/ruoyi/common/utils/poi/ExcelUtil.java
	ruoyi-system/src/main/resources/mapper/system/SysDeptMapper.xml
	ruoyi-system/src/main/resources/mapper/system/SysMenuMapper.xml
	ruoyi-ui/src/assets/styles/element-variables.scss
	ruoyi-ui/src/views/monitor/server/index.vue
	ruoyi-ui/src/views/system/dict/data.vue
	ruoyi-ui/src/views/system/user/index.vue
2022-05-16 09:38:03 +08:00
9c3b53b701 用户管理左侧树型组件增加选中高亮保持 2022-05-13 15:02:16 +08:00
6a69be88c5 update 调整 图片预览组件 去除无用根目录拼接 2022-05-13 09:41:54 +08:00
3a918ae8f6 update 调整 CacheManager 使用系统 系统序列化器 2022-05-13 09:37:44 +08:00
f668089e64 fix 修复 TestDemo 的 bo 和 vo 与 entity 属性类型不匹配问题 2022-05-13 00:24:49 +08:00
af6a08398e update 优化 文件与图片上传组件 使用id存储回显 2022-05-12 10:55:44 +08:00
4d7def4311 fix 修复 腾讯云短信 依赖缺失问题 2022-05-12 09:54:24 +08:00
ae960f5220 update 更新 短信演示案例 增加依赖判断与使用说明 2022-05-12 09:54:24 +08:00
5be9ce1823 fix 修复 token 超时时间设置 -1 导致的单位转换问题 2022-05-11 23:47:05 +08:00
5693bbe1f5 升级oshi到最新版本6.1.6 2022-05-11 09:58:25 +08:00
e4267c5c56 update 优化 弹窗点击遮罩层 默认不关闭 可在 main.js 修改 2022-05-10 23:45:33 +08:00
99dfd42372 update 优化 上传组件 部分用户存储url串 导致无法回显问题 2022-05-10 23:35:54 +08:00
8d36924cb6 fix 修复 sqlserver 新增数据 id 错误 2022-05-10 16:15:12 +08:00
80d1e28d0f update springboot-admin 2.6.6 => 2.6.7
update springboot-mybatis 2.2.0 => 2.2.2
update sa-token 1.29.0 => 1.30.0
update hutool 5.7.22 => 5.8.0
update druid 1.2.8 => 1.2.9
update tlog 1.3.6 => 1.4.0
2022-05-10 14:42:02 +08:00
60132e9947 fix 修复 update-sql 追加字段因顺序问题导致插入失败 2022-05-10 10:24:25 +08:00
940b996e2d !175 [重大改动] 基于S3协议重新实现 OSS模块 支持自定义域名
* [重大改动] 基于S3协议重新实现 OSS模块 支持自定义域名
2022-05-10 01:40:40 +00:00
0055f479cb 修复字典数据显示不全问题(I55MR3) 2022-05-09 20:27:09 +08:00
1c41b701dd 优化excel创建表格样式 2022-05-09 17:37:33 +08:00
e1e26d53e6 !174 fix 修复 短信验证码校验逻辑错误
Merge pull request !174 from SPPan/dev
2022-05-07 07:21:50 +00:00
f9131832c7 短信验证码校验逻辑BUG修复 2022-05-07 15:17:08 +08:00
ce14b5e9fb fix 修复 关闭短信功能 找不到bean异常问题 2022-05-07 15:10:58 +08:00
c40aa1f950 update 完善短信验证码发送接口 2022-05-07 11:24:42 +08:00
7d1d3d3f05 update 完善短信验证码发送接口 2022-05-07 11:18:14 +08:00
5e6a895fef update 更新 readme 短信模块说明 与 文档地址 2022-05-07 10:30:46 +08:00
d2fe2a7fc5 fix 修复 腾讯短信 与 minio okhttp依赖冲突问题 2022-05-07 09:39:11 +08:00
44a8025e0f update 更正 短信演示案例 方法命名 2022-05-06 18:15:31 +08:00
71e392c1f9 add 增加 获取短信验证码接口 2022-05-06 18:08:16 +08:00
416088a2de add 增加 demo 短信演示案例 2022-05-06 18:07:43 +08:00
e57d11d55a add 增加 ruoyi-sms 短信模块 整合 阿里云、腾讯云 短信功能 2022-05-06 18:07:00 +08:00
781ae8d5c8 update 修改邮件开关类型 2022-05-06 17:19:35 +08:00
b01d45cf5c add 增加 RedisUtils 操作原子值方法 2022-05-05 15:07:23 +08:00
4941aaa5c1 update 重构 pr_172 集成邮件发送功能 2022-05-02 23:12:16 +08:00
07559a5aaa !172 邮件发送功能
Merge pull request !172 from MichelleChung/dev
2022-05-02 15:11:25 +00:00
92f030887b [add]:
1. (common) pom.xml - 增加邮件依赖 ;
2. (admin) application-dev.yml - 增加邮件配置 ;
3. (framework) MailProperties, MailConfig - 增加邮件属性配置 ;
4. (common) MailUtils - 重写 Hutool MailUtil方法 ;
5. (demo) MailController - 邮件发送测试方法 ;
2022-05-02 21:21:14 +08:00
9476f7f616 升级spring-boot到最新版本2.5.13 2022-05-01 20:22:35 +08:00
cbe405f6ea ui code format 2022-05-01 20:22:25 +08:00
e18cf51c01 update 优化 RedisUtils 重构过期方法 2022-04-30 22:21:49 +08:00
f32813951f update 优化 redis 序列化 使用系统自带json工具 全局统一 2022-04-29 11:35:51 +08:00
7ba8fc256b fix 修复 查询未分配用户角色列表 角色无绑定用户情况下 空列表问题 2022-04-28 10:16:13 +08:00
c7972aa5e6 fix 修复 全局线程池配置 核心线程与最大线程 参数填反问题 2022-04-25 15:25:43 +08:00
eaef38f79c fix 修复 ExcelUtil 表达式解析 参数添反导致无法解析问题 2022-04-25 15:24:10 +08:00
7414bc492e 修改代码生成树选择组件 2022-04-25 10:27:06 +08:00
6f14087a16 修改显示顺序orderNum类型为整型 2022-04-25 10:23:47 +08:00
0700c60636 Merge remote-tracking branch 'origin/dev' into 4.X 2022-04-24 13:32:10 +08:00
aac6e0521a 发布 4.1.0 2022-04-24 13:28:52 +08:00
7e25a80c5b Merge branch 'master' of https://gitee.com/y_project/RuoYi-Vue into dev
 Conflicts:
	ruoyi-common/src/main/java/com/ruoyi/common/annotation/Excel.java
	ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/SysDictType.java
	ruoyi-common/src/main/java/com/ruoyi/common/core/page/TableSupport.java
	ruoyi-common/src/main/java/com/ruoyi/common/utils/PageUtils.java
	ruoyi-common/src/main/java/com/ruoyi/common/utils/file/FileUtils.java
	ruoyi-common/src/main/java/com/ruoyi/common/utils/poi/ExcelUtil.java
	ruoyi-quartz/src/main/java/com/ruoyi/quartz/util/ScheduleUtils.java
	ruoyi-ui/package.json
2022-04-24 11:46:25 +08:00
328d4b916d Excel注解支持color字体颜色 2022-04-23 20:53:16 +08:00
596ff28207 update springboot 2.6.6 => 2.6.7 2022-04-22 13:39:49 +08:00
70c1a37bbd update 删除一些基本用不上的配置 简化折叠一些配置 2022-04-22 12:16:03 +08:00
4902276921 update 移除 重复提交 配置文件全局配置 使用注解默认值替代 2022-04-22 12:07:32 +08:00
83cdeacaa8 update 简化 全局线程池配置 使用cpu核心数自动处理 2022-04-22 12:06:56 +08:00
e6e2f48f7e update 更新 readme 技术栈介绍 2022-04-21 10:40:37 +08:00
e316f613d0 update 首页 更新日志 指向官网 2022-04-21 10:26:18 +08:00
9a8c87a43e update .gitee/ISSUE_TEMPLATE.zh-CN.md. 2022-04-20 16:14:13 +00:00
67140f996b fix 修复 BeanCopyUtils 工具导包错误 2022-04-20 10:41:27 +08:00
2f5d9ced6d update 更新多数据库说明 2022-04-19 15:07:02 +08:00
3dfb116fdd update 优化文件上传、图片上传组件 文件列表展示文件原名便于后续处理, 完善组件删除功能 2022-04-18 19:55:23 +08:00
eb1047a149 update 优化登录失败相关部分代码结构 2022-04-17 21:51:41 +08:00
b42a8176ca 设置分页参数默认值 2022-04-17 10:29:12 +08:00
2a9beec31d 检查定时任务bean所在包名是否为白名单配置 2022-04-16 22:06:25 +08:00
910fe6261b 新增获取不带后缀文件名称方法 2022-04-16 22:06:15 +08:00
0c820b96d8 !471 新增一个取文件名而不带后缀的整合方法,干净又卫生啊兄弟们
Merge pull request !471 from XCSDN/N/A
2022-04-16 13:53:10 +00:00
9689efedc4 fix 修复 tlog 依赖漏洞 2022-04-16 15:01:27 +08:00
97561f428e fix 修复 guava 漏洞 统一依赖版本 2022-04-16 15:01:11 +08:00
df0497fb58 fix 修复 cos_api bcprov-jdk15on 漏洞 2022-04-16 15:00:38 +08:00
30f0bdc754 update 使用 spring cglib 替换 停止维护的 cglib 2022-04-16 14:08:11 +08:00
c3c49a05c2 新增一个取文件名而不带后缀的整合方法,干净又卫生啊兄弟们 2022-04-16 06:02:07 +00:00
e72b878380 fix 修复 使用雪花id 导致 部门祖籍字段 长度不够问题 2022-04-15 11:52:44 +08:00
d51d8ad877 fix 修复 OssConfig 主键类型错误 2022-04-15 11:42:52 +08:00
68a616d7c7 升级element-ui到最新版本2.15.8 2022-04-15 09:32:21 +08:00
a0447de061 字典类型必须以字母开头,且只能为(小写字母,数字,下滑线) 2022-04-15 09:31:51 +08:00
46db06a22b !465 update ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/SysDictType.java.
Merge pull request !465 from XCSDN/N/A
2022-04-15 01:17:21 +00:00
7984fdfd20 update 演示树表 增加 展开/折叠 功能 2022-04-11 12:09:42 +08:00
d637f03067 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/resources/application.yml
	ruoyi-common/pom.xml
	ruoyi-common/src/main/java/com/ruoyi/common/core/controller/BaseController.java
	ruoyi-common/src/main/java/com/ruoyi/common/core/redis/RedisCache.java
	ruoyi-common/src/main/java/com/ruoyi/common/utils/PageUtils.java
	ruoyi-common/src/main/java/com/ruoyi/common/utils/ip/IpUtils.java
	ruoyi-common/src/main/java/com/ruoyi/common/utils/poi/ExcelUtil.java
	ruoyi-framework/pom.xml
	ruoyi-framework/src/main/java/com/ruoyi/framework/aspectj/LogAspect.java
	ruoyi-generator/pom.xml
	ruoyi-generator/src/main/java/com/ruoyi/generator/controller/GenController.java
	ruoyi-generator/src/main/resources/vm/vue/index-tree.vue.vm
	ruoyi-job/pom.xml
	ruoyi-system/pom.xml
	ruoyi-system/src/main/resources/mapper/system/SysUserMapper.xml
	ruoyi-ui/README.md
	ruoyi-ui/bin/package.bat
	ruoyi-ui/package.json
	ruoyi-ui/src/views/index.vue
2022-04-11 11:58:44 +08:00
4c57c2a044 update springboot-admin 2.6.5 => 2.6.6
update qiniu 7.9.3 => 7.9.5
update qcloud 5.6.68 => 5.6.72
update minio 8.3.7 => 8.3.8
update okhttp 4.9.2 => 4.9.3
2022-04-11 11:50:16 +08:00
94b09c3fc0 fix 修复 minio 上传, 因 socket 导致 available 获取数值不精确问题 2022-04-08 19:43:07 +08:00
de5ae4a05e 添加页签openPage支持传递参数 2022-04-08 15:42:10 +08:00
517c5705b6 add 增加 Mybatis 全局异常处理 开启多数据源切换 严格模式 找不到数据源报错 2022-04-08 11:39:40 +08:00
5d3e977761 update springboot-admin 2.6.3 => 2.6.5
update dynamic-datasource 3.5.0 => 3.5.1
update redisson 3.16.8 => 3.17.0
2022-04-08 10:50:13 +08:00
c0d430f4e5 update ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/SysDictType.java.
字典类型必须以字母开头,且字典类型只能由小写字母或加下划线还有数字组成
防止由于字典类型不符合前端开发规范而报错
2022-04-07 04:57:56 +00:00
d910888181 代码生成树表新增(展开/折叠) 2022-04-07 10:56:40 +08:00
db2dfee6ae 用户缓存信息添加部门ancestors祖级列表 2022-04-07 09:50:42 +08:00
d311d56bbf 修复Excel注解prompt/combo同时使用不生效问题 2022-04-03 18:28:30 +08:00
a33898c2a0 !167 update 修改角色"菜单树选择项"和"部门树选择项"是否关联显示字段为Boolean类型
* fix 修改 postgres sql脚本,处理角色表字段类型错误问题。
* fix 修复postgreSQL新增或更新角色信息报错。修改角色"菜单树选择项"和"部门树选择项"是否关联显示字段为Boolean类型。
2022-04-02 05:02:56 +00:00
e6940d48e3 update 更名 SaInterfaceImpl 为 SaPermissionImpl 完善相关注释 2022-04-02 11:54:44 +08:00
3bc5ef38d3 升级spring-boot到最新版本2.5.12 防止RCE漏洞 2022-04-02 10:16:09 +08:00
bac3b3a0dc 降级jsencrypt版本兼容IE浏览器 2022-04-02 10:15:25 +08:00
07fded4da9 update readme 2022-04-02 10:13:58 +08:00
4f0a584efc update springboot 2.6.5 => 2.6.6 修复 CVE-2022-22965 漏洞 2022-04-01 17:57:00 +08:00
1139fb39c5 update bat 脚本转换为 utf-8 编码 防止上传乱码 需要者自行修改编码 2022-04-01 17:17:39 +08:00
4cd7c07344 update 优化 sa-token 路由拦截器语法 增加注释 避免误操作 2022-04-01 15:43:51 +08:00
a854e0ca8e 若依 3.8.2 2022-04-01 08:30:48 +08:00
de1766abde 新增清理分页的线程变量方法 2022-03-31 11:48:27 +08:00
ebd005e1b1 update 优化 DateUtils 代码格式 2022-03-30 23:22:31 +08:00
9ba61037a4 update 优化代码与注释 2022-03-30 23:04:51 +08:00
c74b878372 fix 修复设置角色报错问题 2022-03-30 11:41:56 +08:00
01a566c794 升级spring-boot到最新版本2.5.11 2022-03-30 10:40:07 +08:00
5362a633e6 升级fastjson到最新版1.2.80 2022-03-30 10:39:47 +08:00
b2c3f45141 update registry source 2022-03-30 10:39:09 +08:00
d5f9b5b74a topNav自定义隐藏侧边栏路由 2022-03-30 10:38:51 +08:00
95a2c74462 fix 修复 数据权限 从 aop 切换到 拦截器 导致获取代理失败问题 2022-03-28 21:01:22 +08:00
d217ef37bf update springboot 2.6.4 => 2.6.5
update springboot-admin 2.6.2 => 2.6.3
update hutool 5.7.21 => 5.7.22
2022-03-28 14:26:01 +08:00
95bea7f64a update 优化 pr 165 2022-03-28 14:05:16 +08:00
58b63a24c2 !165 在全局异常处理器中引入DuplicateKeyException的主键冲突异常,来处理解决主键或UNIQUE索引的数据重复异常。
Merge pull request !165 from xlt/dev
2022-03-28 06:01:00 +00:00
xlt
53c90cfc99 update 在全局异常处理器中引入DuplicateKeyException的主键冲突异常,来处理解决主键或UNIQUE索引的数据重复异常。 2022-03-27 21:57:44 +08:00
2043d1f439 优化IP地址获取到多个的问题 2022-03-27 14:36:48 +08:00
61034d4dde 优化导出excel单元格验证,包含变更为开头.防止正常内容被替换 2022-03-27 14:36:31 +08:00
6605bf35a8 reset pr 452 2022-03-26 17:28:58 +08:00
b2b93e5060 !457 修改RedisCache方法形参命名
Merge pull request !457 from lu_ming/master
2022-03-26 09:25:05 +00:00
098286fcaf 修改RedisCache方法形参命名 2022-03-25 18:50:51 +08:00
a6f30412ad update 修改角色适配 采用 get set 转换数据类型 2022-03-25 15:22:01 +08:00
b624648115 fix 修复增加应用路径路由不生效问题 2022-03-25 15:21:27 +08:00
9d1d74c022 Merge branch 'master' of https://gitee.com/y_project/RuoYi-Vue into dev
 Conflicts:
	README.md
	ruoyi-common/src/main/java/com/ruoyi/common/utils/poi/ExcelUtil.java
	ruoyi-generator/src/main/java/com/ruoyi/generator/controller/GenController.java
	ruoyi-ui/src/layout/components/Sidebar/Item.vue
	ruoyi-ui/src/layout/index.vue
	ruoyi-ui/src/store/modules/app.js
	ruoyi-ui/src/store/modules/user.js
	ruoyi-ui/src/views/index.vue
2022-03-25 11:17:51 +08:00
0c79d1a619 fix 修正 用户行为监听 日志编写错误问题 2022-03-25 11:13:36 +08:00
1ea8eebfec update 更新小程序登录 单独的结构体 2022-03-24 10:28:42 +08:00
1dcc03aae0 update 放行 短信登录 与 小程序登录 接口 2022-03-24 10:21:07 +08:00
3be9535225 fix 修复单独访问 接口文档 请求 favicon.ico 报错问题 2022-03-24 10:20:42 +08:00
8cad83a9dc fix 修复 用户绑定角色 与 角色绑定用户 异常 编写错误 2022-03-23 22:18:56 +08:00
0488495a34 !164 fix 修复swagger描述错误
Merge pull request !164 from Yjoioooo/auto-5403234-dev-1648027721128
2022-03-23 09:36:59 +00:00
a5eb8ce21e fix 修复swagger描述错误 2022-03-23 17:28:11 +08:00
1dbcd4ee6e update 代码生成 支持界面动态配置切换数据源(找不到默认查 primary 数据源) 2022-03-23 15:14:16 +08:00
7e1f024d28 update 适配 sqlserver 代码生成 解决一下小问题 2022-03-23 15:02:38 +08:00
4a353896e3 add 增加 短信登录 与 小程序登录 示例 2022-03-23 00:33:28 +08:00
eaa12de740 添加新群号:167385320 2022-03-22 16:47:56 +08:00
0e4372b4a3 update 优化 logback 日志 异步输出 2022-03-21 13:01:36 +08:00
b0c31ae486 add 增加 sqlserver 测试 sql 2022-03-21 10:44:18 +08:00
a43e4b8aa7 add 增加 postgres 测试 sql 2022-03-21 10:44:17 +08:00
ce3f80144a update 优化 DataBaseHelper 工具 2022-03-21 10:43:05 +08:00
cd33cd66ae !158 修复demo模块字段类型错误问题
Merge pull request !158 from KonBAI/demo_field_type
2022-03-18 12:53:26 +00:00
f2a2c2d407 fix 修复demo模块字段类型错误问题。 2022-03-18 20:38:17 +08:00
5f0481c067 !157 修复执行"查询当前数据库类型"后未关闭数据库链接,导致当前连接池中活跃连接数达到最大连接数的bug
Merge pull request !157 from KonBAI/close_dataSource_conn
2022-03-17 17:53:38 +00:00
f30f3ac37b fix 修复执行"查询当前数据库类型"后未关闭数据库链接,导致当前连接池中活跃连接数达到最大连接数的bug 2022-03-18 01:37:04 +08:00
d31ed1f2e1 update 修正错误提交 2022-03-17 19:53:42 +08:00
cf67d606ae update 初步适配 postgres (代码生成两次导入有问题) 2022-03-17 19:52:40 +08:00
76b859f6ba update 调整菜单排序字段与数据库类型对应 2022-03-17 12:42:49 +08:00
a326e301f0 update 调整菜单排序字段与数据库类型对应 2022-03-17 12:40:20 +08:00
a16ae7dadc !156 修复角色、岗位、字典数据在PostgreSQL执行插入或者更新SQL报错问题,修改对应实体类的排序属性为Integer类型。
Merge pull request !156 from KonBAI/sort_type
2022-03-17 04:32:51 +00:00
ac47375aba fix 修复角色、岗位、字典数据在PostgreSQL执行插入或者更新SQL报错问题,修改对应实体类的排序属性为Integer类型。 2022-03-17 11:45:42 +08:00
857054179c 优化固定Header后顶部导航栏样式问题(I4XDN5) 2022-03-17 09:42:39 +08:00
fd5a87eedf !155 修复根据用户ID查询菜单信息SQL报错
Merge pull request !155 from KonBAI/selectMenuPerms_sql
2022-03-16 09:10:04 +00:00
4770b0d3e3 fix 修复根据用户ID查询菜单信息SQL报错。status字段为char类型,应该传字符类型,此处存在隐式转换问题。(MySQL能自动转换,PostgreSQL转换报错)。 2022-03-16 16:53:17 +08:00
181ec4633b update 调整数据库驱动依赖至输出模块 2022-03-16 14:09:39 +08:00
dc5e5c6c08 add 增加 postgres sqlserver jdbc连接适配 2022-03-16 14:07:46 +08:00
dcdf423d66 update 更新 sqlserver sql脚本 处理遇到的问题 2022-03-16 14:06:00 +08:00
1a19c3b3a5 update 单独指定oracle心跳检查 2022-03-16 14:05:29 +08:00
0a3fcfd9f4 !453 update ruoyi-ui/src/store/modules/user.js.
Merge pull request !453 from guxin0123/N/A
2022-03-16 05:19:33 +00:00
49ac180329 update 优化 SysRole 部分字段类型 防止数据库类型映射异常 2022-03-16 12:59:04 +08:00
0271aa5414 update ruoyi-ui/src/store/modules/user.js.
修复数据库用户表 头像列为 null 时不显示默认头像问题
2022-03-16 04:52:33 +00:00
880b3290e8 fix 修复代码生成导入表报错 2022-03-15 23:22:42 +08:00
a0364f0758 优化菜单名称过长悬停显示标题 2022-03-15 14:24:52 +08:00
ed693e89c9 !452 跨域问题
Merge pull request !452 from younger007/master
2022-03-15 06:23:38 +00:00
526957e0ac !447 优化:解决导出数据时,LocalDateTime类型数据导出没数据问题
Merge pull request !447 from 黄严/dev
2022-03-15 06:23:24 +00:00
3341eb5f2c update 优化 TreeEntity 树实体 去除未知泛型 2022-03-15 13:18:24 +08:00
51fba42b83 update 修复oracle因编码问题导致插入日志报错 2022-03-15 12:51:34 +08:00
12f5327e0e add 增加 oracle postgres sqlserver 模板sql 2022-03-15 11:58:53 +08:00
40f9fac1a5 update 代码生成sql模板适配雪花id 2022-03-15 11:58:26 +08:00
0b5e924a21 update 代码生成适配雪花id 2022-03-15 11:58:07 +08:00
cd312f1348 Merge branch 'master' of https://gitee.com/y_project/RuoYi-Vue into dev
 Conflicts:
	ruoyi-common/src/main/java/com/ruoyi/common/utils/file/FileUploadUtils.java
	ruoyi-common/src/main/java/com/ruoyi/common/utils/poi/ExcelUtil.java
	ruoyi-generator/src/main/java/com/ruoyi/generator/controller/GenController.java
	ruoyi-generator/src/main/resources/vm/vue/index-tree.vue.vm
	ruoyi-generator/src/main/resources/vm/vue/index.vue.vm
	ruoyi-ui/src/assets/styles/sidebar.scss
	ruoyi-ui/src/layout/components/Settings/index.vue
	ruoyi-ui/src/layout/index.vue
	ruoyi-ui/src/store/modules/app.js
	ruoyi-ui/src/store/modules/permission.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/online/index.vue
	ruoyi-ui/src/views/system/dict/data.vue
	ruoyi-ui/src/views/system/dict/index.vue
	ruoyi-ui/src/views/system/role/index.vue
	ruoyi-ui/src/views/system/user/index.vue
	ruoyi-ui/src/views/tool/gen/importTable.vue
2022-03-15 10:20:53 +08:00
e480f616e0 update 使用 in 优化 or 提升索引命中率 2022-03-14 15:58:27 +08:00
2285a94958 update 更新首页关于 权限认证框架 框架说明 改为 Sa-Token 2022-03-14 14:06:43 +08:00
7f1356a447 update 重构代码生成 多数据库sql加载 使用xml特性动态切换sql 2022-03-14 14:05:37 +08:00
420a43cdd5 update ruoyi-generator/src/main/java/com/ruoyi/generator/controller/GenController.java.
和文件下载那边一样,存在跨域问题
2022-03-14 02:52:29 +00:00
1aab88859d update 重命名 oracle postgres sqlserver 菜单字段 query -> query_param 2022-03-11 19:02:46 +08:00
3210fce113 update 删除 自定义 find_in_set 函数 在代码层面适配 2022-03-11 18:55:04 +08:00
0a1b026d92 update 格式化 postgres sql格式 增加 find_in_set 函数 2022-03-11 17:36:51 +08:00
29e1bf3f2e add 增加 4.0 升级 4.1 的 sql 脚本 2022-03-11 13:29:21 +08:00
333a38978e update 重命名 菜单字段 query -> query_param 解决系统关键字问题 2022-03-11 13:29:04 +08:00
91c7b46d52 add 增加 postgresql 主sql脚本 2022-03-11 13:00:53 +08:00
870d51bf10 add 增加 postgresql docker 镜像 2022-03-11 13:00:40 +08:00
7c0f41c785 update 确保更好的适配 多数据库 主键策略统一改为 雪花ID 2022-03-11 13:00:09 +08:00
647d3391bb add 增加 SQL Server 主数据库脚本 2022-03-10 19:53:58 +08:00
0d24f34d83 add 增加 SQL Server docker 编排 2022-03-10 19:48:05 +08:00
a68a32d9b6 add 增加 DataBaseHelper 数据库助手 用于屏蔽多类型数据库sql语句差异 2022-03-10 19:47:31 +08:00
8a89054c2f add 增加 oracle_test.sql 测试sql文件 2022-03-09 16:21:53 +08:00
cd46d08afd fix 修复关于 oracle utf8 编码导致内容字符长度溢出 2022-03-09 15:46:28 +08:00
5e8ccda522 日期转换错误,issue地址:https://gitee.com/y_project/RuoYi-Vue/issues/I4X0U7 2022-03-09 14:39:19 +08:00
78d0e67987 update 处理 find_in_set 函数多类型数据库兼容性问题 2022-03-09 12:11:34 +08:00
62fc38078c 修复遗漏的拼写错误 2022-03-09 10:05:39 +08:00
bc4f844cd8 !445 文件上传兼容Weblogic环境
Merge pull request !445 from yaoozu/master
2022-03-09 02:03:50 +00:00
d73cd5ed27 update 去除 oracle 多余连接参数 天生支持批处理 2022-03-08 17:47:51 +08:00
2bf3d3a9c5 update 更新minio压缩配置 2022-03-08 13:22:11 +08:00
e3b64387a5 fix 修复 oracle sql 函数分隔符书写错误问题 2022-03-07 18:02:40 +08:00
bd0454309f update 去除掉 不推荐使用的配置 2022-03-07 13:14:59 +08:00
a72fa8038f fix 修复oracle时间查询相关问题 2022-03-07 13:05:14 +08:00
f15f8e3295 文件上传兼容Weblogic环境 2022-03-07 10:44:01 +08:00
604c671d41 update 临时处理 关于数据源的切换(后续在页面做个输入框 有兴趣的可以pr) 2022-03-06 11:22:27 +08:00
6130bebbb3 开启TopNav没有子菜单情况隐藏侧边栏 2022-03-06 09:03:44 +08:00
9f944c043f !444 修改提示
Merge pull request !444 from SG/N/A
2022-03-05 14:11:22 +00:00
092b3214c5 !443 修复代码错误,其他文件也修改下
Merge pull request !443 from SG/N/A
2022-03-05 14:11:17 +00:00
SG
07dfef48be 修改提示 2022-03-05 12:28:44 +00:00
e9571fc2e2 fix 2022-03-05 05:06:39 +00:00
db3a83d163 !150 fix 修复talbleId的单词拼写错误,应为tableId
Merge pull request !150 from xlt/dev
2022-03-05 05:05:39 +00:00
22f7ccc11d 修复导入Excel时字典字段类型为Long转义为空问题 2022-03-05 08:39:52 +08:00
xlt
ea53b3faba fix 修复talbleId的单词拼写错误,应为tableId 2022-03-05 01:27:02 +08:00
645ccb2f87 update 统一控制依赖版本 2022-03-05 00:39:31 +08:00
b40cc02e2a fix 修复Oracle代码生成器空值更新报错问题 2022-03-05 00:20:43 +08:00
98418272ab !148 fix 修复Oracle代码生成器空值更新报错问题
Merge pull request !148 from Yjoioooo/auto-5403234-dev-1646410371975
2022-03-04 16:18:15 +00:00
a32cc879cc fix 修复代码生成器空值更新报错问题 2022-03-05 00:12:50 +08:00
adf329cf1a fix 修复 poi 组件漏洞 与 mysql jdbc 漏洞 2022-03-05 00:12:25 +08:00
SG
4bd5009ec1 修复代码错误,其他文件也修改下 2022-03-04 14:38:57 +00:00
74a9b4c058 update 配置增加oracle jdbc链接串 2022-03-04 21:14:36 +08:00
8ee749f137 update 初步适配oracle(未完成) 2022-03-04 21:09:46 +08:00
46fa404d83 update 增加 mysql 字段格式化处理 防止关键字问题 2022-03-04 20:32:12 +08:00
cb8f5de5af 修复表单清除元素位置未垂直居中问题(I4V27B) 2022-03-04 19:24:28 +08:00
3c7c5380f4 update 去除多余注解参数 统一使用全局配置 2022-03-04 19:05:37 +08:00
04d611e1c2 update 放行 actuator 路径 2022-03-04 14:34:39 +08:00
2d813b2191 update 删除多余 参数类型 2022-03-04 13:42:08 +08:00
f1bf549e0f update 简化查询代码生成列表功能 2022-03-04 13:12:20 +08:00
d3a3ad5cbd update 简化查询用户功能 2022-03-04 11:45:38 +08:00
8091a46005 update 简化查询菜单功能 2022-03-04 10:48:12 +08:00
18cffc4678 update 简化查询角色功能 2022-03-04 10:20:06 +08:00
c1d01fb1e1 update 优化 部门修改子元素关系 使用批量更新 2022-03-04 09:26:26 +08:00
4d0c84bcf5 remove 删除多余引号 2022-03-03 23:58:09 +08:00
8db5c27d81 update 删除无用前缀 2022-03-03 23:18:20 +08:00
2ff36d81a1 update 优化 防重 与 限流 功能支持国际化消息返回 2022-03-03 22:55:49 +08:00
56feff0455 update 优化 RepeatSubmit 注解 支持业务处理失败 与 异常快速放行 2022-03-03 22:05:31 +08:00
cf17bcb15c fix 修复 数据权限 从 aop 切换到 拦截器 导致获取代理失败问题 2022-03-03 14:34:13 +08:00
b2d3abd9d6 update 优化去除sql差异化 时间范围统一使用 between 处理 2022-03-03 11:18:10 +08:00
a54cb7d3e4 update 简化查询菜单功能 2022-03-03 11:18:10 +08:00
00549c267f update 简化查询部门功能 2022-03-03 11:18:10 +08:00
f41bfdb8eb update 更新数据权限Service的使用说明 2022-03-03 01:55:01 +08:00
276 changed files with 10177 additions and 3800 deletions

View File

@ -1,4 +1,4 @@
### 使用版本
### 使用版本(未按照模板填写直接删除)
### 问题描述

View File

@ -1,4 +1,4 @@
### 更改目的 解决了什么问题
### 更改目的 解决了什么问题(请提交到dev分支)
### 描述 做了哪些改动

View File

@ -4,8 +4,8 @@
[![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-4.0.1-success.svg)](https://gitee.com/JavaLionLi/RuoYi-Vue-Plus)
[![Spring Boot](https://img.shields.io/badge/Spring%20Boot-2.5-blue.svg)]()
[![RuoYi-Vue-Plus](https://img.shields.io/badge/RuoYi_Vue_Plus-4.2.0_beta1-success.svg)](https://gitee.com/JavaLionLi/RuoYi-Vue-Plus)
[![Spring Boot](https://img.shields.io/badge/Spring%20Boot-2.6-blue.svg)]()
[![JDK-8+](https://img.shields.io/badge/JDK-8-green.svg)]()
[![JDK-11](https://img.shields.io/badge/JDK-11-green.svg)]()
@ -25,6 +25,9 @@
| 容器框架 | Undertow | [Undertow官网](https://undertow.io/) | 基于 XNIO 的高性能容器 |
| 权限认证框架 | Sa-Token、Jwt | [Sa-Token官网](https://sa-token.dev33.cn/) | 强解耦、强扩展 |
| 关系数据库 | MySQL | [MySQL官网](https://dev.mysql.com/) | 适配 8.X 最低 5.7 |
| 关系数据库 | Oracle | [Oracle官网](https://www.oracle.com/cn/database/) | 适配 11g 12c |
| 关系数据库 | PostgreSQL | [PostgreSQL官网](https://www.postgresql.org/) | 适配 13 14 |
| 关系数据库 | SQLServer | [SQLServer官网](https://docs.microsoft.com/zh-cn/sql/sql-server) | 适配 2017 2019 |
| 缓存数据库 | 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 分析 |
@ -39,6 +42,7 @@
| 分布式任务调度 | 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) | 云存储 |
| 短信模块 | 阿里、腾讯 | [短信使用文档](https://gitee.com/JavaLionLi/RuoYi-Vue-Plus/wikis/pages?sort_id=5578491&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/) | 增强接口安全性、严谨性 支持国际化 |
| Excel框架 | Alibaba EasyExcel | [EasyExcel文档](https://www.yuque.com/easyexcel/doc/easyexcel) | 性能优异 扩展性强 |

115
pom.xml
View File

@ -6,46 +6,46 @@
<groupId>com.ruoyi</groupId>
<artifactId>ruoyi-vue-plus</artifactId>
<version>4.0.1</version>
<version>4.2.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>4.0.1</ruoyi-vue-plus.version>
<spring-boot.version>2.6.4</spring-boot.version>
<ruoyi-vue-plus.version>4.2.0</ruoyi-vue-plus.version>
<spring-boot.version>2.6.9</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>
<maven-jar-plugin.version>3.2.2</maven-jar-plugin.version>
<druid.version>1.2.8</druid.version>
<spring-boot.mybatis>2.2.2</spring-boot.mybatis>
<druid.version>1.2.11</druid.version>
<knife4j.version>3.0.3</knife4j.version>
<swagger-annotations.version>1.5.22</swagger-annotations.version>
<poi.version>4.1.2</poi.version>
<easyexcel.version>3.0.5</easyexcel.version>
<cglib.version>3.3.0</cglib.version>
<poi.version>5.2.2</poi.version>
<easyexcel.version>3.1.1</easyexcel.version>
<velocity.version>2.3</velocity.version>
<satoken.version>1.29.0</satoken.version>
<mybatis-plus.version>3.5.1</mybatis-plus.version>
<satoken.version>1.30.0</satoken.version>
<mybatis-plus.version>3.5.2</mybatis-plus.version>
<p6spy.version>3.9.1</p6spy.version>
<hutool.version>5.7.21</hutool.version>
<okhttp.version>4.9.2</okhttp.version>
<spring-boot-admin.version>2.6.2</spring-boot-admin.version>
<redisson.version>3.16.8</redisson.version>
<hutool.version>5.8.3</hutool.version>
<okhttp.version>4.9.3</okhttp.version>
<spring-boot-admin.version>2.6.7</spring-boot-admin.version>
<redisson.version>3.17.4</redisson.version>
<lock4j.version>2.2.1</lock4j.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>
<dynamic-ds.version>3.5.1</dynamic-ds.version>
<tlog.version>1.4.3</tlog.version>
<xxl-job.version>2.3.1</xxl-job.version>
<!-- jdk11 缺失依赖 jaxb-->
<jaxb.version>3.0.1</jaxb.version>
<!-- 统一 guava 版本 解决隐式漏洞问题 -->
<guava.version>30.0-jre</guava.version>
<!-- OSS 配置 -->
<qiniu.version>7.9.3</qiniu.version>
<aliyun.oss.version>3.14.0</aliyun.oss.version>
<qcloud.cos.version>5.6.68</qcloud.cos.version>
<minio.version>8.3.7</minio.version>
<aws-java-sdk-s3.version>1.12.248</aws-java-sdk-s3.version>
<!-- SMS 配置 -->
<aliyun.sms.version>2.0.9</aliyun.sms.version>
<tencent.sms.version>3.1.537</tencent.sms.version>
<!-- docker 配置 -->
<docker.registry.url>localhost</docker.registry.url>
@ -102,22 +102,21 @@
<version>${swagger-annotations.version}</version>
</dependency>
<!-- excel工具 -->
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>${poi.version}</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>${poi.version}</version>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>easyexcel</artifactId>
<version>${easyexcel.version}</version>
<exclusions>
<exclusion>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml-schemas</artifactId>
@ -125,12 +124,6 @@
</exclusions>
</dependency>
<dependency>
<groupId>cglib</groupId>
<artifactId>cglib</artifactId>
<version>${cglib.version}</version>
</dependency>
<!-- velocity代码生成使用模板 -->
<dependency>
<groupId>org.apache.velocity</groupId>
@ -151,13 +144,6 @@
<version>${satoken.version}</version>
</dependency>
<!-- jdk11 缺失依赖 jaxb-->
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-impl</artifactId>
<version>${jaxb.version}</version>
</dependency>
<!-- dynamic-datasource 多数据源-->
<dependency>
<groupId>com.baomidou</groupId>
@ -188,6 +174,24 @@
<version>${okhttp.version}</version>
</dependency>
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk-s3</artifactId>
<version>${aws-java-sdk-s3.version}</version>
</dependency>
<dependency>
<groupId>com.aliyun</groupId>
<artifactId>dysmsapi20170525</artifactId>
<version>${aliyun.sms.version}</version>
</dependency>
<dependency>
<groupId>com.tencentcloudapi</groupId>
<artifactId>tencentcloud-sdk-java</artifactId>
<version>${tencent.sms.version}</version>
</dependency>
<dependency>
<groupId>de.codecentric</groupId>
<artifactId>spring-boot-admin-starter-server</artifactId>
@ -222,6 +226,20 @@
<groupId>com.yomahub</groupId>
<artifactId>tlog-web-spring-boot-starter</artifactId>
<version>${tlog.version}</version>
<exclusions>
<exclusion>
<artifactId>log4j</artifactId>
<groupId>log4j</groupId>
</exclusion>
<exclusion>
<artifactId>dom4j</artifactId>
<groupId>dom4j</groupId>
</exclusion>
<exclusion>
<artifactId>commons-beanutils</artifactId>
<groupId>commons-beanutils</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
@ -230,6 +248,13 @@
<version>${tlog.version}</version>
</dependency>
<!-- 统一 guava 版本 解决隐式漏洞问题 -->
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>${guava.version}</version>
</dependency>
<!-- 定时任务 -->
<dependency>
<groupId>com.ruoyi</groupId>
@ -272,6 +297,13 @@
<version>${ruoyi-vue-plus.version}</version>
</dependency>
<!-- SMS短信模块 -->
<dependency>
<groupId>com.ruoyi</groupId>
<artifactId>ruoyi-sms</artifactId>
<version>${ruoyi-vue-plus.version}</version>
</dependency>
<!-- demo模块 -->
<dependency>
<groupId>com.ruoyi</groupId>
@ -292,6 +324,7 @@
<module>ruoyi-demo</module>
<module>ruoyi-extend</module>
<module>ruoyi-oss</module>
<module>ruoyi-sms</module>
</modules>
<packaging>pom</packaging>

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>ruoyi-vue-plus</artifactId>
<groupId>com.ruoyi</groupId>
<version>4.0.1</version>
<version>4.2.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<packaging>jar</packaging>
@ -29,6 +29,21 @@
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>
<!-- Oracle -->
<dependency>
<groupId>com.oracle.database.jdbc</groupId>
<artifactId>ojdbc8</artifactId>
</dependency>
<!-- PostgreSql -->
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
</dependency>
<!-- SqlServer -->
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>mssql-jdbc</artifactId>
</dependency>
<!-- 核心模块-->
<dependency>

View File

@ -4,6 +4,8 @@ import cn.hutool.captcha.AbstractCaptcha;
import cn.hutool.captcha.generator.CodeGenerator;
import cn.hutool.core.convert.Convert;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.RandomUtil;
import com.ruoyi.common.annotation.Anonymous;
import com.ruoyi.common.constant.Constants;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.enums.CaptchaType;
@ -12,30 +14,68 @@ import com.ruoyi.common.utils.redis.RedisUtils;
import com.ruoyi.common.utils.reflect.ReflectUtils;
import com.ruoyi.common.utils.spring.SpringUtils;
import com.ruoyi.framework.config.properties.CaptchaProperties;
import com.ruoyi.sms.config.properties.SmsProperties;
import com.ruoyi.sms.core.SmsTemplate;
import com.ruoyi.sms.entity.SmsResult;
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 lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.validation.constraints.NotBlank;
import java.time.Duration;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.TimeUnit;
/**
* 验证码操作处理
*
* @author Lion Li
*/
@Anonymous
@Slf4j
@Validated
@Api(value = "验证码操作处理", tags = {"验证码管理"})
@RequiredArgsConstructor
@RestController
public class CaptchaController {
private final CaptchaProperties captchaProperties;
private final SmsProperties smsProperties;
private final ISysConfigService configService;
/**
* 短信验证码
*/
@ApiOperation("短信验证码")
@GetMapping("/captchaSms")
public R<Void> smsCaptcha(@ApiParam("用户手机号")
@NotBlank(message = "{user.phonenumber.not.blank}")
String phonenumber) {
if (smsProperties.getEnabled()) {
R.fail("当前系统没有开启短信功能!");
}
String key = Constants.CAPTCHA_CODE_KEY + phonenumber;
String code = RandomUtil.randomNumbers(4);
RedisUtils.setCacheObject(key, code, Duration.ofMinutes(Constants.CAPTCHA_EXPIRATION));
// 验证码模板id 自行处理 (查数据库或写死均可)
String templateId = "";
Map<String, String> map = new HashMap<>(1);
map.put("code", code);
SmsTemplate smsTemplate = SpringUtils.getBean(SmsTemplate.class);
SmsResult result = smsTemplate.send(phonenumber, templateId, map);
if (!result.isSuccess()) {
log.error("验证码短信发送异常 => {}", result);
return R.fail(result.getMessage());
}
return R.ok();
}
/**
* 生成验证码
*/
@ -60,7 +100,7 @@ public class CaptchaController {
captcha.setGenerator(codeGenerator);
captcha.createCode();
String code = isMath ? getCodeResult(captcha.getCode()) : captcha.getCode();
RedisUtils.setCacheObject(verifyKey, code, Constants.CAPTCHA_EXPIRATION, TimeUnit.MINUTES);
RedisUtils.setCacheObject(verifyKey, code, Duration.ofMinutes(Constants.CAPTCHA_EXPIRATION));
ajax.put("uuid", uuid);
ajax.put("img", captcha.getImageBase64());
return R.ok(ajax);

View File

@ -2,11 +2,13 @@ package com.ruoyi.web.controller.system;
import cn.dev33.satoken.exception.NotLoginException;
import cn.dev33.satoken.stp.StpUtil;
import com.ruoyi.common.annotation.Anonymous;
import com.ruoyi.common.constant.Constants;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.domain.entity.SysMenu;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.core.domain.model.LoginBody;
import com.ruoyi.common.core.domain.model.SmsLoginBody;
import com.ruoyi.common.helper.LoginHelper;
import com.ruoyi.system.domain.vo.RouterVo;
import com.ruoyi.system.service.ISysMenuService;
@ -22,6 +24,7 @@ import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import javax.validation.constraints.NotBlank;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@ -49,6 +52,7 @@ public class SysLoginController {
* @param loginBody 登录信息
* @return 结果
*/
@Anonymous
@ApiOperation("登录方法")
@PostMapping("/login")
public R<Map<String, Object>> login(@Validated @RequestBody LoginBody loginBody) {
@ -60,12 +64,48 @@ public class SysLoginController {
return R.ok(ajax);
}
/**
* 短信登录(示例)
*
* @param smsLoginBody 登录信息
* @return 结果
*/
@Anonymous
@ApiOperation("短信登录(示例)")
@PostMapping("/smsLogin")
public R<Map<String, Object>> smsLogin(@Validated @RequestBody SmsLoginBody smsLoginBody) {
Map<String, Object> ajax = new HashMap<>();
// 生成令牌
String token = loginService.smsLogin(smsLoginBody.getPhonenumber(), smsLoginBody.getSmsCode());
ajax.put(Constants.TOKEN, token);
return R.ok(ajax);
}
/**
* 小程序登录(示例)
*
* @param xcxCode 小程序code
* @return 结果
*/
@Anonymous
@ApiOperation("小程序登录(示例)")
@PostMapping("/xcxLogin")
public R<Map<String, Object>> xcxLogin(@NotBlank(message = "{xcx.code.not.blank}") String xcxCode) {
Map<String, Object> ajax = new HashMap<>();
// 生成令牌
String token = loginService.xcxLogin(xcxCode);
ajax.put(Constants.TOKEN, token);
return R.ok(ajax);
}
@Anonymous
@ApiOperation("登出方法")
@PostMapping("/logout")
public R<Void> logout() {
try {
String username = LoginHelper.getUsername();
StpUtil.logout();
loginService.logout(LoginHelper.getUsername());
loginService.logout(username);
} catch (NotLoginException e) {
}
return R.ok("退出成功");

View File

@ -59,7 +59,7 @@ public class SysOssConfigController extends BaseController {
@GetMapping("/{ossConfigId}")
public R<SysOssConfigVo> getInfo(@ApiParam("OSS配置ID")
@NotNull(message = "主键不能为空")
@PathVariable("ossConfigId") Integer ossConfigId) {
@PathVariable("ossConfigId") Long ossConfigId) {
return R.ok(iSysOssConfigService.queryById(ossConfigId));
}

View File

@ -18,7 +18,6 @@ import com.ruoyi.common.utils.file.FileUtils;
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.*;
import lombok.RequiredArgsConstructor;
@ -33,6 +32,7 @@ import java.io.File;
import java.io.IOException;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
@ -48,7 +48,6 @@ import java.util.Map;
public class SysOssController extends BaseController {
private final ISysOssService iSysOssService;
private final ISysConfigService iSysConfigService;
/**
* 查询OSS对象存储列表
@ -60,6 +59,19 @@ public class SysOssController extends BaseController {
return iSysOssService.queryPageList(bo, pageQuery);
}
/**
* 查询OSS对象基于id串
*/
@ApiOperation("查询OSS对象基于ID")
@SaCheckPermission("system:oss:list")
@GetMapping("/listByIds/{ossIds}")
public R<List<SysOssVo>> listByIds(@ApiParam("OSS对象ID串")
@NotEmpty(message = "主键不能为空")
@PathVariable Long[] ossIds) {
List<SysOssVo> list = iSysOssService.listByIds(Arrays.asList(ossIds));
return R.ok(list);
}
/**
* 上传OSS对象存储
*/
@ -77,7 +89,8 @@ public class SysOssController extends BaseController {
SysOss oss = iSysOssService.upload(file);
Map<String, String> map = new HashMap<>(2);
map.put("url", oss.getUrl());
map.put("fileName", oss.getFileName());
map.put("fileName", oss.getOriginalName());
map.put("ossId", oss.getOssId().toString());
return R.ok(map);
}

View File

@ -1,6 +1,7 @@
package com.ruoyi.web.controller.system;
import cn.dev33.satoken.secure.BCrypt;
import cn.hutool.core.io.FileUtil;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.constant.UserConstants;
import com.ruoyi.common.core.controller.BaseController;
@ -9,6 +10,7 @@ import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.helper.LoginHelper;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.file.MimeTypeUtils;
import com.ruoyi.system.domain.SysOss;
import com.ruoyi.system.service.ISysOssService;
import com.ruoyi.system.service.ISysUserService;
@ -22,6 +24,7 @@ import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import java.io.File;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
@ -117,6 +120,10 @@ public class SysProfileController extends BaseController {
public R<Map<String, Object>> avatar(@RequestPart("avatarfile") MultipartFile file) {
Map<String, Object> ajax = new HashMap<>();
if (!file.isEmpty()) {
String extension = FileUtil.extName(file.getOriginalFilename());
if (!StringUtils.equalsAnyIgnoreCase(extension, MimeTypeUtils.IMAGE_EXTENSION)) {
return R.fail("文件格式不正确,请上传" + Arrays.toString(MimeTypeUtils.IMAGE_EXTENSION) + "格式");
}
SysOss oss = iSysOssService.upload(file);
String avatar = oss.getUrl();
if (userService.updateUserAvatar(getUsername(), avatar)) {

View File

@ -1,5 +1,6 @@
package com.ruoyi.web.controller.system;
import com.ruoyi.common.annotation.Anonymous;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.domain.model.RegisterBody;
@ -27,6 +28,7 @@ public class SysRegisterController extends BaseController {
private final SysRegisterService registerService;
private final ISysConfigService configService;
@Anonymous
@ApiOperation("用户注册")
@PostMapping("/register")
public R<Void> register(@Validated @RequestBody RegisterBody user) {

View File

@ -148,7 +148,7 @@ public class SysRoleController extends BaseController {
@SaCheckPermission("system:role:remove")
@Log(title = "角色管理", businessType = BusinessType.DELETE)
@DeleteMapping("/{roleIds}")
public R<Void> remove(@ApiParam("岗位ID串") @PathVariable Long[] roleIds) {
public R<Void> remove(@ApiParam("角色ID串") @PathVariable Long[] roleIds) {
return toAjax(roleService.deleteRoleByIds(roleIds));
}

View File

@ -1,41 +1,34 @@
--- # 监控配置
spring:
boot:
admin:
# Spring Boot Admin Client 客户端的相关配置
client:
# 增加客户端开关
enabled: true
# 设置 Spring Boot Admin Server 地址
url: http://localhost:9090/admin
instance:
service-host-type: IP
username: ruoyi
password: 123456
--- # 监控中心配置
spring.boot.admin.client:
# 增加客户端开关
enabled: true
url: http://localhost:9090/admin
instance:
service-host-type: IP
username: ruoyi
password: 123456
--- # xxl-job 配置
xxl:
job:
# 执行器开关
enabled: true
# 调度中心地址:如调度中心集群部署存在多个地址则用逗号分隔。
admin-addresses: http://localhost:9100/xxl-job-admin
# 执行器通讯TOKEN非空时启用
access-token: xxl-job
# 执行器配置
executor:
# 执行器AppName执行器心跳注册分组依据为空则关闭自动注册
appname: xxl-job-executor
# 执行器端口号 执行器从9101开始往后写
port: 9101
# 执行器注册:默认IP:PORT
address:
# 执行器IP默认自动获取IP
ip:
# 执行器运行日志文件存储磁盘路径
logpath: ./logs/xxl-job
# 执行器日志文件保存天数大于3生效
logretentiondays: 30
xxl.job:
# 执行器开关
enabled: true
# 调度中心地址:如调度中心集群部署存在多个地址则用逗号分隔。
admin-addresses: http://localhost:9100/xxl-job-admin
# 执行器通讯TOKEN非空时启用
access-token: xxl-job
executor:
# 执行器AppName执行器心跳注册分组依据为空则关闭自动注册
appname: xxl-job-executor
# 执行器端口号 执行器从9101开始往后写
port: 9101
# 执行器注册默认IP:PORT
address:
# 执行器IP:默认自动获取IP
ip:
# 执行器运行日志文件存储磁盘路径
logpath: ./logs/xxl-job
# 执行器日志文件保存天数大于3生效
logretentiondays: 30
--- # 数据源配置
spring:
@ -47,6 +40,8 @@ spring:
p6spy: true
# 设置默认的数据源或者数据源组,默认值即为 master
primary: master
# 严格模式 匹配不到数据源则报错
strict: true
datasource:
# 主库数据源
master:
@ -63,6 +58,23 @@ spring:
url:
username:
password:
# oracle:
# driverClassName: oracle.jdbc.OracleDriver
# url: jdbc:oracle:thin:@//localhost:1521/XE
# username: ROOT
# password: root
# druid:
# validationQuery: SELECT 1 FROM DUAL
# postgres:
# driverClassName: org.postgresql.Driver
# url: jdbc:postgresql://localhost:5432/postgres?useUnicode=true&characterEncoding=utf8&useSSL=true&autoReconnect=true&reWriteBatchedInserts=true
# username: root
# password: root
# sqlserver:
# driverClassName: com.microsoft.sqlserver.jdbc.SQLServerDriver
# url: jdbc:sqlserver://localhost:1433;DatabaseName=tempdb;SelectMethod=cursor;rewriteBatchedStatements=true
# username: SA
# password: root
druid:
# 初始连接数
initialSize: 5
@ -79,7 +91,7 @@ spring:
# 配置一个连接在池中最大生存的时间,单位是毫秒
maxEvictableIdleTimeMillis: 900000
# 配置检测连接是否有效
validationQuery: SELECT 1 FROM DUAL
validationQuery: SELECT 1
testWhileIdle: true
testOnBorrow: false
testOnReturn: false
@ -87,29 +99,27 @@ spring:
filters: stat
--- # druid 配置
spring:
datasource:
druid:
webStatFilter:
enabled: true
statViewServlet:
enabled: true
# 设置白名单,不填则允许所有访问
allow:
url-pattern: /druid/*
# 控制台管理用户名和密码
login-username: ruoyi
login-password: 123456
filter:
stat:
enabled: true
# 慢SQL记录
log-slow-sql: true
slow-sql-millis: 1000
merge-sql: true
wall:
config:
multi-statement-allow: true
spring.datasource.druid:
webStatFilter:
enabled: true
statViewServlet:
enabled: true
# 设置白名单,不填则允许所有访问
allow:
url-pattern: /druid/*
# 控制台管理用户名和密码
login-username: ruoyi
login-password: 123456
filter:
stat:
enabled: true
# 慢SQL记录
log-slow-sql: true
slow-sql-millis: 1000
merge-sql: true
wall:
config:
multi-statement-allow: true
--- # redis 单机配置(单机与集群只能开启一个另一个需要注释掉)
spring:
@ -120,8 +130,8 @@ spring:
port: 6379
# 数据库索引
database: 0
# 密码
password:
# 密码(如没有密码请注释掉)
# password:
# 连接超时时间
timeout: 10s
# 是否开启ssl
@ -132,8 +142,6 @@ redisson:
threads: 4
# Netty线程池数量
nettyThreads: 8
# 传输模式
transportMode: "NIO"
# 单节点配置
singleServerConfig:
# 客户端名称
@ -146,9 +154,39 @@ redisson:
idleConnectionTimeout: 10000
# 命令等待超时,单位:毫秒
timeout: 3000
# 如果尝试在此限制之内发送成功,则开始启用 timeout 计时。
retryAttempts: 3
# 命令重试发送时间间隔,单位:毫秒
retryInterval: 1500
# 发布和订阅连接池大小
subscriptionConnectionPoolSize: 50
--- # mail 邮件发送
mail:
enabled: false
host: smtp.163.com
port: 465
# 是否需要用户名密码验证
auth: true
# 发送方遵循RFC-822标准
from: xxx@163.com
# 用户名注意如果使用foxmail邮箱此处user为qq号
user: xxx@163.com
# 密码注意某些邮箱需要为SMTP服务单独设置密码详情查看相关帮助
pass: xxxxxxxxxx
# 使用 STARTTLS安全连接STARTTLS是对纯文本通信协议的扩展。
starttlsEnable: true
# 使用SSL安全连接
sslEnable: true
# SMTP超时时长单位毫秒缺省值不超时
timeout: 0
# Socket连接超时值单位毫秒缺省值不超时
connectionTimeout: 0
--- # sms 短信
sms:
enabled: false
# 阿里云 dysmsapi.aliyuncs.com
# 腾讯云 sms.tencentcloudapi.com
endpoint: "dysmsapi.aliyuncs.com"
accessKeyId: xxxxxxx
accessKeySecret: xxxxxx
signName: 测试
# 腾讯专用
sdkAppId:

View File

@ -1,48 +1,37 @@
--- # 配置临时路径存储
spring:
servlet:
multipart:
# 临时文件存储位置 避免临时文件被系统清理报错
location: /ruoyi/server/temp
--- # 临时文件存储位置 避免临时文件被系统清理报错
spring.servlet.multipart.location: /ruoyi/server/temp
--- # 监控配置
spring:
boot:
admin:
# Spring Boot Admin Client 客户端的相关配置
client:
# 增加客户端开关
enabled: true
# 设置 Spring Boot Admin Server 地址
url: http://172.30.0.90:9090/admin
instance:
service-host-type: IP
username: ruoyi
password: 123456
--- # 监控中心配置
spring.boot.admin.client:
# 增加客户端开关
enabled: true
url: http://172.30.0.90:9090/admin
instance:
service-host-type: IP
username: ruoyi
password: 123456
--- # xxl-job 配置
xxl:
job:
# 执行器开关
enabled: true
# 调度中心地址:如调度中心集群部署存在多个地址则用逗号分隔。
admin-addresses: http://172.30.0.92:9100/xxl-job-admin
# 执行器通讯TOKEN非空时启用
access-token: xxl-job
# 执行器配置
executor:
# 执行器AppName执行器心跳注册分组依据为空则关闭自动注册
appname: xxl-job-executor
# 执行器端口号 执行器从9101开始往后写
port: 9101
# 执行器注册:默认IP:PORT
address:
# 执行器IP默认自动获取IP
ip:
# 执行器运行日志文件存储磁盘路径
logpath: ./logs/xxl-job
# 执行器日志文件保存天数大于3生效
logretentiondays: 30
xxl.job:
# 执行器开关
enabled: true
# 调度中心地址:如调度中心集群部署存在多个地址则用逗号分隔。
admin-addresses: http://172.30.0.92:9100/xxl-job-admin
# 执行器通讯TOKEN非空时启用
access-token: xxl-job
executor:
# 执行器AppName执行器心跳注册分组依据为空则关闭自动注册
appname: xxl-job-executor
# 执行器端口号 执行器从9101开始往后写
port: 9101
# 执行器注册默认IP:PORT
address:
# 执行器IP:默认自动获取IP
ip:
# 执行器运行日志文件存储磁盘路径
logpath: ./logs/xxl-job
# 执行器日志文件保存天数大于3生效
logretentiondays: 30
--- # 数据源配置
spring:
@ -54,6 +43,8 @@ spring:
p6spy: false
# 设置默认的数据源或者数据源组,默认值即为 master
primary: master
# 严格模式 匹配不到数据源则报错
strict: true
datasource:
# 主库数据源
master:
@ -70,6 +61,23 @@ spring:
url:
username:
password:
# oracle:
# driverClassName: oracle.jdbc.OracleDriver
# url: jdbc:oracle:thin:@//172.30.0.36:1521/XE
# username: ROOT
# password: root
# druid:
# validationQuery: SELECT 1 FROM DUAL
# postgres:
# driverClassName: org.postgresql.Driver
# url: jdbc:postgresql://172.30.0.36:5432/postgres?useUnicode=true&characterEncoding=utf8&useSSL=true&autoReconnect=true&reWriteBatchedInserts=true
# username: root
# password: root
# sqlserver:
# driverClassName: com.microsoft.sqlserver.jdbc.SQLServerDriver
# url: jdbc:sqlserver://172.30.0.36:1433;DatabaseName=tempdb;SelectMethod=cursor;rewriteBatchedStatements=true
# username: SA
# password: root
druid:
# 初始连接数
initialSize: 5
@ -86,7 +94,7 @@ spring:
# 配置一个连接在池中最大生存的时间,单位是毫秒
maxEvictableIdleTimeMillis: 900000
# 配置检测连接是否有效
validationQuery: SELECT 1 FROM DUAL
validationQuery: SELECT 1
testWhileIdle: true
testOnBorrow: false
testOnReturn: false
@ -94,29 +102,27 @@ spring:
filters: stat
--- # druid 配置
spring:
datasource:
druid:
webStatFilter:
enabled: true
statViewServlet:
enabled: true
# 设置白名单,不填则允许所有访问
allow:
url-pattern: /druid/*
# 控制台管理用户名和密码
login-username: ruoyi
login-password: 123456
filter:
stat:
enabled: true
# 慢SQL记录
log-slow-sql: true
slow-sql-millis: 1000
merge-sql: true
wall:
config:
multi-statement-allow: true
spring.datasource.druid:
webStatFilter:
enabled: true
statViewServlet:
enabled: true
# 设置白名单,不填则允许所有访问
allow:
url-pattern: /druid/*
# 控制台管理用户名和密码
login-username: ruoyi
login-password: 123456
filter:
stat:
enabled: true
# 慢SQL记录
log-slow-sql: true
slow-sql-millis: 1000
merge-sql: true
wall:
config:
multi-statement-allow: true
--- # redis 单机配置(单机与集群只能开启一个另一个需要注释掉)
spring:
@ -127,8 +133,8 @@ spring:
port: 6379
# 数据库索引
database: 0
# 密码
password:
# 密码(如没有密码请注释掉)
# password:
# 连接超时时间
timeout: 10s
# 是否开启ssl
@ -139,8 +145,6 @@ redisson:
threads: 16
# Netty线程池数量
nettyThreads: 32
# 传输模式
transportMode: "NIO"
# 单节点配置
singleServerConfig:
# 客户端名称
@ -153,9 +157,39 @@ redisson:
idleConnectionTimeout: 10000
# 命令等待超时,单位:毫秒
timeout: 3000
# 如果尝试在此限制之内发送成功,则开始启用 timeout 计时。
retryAttempts: 3
# 命令重试发送时间间隔,单位:毫秒
retryInterval: 1500
# 发布和订阅连接池大小
subscriptionConnectionPoolSize: 50
--- # mail 邮件发送
mail:
enabled: false
host: smtp.163.com
port: 465
# 是否需要用户名密码验证
auth: true
# 发送方遵循RFC-822标准
from: xxx@163.com
# 用户名注意如果使用foxmail邮箱此处user为qq号
user: xxx@163.com
# 密码注意某些邮箱需要为SMTP服务单独设置密码详情查看相关帮助
pass: xxxxxxxxxx
# 使用 STARTTLS安全连接STARTTLS是对纯文本通信协议的扩展。
starttlsEnable: true
# 使用SSL安全连接
sslEnable: true
# SMTP超时时长单位毫秒缺省值不超时
timeout: 0
# Socket连接超时值单位毫秒缺省值不超时
connectionTimeout: 0
--- # sms 短信
sms:
enabled: false
# 阿里云 dysmsapi.aliyuncs.com
# 腾讯云 sms.tencentcloudapi.com
endpoint: "dysmsapi.aliyuncs.com"
accessKeyId: xxxxxxx
accessKeySecret: xxxxxx
signName: 测试
# 腾讯专用
sdkAppId:

View File

@ -75,10 +75,6 @@ spring:
restart:
# 热部署开关
enabled: true
# 与vue整合部署使用
thymeleaf:
# 将系统模板放置到最前面 否则会与 springboot-admin 页面冲突
template-resolver-order: 1
mvc:
pathmatch:
# 适配 boot 2.6 路由与 springfox 兼容
@ -107,16 +103,12 @@ sa-token:
is-concurrent: true
# 在多人登录同一账号时是否共用一个token (为true时所有登录共用一个token, 为false时每次登录新建一个token)
is-share: false
# 是否尝试从请求体里读取token
is-read-body: false
# 是否尝试从header里读取token
is-read-head: true
# 是否尝试从cookie里读取token
is-read-cookie: false
# token前缀
token-prefix: "Bearer"
# token风格
token-style: uuid
# jwt秘钥
jwt-secret-key: abcdefghijklmnopqrstuvwxyz
# 是否输出操作日志
@ -126,33 +118,23 @@ sa-token:
security:
# 排除路径
excludes:
- /login
- /logout
- /register
- /captchaImage
# 静态资源
- /*.html
- /**/*.html
- /**/*.css
- /**/*.js
# swagger 文档配置
- /favicon.ico
- /doc.html
- /swagger-resources/**
- /webjars/**
- /*/api-docs
# druid 监控配置
- /druid/**
# 用户放行
permit-all:
# actuator 监控配置
- /actuator
- /actuator/**
# 重复提交
repeat-submit:
# 全局间隔时间(毫秒)
interval: 5000
# MyBatisPlus配置
# https://baomidou.com/config/
mybatis-plus:
@ -165,25 +147,15 @@ mybatis-plus:
typeAliasesPackage: com.ruoyi.**.domain
# 启动时是否检查 MyBatis XML 文件的存在,默认不检查
checkConfigLocation: false
# 通过该属性可指定 MyBatis 的执行器MyBatis 的执行器总共有三种:
# SIMPLE每个语句创建新的预处理器 REUSE会复用预处理器 BATCH批量执行所有的更新
executorType: SIMPLE
configuration:
# 自动驼峰命名规则camel case映射
mapUnderscoreToCamelCase: true
# 当设置为 true 的时候,懒加载的对象可能被任何懒属性全部加载,否则,每个属性都按需加载。需要和 lazyLoadingEnabled 一起使用。
aggressiveLazyLoading: true
# MyBatis 自动映射策略
# NONE不启用 PARTIAL只对非嵌套 resultMap 自动映射 FULL对所有 resultMap 自动映射
autoMappingBehavior: PARTIAL
# MyBatis 自动映射时未知列或未知属性处理策
# NONE不做处理 WARNING打印相关警告 FAILING抛出异常和详细信息
autoMappingUnknownColumnBehavior: NONE
# Mybatis一级缓存默认为 SESSION
# SESSION session级别缓存 STATEMENT 关闭一级缓存
localCacheScope: SESSION
# 开启Mybatis二级缓存默认为 true
cacheEnabled: false
# 更详细的日志输出 会有性能损耗 org.apache.ibatis.logging.stdout.StdOutImpl
# 关闭日志记录 (可单纯使用 p6spy 分析) org.apache.ibatis.logging.nologging.NoLoggingImpl
# 默认日志输出 org.apache.ibatis.logging.slf4j.Slf4jImpl
@ -191,16 +163,10 @@ mybatis-plus:
global-config:
# 是否打印 Logo banner
banner: true
# 是否初始化 SqlRunner
enableSqlRunner: false
dbConfig:
# 主键类型
# AUTO 自增 NONE 空 INPUT 用户输入 ASSIGN_ID 雪花 ASSIGN_UUID 唯一 UUID
idType: AUTO
# 表名是否使用驼峰转下划线命名,只对表名生效
tableUnderline: true
# 大写命名,对表名和字段名均生效
capitalMode: false
idType: ASSIGN_ID
# 逻辑已删除值
logicDeleteValue: 2
# 逻辑未删除值
@ -271,20 +237,10 @@ xss:
thread-pool:
# 是否开启线程池
enabled: false
# 核心线程池大小
corePoolSize: 8
# 最大可创建的线程数
maxPoolSize: 16
# 队列最大长度
queueCapacity: 128
# 线程池维护线程所允许的空闲时间
keepAliveSeconds: 300
# 线程池对拒绝任务(无线程可用)的处理策略
# CALLER_RUNS_POLICY 调用方执行
# DISCARD_OLDEST_POLICY 放弃最旧的
# DISCARD_POLICY 丢弃
# ABORT_POLICY 中止
rejectedExecutionHandler: CALLER_RUNS_POLICY
--- # redisson 缓存配置
redisson:
@ -312,8 +268,6 @@ lock4j:
management:
endpoints:
web:
# Actuator 提供的 API 接口的根目录。默认为 /actuator
base-path: /actuator
exposure:
# 需要开放的端点。默认值只打开 health 和 info 两个端点。通过设置 * ,可以开放所有端点。
# 生产环境不建议放开所有 根据项目需求放开即可

View File

@ -18,6 +18,7 @@ user.password.not.blank=用户密码不能为空
user.password.length.valid=用户密码长度必须在{min}到{max}个字符之间
user.password.not.valid=* 5-50个字符
user.email.not.valid=邮箱格式错误
user.phonenumber.not.blank=用户手机号不能为空
user.mobile.phone.number.not.valid=手机号格式错误
user.login.success=登录成功
user.register.success=注册成功
@ -36,3 +37,9 @@ no.update.permission=您没有修改数据的权限,请联系管理员添加
no.delete.permission=您没有删除数据的权限,请联系管理员添加权限 [{0}]
no.export.permission=您没有导出数据的权限,请联系管理员添加权限 [{0}]
no.view.permission=您没有查看数据的权限,请联系管理员添加权限 [{0}]
repeat.submit.message=不允许重复提交,请稍候再试
rate.limiter.message=访问过于频繁,请稍候再试
sms.code.not.blank=短信验证码不能为空
sms.code.retry.limit.count=短信验证码输入错误{0}次
sms.code.retry.limit.exceed=短信验证码错误次数过多,帐户锁定{0}分钟
xcx.code.not.blank=小程序code不能为空

View File

@ -18,6 +18,7 @@ user.password.not.blank=Password cannot be empty
user.password.length.valid=Password length must be between {min} and {max} characters
user.password.not.valid=* 5-50 characters
user.email.not.valid=Mailbox format error
user.phonenumber.not.blank=Phone number cannot be blank
user.mobile.phone.number.not.valid=Phone number format error
user.login.success=Login successful
user.register.success=Register successful
@ -36,3 +37,9 @@ no.update.permission=You do not have permission to modify dataplease contact
no.delete.permission=You do not have permission to delete dataplease contact your administrator to add permissions [{0}]
no.export.permission=You do not have permission to export dataplease contact your administrator to add permissions [{0}]
no.view.permission=You do not have permission to view dataplease contact your administrator to add permissions [{0}]
repeat.submit.message=Repeat submit is not allowed, please try again later
rate.limiter.message=Visit too frequently, please try again later
sms.code.not.blank=Sms code cannot be blank
sms.code.retry.limit.count=Sms code input error {0} times
sms.code.retry.limit.exceed=Too many sms code errors, account locked for {0} minutes
xcx.code.not.blank=Mini program code cannot be blank

View File

@ -18,6 +18,7 @@ user.password.not.blank=用户密码不能为空
user.password.length.valid=用户密码长度必须在{min}到{max}个字符之间
user.password.not.valid=* 5-50个字符
user.email.not.valid=邮箱格式错误
user.phonenumber.not.blank=用户手机号不能为空
user.mobile.phone.number.not.valid=手机号格式错误
user.login.success=登录成功
user.register.success=注册成功
@ -36,3 +37,9 @@ no.update.permission=您没有修改数据的权限,请联系管理员添加
no.delete.permission=您没有删除数据的权限,请联系管理员添加权限 [{0}]
no.export.permission=您没有导出数据的权限,请联系管理员添加权限 [{0}]
no.view.permission=您没有查看数据的权限,请联系管理员添加权限 [{0}]
repeat.submit.message=不允许重复提交,请稍候再试
rate.limiter.message=访问过于频繁,请稍候再试
sms.code.not.blank=短信验证码不能为空
sms.code.retry.limit.count=短信验证码输入错误{0}次
sms.code.retry.limit.exceed=短信验证码错误次数过多,帐户锁定{0}分钟
xcx.code.not.blank=小程序code不能为空

View File

@ -77,19 +77,31 @@
</filter>
</appender>
<!-- 系统模块日志级别控制 -->
<logger name="com.ruoyi" level="info" />
<!-- Spring日志级别控制 -->
<logger name="org.springframework" level="warn" />
<!-- info异步输出 -->
<appender name="async_info" class="com.yomahub.tlog.core.enhance.logback.async.AspectLogbackAsyncAppender">
<!-- 不丢失日志.默认的,如果队列的80%已满,则会丢弃TRACT、DEBUG、INFO级别的日志 -->
<discardingThreshold>0</discardingThreshold>
<!-- 更改默认的队列的深度,该值会影响性能.默认值为256 -->
<queueSize>512</queueSize>
<!-- 添加附加的appender,最多只能添加一个 -->
<appender-ref ref="file_info"/>
</appender>
<root level="info">
<appender-ref ref="console" />
</root>
<!-- error异步输出 -->
<appender name="async_error" class="com.yomahub.tlog.core.enhance.logback.async.AspectLogbackAsyncAppender">
<!-- 不丢失日志.默认的,如果队列的80%已满,则会丢弃TRACT、DEBUG、INFO级别的日志 -->
<discardingThreshold>0</discardingThreshold>
<!-- 更改默认的队列的深度,该值会影响性能.默认值为256 -->
<queueSize>512</queueSize>
<!-- 添加附加的appender,最多只能添加一个 -->
<appender-ref ref="file_error"/>
</appender>
<!--系统操作日志-->
<root level="info">
<appender-ref ref="file_info" />
<appender-ref ref="file_error" />
<appender-ref ref="console" />
<appender-ref ref="async_info" />
<appender-ref ref="async_error" />
<appender-ref ref="file_console" />
</root>

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>ruoyi-vue-plus</artifactId>
<groupId>com.ruoyi</groupId>
<version>4.0.1</version>
<version>4.2.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
@ -58,34 +58,17 @@
<artifactId>jackson-databind</artifactId>
</dependency>
<!-- excel工具 -->
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>easyexcel</artifactId>
</dependency>
<dependency>
<groupId>cglib</groupId>
<artifactId>cglib</artifactId>
</dependency>
<!-- yml解析器 -->
<dependency>
<groupId>org.yaml</groupId>
<artifactId>snakeyaml</artifactId>
</dependency>
<!-- jdk11 缺失依赖 jaxb-->
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-impl</artifactId>
</dependency>
<!-- servlet包 -->
<dependency>
<groupId>javax.servlet</groupId>
@ -132,6 +115,11 @@
<artifactId>hutool-extra</artifactId>
</dependency>
<dependency>
<groupId>com.sun.mail</groupId>
<artifactId>jakarta.mail</artifactId>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>

View File

@ -0,0 +1,18 @@
package com.ruoyi.common.annotation;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* 匿名访问不鉴权注解
*
* @author ruoyi
*/
@Target({ElementType.METHOD, ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface Anonymous {
}

View File

@ -0,0 +1,24 @@
package com.ruoyi.common.annotation;
import com.ruoyi.common.excel.CellMergeStrategy;
import java.lang.annotation.*;
/**
* excel 列单元格合并(合并列相同项)
*
* 需搭配 {@link CellMergeStrategy} 策略使用
*
* @author Lion Li
*/
@Target(ElementType.FIELD)
@Retention(RetentionPolicy.RUNTIME)
@Inherited
public @interface CellMerge {
/**
* col index
*/
int index() default -1;
}

View File

@ -22,8 +22,8 @@ public @interface RepeatSubmit {
TimeUnit timeUnit() default TimeUnit.MILLISECONDS;
/**
* 提示消息
* 提示消息 支持国际化 格式为 {code}
*/
String message() default "不允许重复提交,请稍候再试";
String message() default "{repeat.submit.message}";
}

View File

@ -65,12 +65,12 @@ public interface Constants {
/**
* 登录用户 redis key
*/
public static final String LOGIN_TOKEN_KEY = "Authorization:login:token:";
String LOGIN_TOKEN_KEY = "Authorization:login:token:";
/**
* 在线用户 redis key
*/
public static final String ONLINE_TOKEN_KEY = "online_tokens:";
String ONLINE_TOKEN_KEY = "online_tokens:";
/**
* 防重提交 redis key

View File

@ -22,11 +22,21 @@ public interface UserConstants {
*/
String EXCEPTION = "1";
/**
* 用户正常状态
*/
String USER_NORMAL = "0";
/**
* 用户封禁状态
*/
String USER_DISABLE = "1";
/**
* 角色正常状态
*/
String ROLE_NORMAL = "0";
/**
* 角色封禁状态
*/
@ -62,6 +72,16 @@ public interface UserConstants {
*/
String NO_FRAME = "1";
/**
* 菜单正常状态
*/
String MENU_NORMAL = "0";
/**
* 菜单停用状态
*/
String MENU_DISABLE = "1";
/**
* 菜单类型(目录)
*/

View File

@ -16,7 +16,7 @@ import java.util.List;
@Data
@EqualsAndHashCode(callSuper = true)
public class TreeEntity extends BaseEntity {
public class TreeEntity<T> extends BaseEntity {
private static final long serialVersionUID = 1L;
@ -38,6 +38,6 @@ public class TreeEntity extends BaseEntity {
*/
@TableField(exist = false)
@ApiModelProperty(value = "子部门")
private List<?> children = new ArrayList<>();
private List<T> children = new ArrayList<>();
}

View File

@ -24,7 +24,7 @@ import javax.validation.constraints.Size;
@EqualsAndHashCode(callSuper = true)
@TableName("sys_dept")
@ApiModel("部门业务对象")
public class SysDept extends TreeEntity {
public class SysDept extends TreeEntity<SysDept> {
private static final long serialVersionUID = 1L;
/**
@ -47,7 +47,7 @@ public class SysDept extends TreeEntity {
*/
@ApiModelProperty(value = "显示顺序")
@NotNull(message = "显示顺序不能为空")
private Long orderNum;
private Integer orderNum;
/**
* 负责人

View File

@ -42,7 +42,7 @@ public class SysDictData extends BaseEntity {
*/
@ApiModelProperty(value = "字典排序")
@ExcelProperty(value = "字典排序")
private Long dictSort;
private Integer dictSort;
/**
* 字典标签

View File

@ -14,6 +14,7 @@ import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Pattern;
import javax.validation.constraints.Size;
/**
@ -53,6 +54,7 @@ public class SysDictType extends BaseEntity {
@ExcelProperty(value = "字典类型")
@NotBlank(message = "字典类型不能为空")
@Size(min = 0, max = 100, message = "字典类型类型长度不能超过100个字符")
@Pattern(regexp = "^[a-z][a-z0-9_]*$", message = "字典类型必须以字母开头,且只能为(小写字母,数字,下滑线)")
private String dictType;
/**

View File

@ -1,8 +1,8 @@
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.fasterxml.jackson.annotation.JsonInclude;
import com.ruoyi.common.core.domain.TreeEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
@ -23,7 +23,7 @@ import javax.validation.constraints.Size;
@EqualsAndHashCode(callSuper = true)
@TableName("sys_menu")
@ApiModel("菜单权限业务对象")
public class SysMenu extends TreeEntity {
public class SysMenu extends TreeEntity<SysMenu> {
/**
* 菜单ID
@ -45,7 +45,7 @@ public class SysMenu extends TreeEntity {
*/
@ApiModelProperty(value = "显示顺序")
@NotNull(message = "显示顺序不能为空")
private Long orderNum;
private Integer orderNum;
/**
* 路由地址
@ -65,8 +65,7 @@ public class SysMenu extends TreeEntity {
* 路由参数
*/
@ApiModelProperty(value = "路由参数")
@TableField("`query`")
private String query;
private String queryParam;
/**
* 是否为外链0是 1否
@ -103,6 +102,7 @@ public class SysMenu extends TreeEntity {
* 权限字符串
*/
@ApiModelProperty(value = "权限字符串")
@JsonInclude(JsonInclude.Include.NON_NULL)
@Size(min = 0, max = 100, message = "权限标识长度不能超过100个字符")
private String perms;

View File

@ -16,6 +16,7 @@ import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
/**
@ -62,8 +63,8 @@ public class SysRole extends BaseEntity {
*/
@ApiModelProperty(value = "角色排序")
@ExcelProperty(value = "角色排序")
@NotBlank(message = "显示顺序不能为空")
private String roleSort;
@NotNull(message = "显示顺序不能为空")
private Integer roleSort;
/**
* 数据范围1所有数据权限2自定义数据权限3本部门数据权限4本部门及以下数据权限5仅本人数据权限
@ -77,13 +78,13 @@ public class SysRole extends BaseEntity {
* 菜单树选择项是否关联显示( 0父子不互相关联显示 1父子互相关联显示
*/
@ApiModelProperty(value = "菜单树选择项是否关联显示( 0父子不互相关联显示 1父子互相关联显示")
private boolean menuCheckStrictly;
private Boolean menuCheckStrictly;
/**
* 部门树选择项是否关联显示0父子不互相关联显示 1父子互相关联显示
*/
@ApiModelProperty(value = "部门树选择项是否关联显示0父子不互相关联显示 1父子互相关联显示 ")
private boolean deptCheckStrictly;
private Boolean deptCheckStrictly;
/**
* 角色状态0正常 1停用
@ -135,5 +136,4 @@ public class SysRole extends BaseEntity {
public boolean isAdmin() {
return UserConstants.ADMIN_ID.equals(this.roleId);
}
}

View File

@ -108,12 +108,6 @@ public class SysUser extends BaseEntity {
)
private String password;
@JsonIgnore
@JsonProperty
public String getPassword() {
return password;
}
/**
* 帐号状态0正常 1停用
*/

View File

@ -0,0 +1,33 @@
package com.ruoyi.common.core.domain.model;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotBlank;
/**
* 短信登录对象
*
* @author Lion Li
*/
@Data
@ApiModel("短信登录对象")
public class SmsLoginBody {
/**
* 用户名
*/
@NotBlank(message = "{user.phonenumber.not.blank}")
@ApiModelProperty(value = "用户手机号")
private String phonenumber;
/**
* 用户密码
*/
@NotBlank(message = "{sms.code.not.blank}")
@ApiModelProperty(value = "短信验证码")
private String smsCode;
}

View File

@ -0,0 +1,24 @@
package com.ruoyi.common.core.domain.model;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
/**
* 小程序登录用户身份权限
*
* @author Lion Li
*/
@Data
@EqualsAndHashCode(callSuper = true)
@NoArgsConstructor
public class XcxLoginUser extends LoginUser {
private static final long serialVersionUID = 1L;
/**
* openid
*/
private String openid;
}

View File

@ -0,0 +1,49 @@
package com.ruoyi.common.enums;
import com.ruoyi.common.utils.StringUtils;
import lombok.AllArgsConstructor;
import lombok.Getter;
/**
* 数据库类型
*
* @author Lion Li
*/
@Getter
@AllArgsConstructor
public enum DataBaseType {
/**
* MySQL
*/
MY_SQL("MySQL"),
/**
* Oracle
*/
ORACLE("Oracle"),
/**
* PostgreSQL
*/
POSTGRE_SQL("PostgreSQL"),
/**
* SQL Server
*/
SQL_SERVER("Microsoft SQL Server");
private final String type;
public static DataBaseType find(String databaseProductName) {
if (StringUtils.isBlank(databaseProductName)) {
return null;
}
for (DataBaseType type : values()) {
if (type.getType().equals(databaseProductName)) {
return type;
}
}
return null;
}
}

View File

@ -21,7 +21,12 @@ public enum DeviceType {
/**
* app端
*/
APP("app");
APP("app"),
/**
* 小程序端
*/
XCX("xcx");
private final String device;
}

View File

@ -0,0 +1,39 @@
package com.ruoyi.common.enums;
import lombok.AllArgsConstructor;
import lombok.Getter;
/**
* 登录类型
*
* @author Lion Li
*/
@Getter
@AllArgsConstructor
public enum LoginType {
/**
* 密码登录
*/
PASSWORD("user.password.retry.limit.exceed", "user.password.retry.limit.count"),
/**
* 短信登录
*/
SMS("sms.code.retry.limit.exceed", "sms.code.retry.limit.count"),
/**
* 小程序登录
*/
XCX("", "");
/**
* 登录重试超出限制提示
*/
final String retryLimitExceed;
/**
* 登录重试限制计数提示
*/
final String retryLimitCount;
}

View File

@ -1,26 +0,0 @@
package com.ruoyi.common.enums;
import lombok.AllArgsConstructor;
import lombok.Getter;
import java.util.concurrent.RejectedExecutionHandler;
import java.util.concurrent.ThreadPoolExecutor;
/**
* 线程池 拒绝策略 泛型
*
* @author Lion Li
*/
@Getter
@AllArgsConstructor
public enum ThreadPoolRejectedPolicy {
CALLER_RUNS_POLICY("调用方执行", ThreadPoolExecutor.CallerRunsPolicy.class),
DISCARD_OLDEST_POLICY("放弃最旧的", ThreadPoolExecutor.DiscardOldestPolicy.class),
DISCARD_POLICY("丢弃", ThreadPoolExecutor.DiscardPolicy.class),
ABORT_POLICY("中止", ThreadPoolExecutor.AbortPolicy.class);
private final String name;
private final Class<? extends RejectedExecutionHandler> clazz;
}

View File

@ -0,0 +1,114 @@
package com.ruoyi.common.excel;
import com.alibaba.excel.metadata.Head;
import com.alibaba.excel.write.merge.AbstractMergeStrategy;
import com.ruoyi.common.annotation.CellMerge;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.util.CellRangeAddress;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* 列值重复合并策略
*
* @author Lion Li
*/
@AllArgsConstructor
@Slf4j
public class CellMergeStrategy extends AbstractMergeStrategy {
private List<?> list;
private boolean hasTitle;
@Override
protected void merge(Sheet sheet, Cell cell, Head head, Integer relativeRowIndex) {
List<CellRangeAddress> cellList = handle(list, hasTitle);
// judge the list is not null
if (CollectionUtils.isNotEmpty(cellList)) {
// the judge is necessary
if (cell.getRowIndex() == 1 && cell.getColumnIndex() == 0) {
for (CellRangeAddress item : cellList) {
sheet.addMergedRegion(item);
}
}
}
}
@SneakyThrows
private static List<CellRangeAddress> handle(List<?> list, boolean hasTitle) {
List<CellRangeAddress> cellList = new ArrayList<>();
if (CollectionUtils.isEmpty(list)) {
return cellList;
}
Class<?> clazz = list.get(0).getClass();
Field[] fields = clazz.getDeclaredFields();
// 有注解的字段
List<Field> mergeFields = new ArrayList<>();
List<Integer> mergeFieldsIndex = new ArrayList<>();
for (int i = 0; i < fields.length; i++) {
Field field = fields[i];
if (field.isAnnotationPresent(CellMerge.class)) {
CellMerge cm = field.getAnnotation(CellMerge.class);
mergeFields.add(field);
mergeFieldsIndex.add(cm.index() == -1 ? i : cm.index());
}
}
// 行合并开始下标
int rowIndex = hasTitle ? 1 : 0;
Map<Field, RepeatCell> map = new HashMap<>();
// 生成两两合并单元格
for (int i = 0; i < list.size(); i++) {
for (int j = 0; j < mergeFields.size(); j++) {
Field field = mergeFields.get(j);
String name = field.getName();
String methodName = "get" + name.substring(0, 1).toUpperCase() + name.substring(1);
Method readMethod = clazz.getMethod(methodName);
Object val = readMethod.invoke(list.get(i));
int colNum = mergeFieldsIndex.get(j);
if (!map.containsKey(field)) {
map.put(field, new RepeatCell(val, i));
} else {
RepeatCell repeatCell = map.get(field);
Object cellValue = repeatCell.getValue();
if (cellValue == null || "".equals(cellValue)) {
// 空值跳过不合并
continue;
}
if (cellValue != val) {
if (i - repeatCell.getCurrent() > 1) {
cellList.add(new CellRangeAddress(repeatCell.getCurrent() + rowIndex, i + rowIndex - 1, colNum, colNum));
}
map.put(field, new RepeatCell(val, i));
} else if (i == list.size() - 1) {
if (i > repeatCell.getCurrent()) {
cellList.add(new CellRangeAddress(repeatCell.getCurrent() + rowIndex, i + rowIndex, colNum, colNum));
}
}
}
}
}
return cellList;
}
@Data
@AllArgsConstructor
static class RepeatCell {
private Object value;
private int current;
}
}

View File

@ -0,0 +1,72 @@
package com.ruoyi.common.helper;
import cn.hutool.core.convert.Convert;
import com.baomidou.dynamic.datasource.DynamicRoutingDataSource;
import com.ruoyi.common.enums.DataBaseType;
import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.common.utils.spring.SpringUtils;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import javax.sql.DataSource;
import java.sql.Connection;
import java.sql.DatabaseMetaData;
import java.sql.SQLException;
/**
* 数据库助手
*
* @author Lion Li
*/
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public class DataBaseHelper {
private static final DynamicRoutingDataSource DS = SpringUtils.getBean(DynamicRoutingDataSource.class);
/**
* 获取当前数据库类型
*/
public static DataBaseType getDataBaseType() {
DataSource dataSource = DS.determineDataSource();
try (Connection conn = dataSource.getConnection()) {
DatabaseMetaData metaData = conn.getMetaData();
String databaseProductName = metaData.getDatabaseProductName();
return DataBaseType.find(databaseProductName);
} catch (SQLException e) {
throw new ServiceException(e.getMessage());
}
}
public static boolean isMySql() {
return DataBaseType.MY_SQL == getDataBaseType();
}
public static boolean isOracle() {
return DataBaseType.ORACLE == getDataBaseType();
}
public static boolean isPostgerSql() {
return DataBaseType.POSTGRE_SQL == getDataBaseType();
}
public static boolean isSqlServer() {
return DataBaseType.SQL_SERVER == getDataBaseType();
}
public static String findInSet(Object var1, String var2) {
DataBaseType dataBasyType = getDataBaseType();
String var = Convert.toStr(var1);
if (dataBasyType == DataBaseType.SQL_SERVER) {
// charindex(',100,' , ',0,100,101,') <> 0
return "charindex('," + var + ",' , ','+" + var2 + "+',') <> 0";
} else if (dataBasyType == DataBaseType.POSTGRE_SQL) {
// (select position(',100,' in ',0,100,101,')) <> 0
return "(select position('," + var + ",' in ','||" + var2 + "||',')) <> 0";
} else if (dataBasyType == DataBaseType.ORACLE) {
// instr(',0,100,101,' , ',100,') <> 0
return "instr(','||" + var2 + "||',' , '," + var + ",') <> 0";
}
// find_in_set(100 , '0,100,101')
return "find_in_set(" + var + " , " + var2 + ") <> 0";
}
}

View File

@ -1,11 +1,11 @@
package com.ruoyi.common.helper;
import cn.dev33.satoken.context.SaHolder;
import cn.dev33.satoken.context.model.SaStorage;
import cn.hutool.core.util.ObjectUtil;
import com.ruoyi.common.utils.ServletUtils;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.Map;
@ -33,11 +33,11 @@ public class DataPermissionHelper {
}
public static Map<String, Object> getContext() {
HttpServletRequest request = ServletUtils.getRequest();
Object attribute = request.getAttribute(DATA_PERMISSION_KEY);
SaStorage saStorage = SaHolder.getStorage();
Object attribute = saStorage.get(DATA_PERMISSION_KEY);
if (ObjectUtil.isNull(attribute)) {
request.setAttribute(DATA_PERMISSION_KEY, new HashMap<>());
attribute = request.getAttribute(DATA_PERMISSION_KEY);
saStorage.set(DATA_PERMISSION_KEY, new HashMap<>());
attribute = saStorage.get(DATA_PERMISSION_KEY);
}
if (attribute instanceof Map) {
return (Map<String, Object>) attribute;

View File

@ -1,5 +1,6 @@
package com.ruoyi.common.helper;
import cn.dev33.satoken.context.SaHolder;
import cn.dev33.satoken.stp.StpUtil;
import cn.hutool.core.util.ObjectUtil;
import com.ruoyi.common.constant.UserConstants;
@ -13,7 +14,7 @@ import lombok.NoArgsConstructor;
/**
* 登录鉴权助手
*
*
* user_type 为 用户类型 同一个用户表 可以有多种用户类型 例如 pc,app
* deivce 为 设备类型 同一个用户类型 可以有 多种设备类型 例如 web,ios
* 可以组成 用户类型与设备类型多对多的 权限灵活控制
@ -29,15 +30,13 @@ public class LoginHelper {
public static final String JOIN_CODE = ":";
public static final String LOGIN_USER_KEY = "loginUser";
private static final ThreadLocal<LoginUser> LOGIN_CACHE = new ThreadLocal<>();
/**
* 登录系统
*
* @param loginUser 登录用户信息
*/
public static void login(LoginUser loginUser) {
LOGIN_CACHE.set(loginUser);
SaHolder.getStorage().set(LOGIN_USER_KEY, loginUser);
StpUtil.login(loginUser.getLoginId());
setLoginUser(loginUser);
}
@ -49,7 +48,7 @@ public class LoginHelper {
* @param loginUser 登录用户信息
*/
public static void loginByDevice(LoginUser loginUser, DeviceType deviceType) {
LOGIN_CACHE.set(loginUser);
SaHolder.getStorage().set(LOGIN_USER_KEY, loginUser);
StpUtil.login(loginUser.getLoginId(), deviceType.getDevice());
setLoginUser(loginUser);
}
@ -65,18 +64,13 @@ public class LoginHelper {
* 获取用户(多级缓存)
*/
public static LoginUser getLoginUser() {
LoginUser loginUser = LOGIN_CACHE.get();
LoginUser loginUser = (LoginUser) SaHolder.getStorage().get(LOGIN_USER_KEY);
if (loginUser != null) {
return loginUser;
}
return (LoginUser) StpUtil.getTokenSession().get(LOGIN_USER_KEY);
}
/**
* 清除一级缓存 防止内存问题
*/
public static void clearCache() {
LOGIN_CACHE.remove();
loginUser = (LoginUser) StpUtil.getTokenSession().get(LOGIN_USER_KEY);
SaHolder.getStorage().set(LOGIN_USER_KEY, loginUser);
return loginUser;
}
/**

View File

@ -27,9 +27,9 @@ public class SensitiveJsonSerializer extends JsonSerializer<String> implements C
public void serialize(String value, JsonGenerator gen, SerializerProvider serializers) throws IOException {
SensitiveService sensitiveService = SpringUtils.getBean(SensitiveService.class);
if (sensitiveService.isSensitive()) {
gen.writeString(value);
} else {
gen.writeString(strategy.desensitizer().apply(value));
} else {
gen.writeString(value);
}
}

View File

@ -1,15 +1,20 @@
package com.ruoyi.common.utils;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.lang.SimpleCache;
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 cn.hutool.core.util.StrUtil;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import org.springframework.cglib.beans.BeanCopier;
import org.springframework.cglib.beans.BeanMap;
import org.springframework.cglib.core.Converter;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* bean深拷贝工具(基于 cglib 性能优异)
@ -37,7 +42,8 @@ public class BeanCopyUtils {
if (ObjectUtil.isNull(desc)) {
return null;
}
return CglibUtil.copy(source, desc);
final V target = ReflectUtil.newInstanceIfPossible(desc);
return copy(source, target);
}
/**
@ -54,7 +60,8 @@ public class BeanCopyUtils {
if (ObjectUtil.isNull(desc)) {
return null;
}
CglibUtil.copy(source, desc);
BeanCopier beanCopier = BeanCopierCache.INSTANCE.get(source.getClass(), desc.getClass(), null);
beanCopier.copy(source, desc, null);
return desc;
}
@ -72,7 +79,11 @@ public class BeanCopyUtils {
if (CollUtil.isEmpty(sourceList)) {
return CollUtil.newArrayList();
}
return CglibUtil.copyList(sourceList, () -> ReflectUtil.newInstanceIfPossible(desc));
return sourceList.stream().map(source -> {
V target = ReflectUtil.newInstanceIfPossible(desc);
copy(source, target);
return target;
}).collect(Collectors.toList());
}
/**
@ -81,11 +92,12 @@ public class BeanCopyUtils {
* @param bean 数据来源实体
* @return map对象
*/
@SuppressWarnings("unchecked")
public static <T> Map<String, Object> copyToMap(T bean) {
if (ObjectUtil.isNull(bean)) {
return null;
}
return CglibUtil.toMap(bean);
return BeanMap.create(bean);
}
/**
@ -102,7 +114,8 @@ public class BeanCopyUtils {
if (ObjectUtil.isNull(beanClass)) {
return null;
}
return CglibUtil.toBean(map, beanClass);
T bean = ReflectUtil.newInstanceIfPossible(beanClass);
return mapToBean(map, bean);
}
/**
@ -119,6 +132,54 @@ public class BeanCopyUtils {
if (ObjectUtil.isNull(bean)) {
return null;
}
return CglibUtil.fillBean(map, bean);
BeanMap.create(bean).putAll(map);
return bean;
}
/**
* BeanCopier属性缓存<br>
* 缓存用于防止多次反射造成的性能问题
*
* @author Looly
* @since 5.4.1
*/
public enum BeanCopierCache {
/**
* BeanCopier属性缓存单例
*/
INSTANCE;
private final SimpleCache<String, BeanCopier> cache = new SimpleCache<>();
/**
* 获得类与转换器生成的key在{@link BeanCopier}的Map中对应的元素
*
* @param srcClass 源Bean的类
* @param targetClass 目标Bean的类
* @param converter 转换器
* @return Map中对应的BeanCopier
*/
public BeanCopier get(Class<?> srcClass, Class<?> targetClass, Converter converter) {
final String key = genKey(srcClass, targetClass, converter);
return cache.get(key, () -> BeanCopier.create(srcClass, targetClass, converter != null));
}
/**
* 获得类与转换器生成的key
*
* @param srcClass 源Bean的类
* @param targetClass 目标Bean的类
* @param converter 转换器
* @return 属性名和Map映射的key
*/
private String genKey(Class<?> srcClass, Class<?> targetClass, Converter converter) {
final StringBuilder key = StrUtil.builder()
.append(srcClass.getName()).append('#').append(targetClass.getName());
if(null != converter){
key.append('#').append(converter.getClass().getName());
}
return key.toString();
}
}
}

View File

@ -22,17 +22,17 @@ import java.util.Date;
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public class DateUtils extends org.apache.commons.lang3.time.DateUtils {
public static String YYYY = "yyyy";
public static final String YYYY = "yyyy";
public static String YYYY_MM = "yyyy-MM";
public static final String YYYY_MM = "yyyy-MM";
public static String YYYY_MM_DD = "yyyy-MM-dd";
public static final String YYYY_MM_DD = "yyyy-MM-dd";
public static String YYYYMMDDHHMMSS = "yyyyMMddHHmmss";
public static final String YYYYMMDDHHMMSS = "yyyyMMddHHmmss";
public static String YYYY_MM_DD_HH_MM_SS = "yyyy-MM-dd HH:mm:ss";
public static final String YYYY_MM_DD_HH_MM_SS = "yyyy-MM-dd HH:mm:ss";
private static String[] parsePatterns = {
private static final String[] PARSE_PATTERNS = {
"yyyy-MM-dd", "yyyy-MM-dd HH:mm:ss", "yyyy-MM-dd HH:mm", "yyyy-MM",
"yyyy/MM/dd", "yyyy/MM/dd HH:mm:ss", "yyyy/MM/dd HH:mm", "yyyy/MM",
"yyyy.MM.dd", "yyyy.MM.dd HH:mm:ss", "yyyy.MM.dd HH:mm", "yyyy.MM"};
@ -55,27 +55,27 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils {
return dateTimeNow(YYYY_MM_DD);
}
public static final String getTime() {
public static String getTime() {
return dateTimeNow(YYYY_MM_DD_HH_MM_SS);
}
public static final String dateTimeNow() {
public static String dateTimeNow() {
return dateTimeNow(YYYYMMDDHHMMSS);
}
public static final String dateTimeNow(final String format) {
public static String dateTimeNow(final String format) {
return parseDateToStr(format, new Date());
}
public static final String dateTime(final Date date) {
public static String dateTime(final Date date) {
return parseDateToStr(YYYY_MM_DD, date);
}
public static final String parseDateToStr(final String format, final Date date) {
public static String parseDateToStr(final String format, final Date date) {
return new SimpleDateFormat(format).format(date);
}
public static final Date dateTime(final String format, final String ts) {
public static Date dateTime(final String format, final String ts) {
try {
return new SimpleDateFormat(format).parse(ts);
} catch (ParseException e) {
@ -86,7 +86,7 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils {
/**
* 日期路径 即年/月/日 如2018/08/08
*/
public static final String datePath() {
public static String datePath() {
Date now = new Date();
return DateFormatUtils.format(now, "yyyy/MM/dd");
}
@ -94,7 +94,7 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils {
/**
* 日期路径 即年/月/日 如20180808
*/
public static final String dateTime() {
public static String dateTime() {
Date now = new Date();
return DateFormatUtils.format(now, "yyyyMMdd");
}
@ -107,7 +107,7 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils {
return null;
}
try {
return parseDate(str.toString(), parsePatterns);
return parseDate(str.toString(), PARSE_PATTERNS);
} catch (ParseException e) {
return null;
}
@ -124,8 +124,7 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils {
/**
* 计算相差天数
*/
public static int differentDaysByMillisecond(Date date1, Date date2)
{
public static int differentDaysByMillisecond(Date date1, Date date2) {
return Math.abs((int) ((date2.getTime() - date1.getTime()) / (1000 * 3600 * 24)));
}

View File

@ -0,0 +1,468 @@
package com.ruoyi.common.utils.email;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.io.IoUtil;
import cn.hutool.core.map.MapUtil;
import cn.hutool.core.util.CharUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.extra.mail.*;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.spring.SpringUtils;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import javax.mail.Authenticator;
import javax.mail.Session;
import java.io.File;
import java.io.InputStream;
import java.util.Collection;
import java.util.List;
import java.util.Map;
/**
* 邮件工具类
*/
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public class MailUtils {
private static final MailAccount ACCOUNT = SpringUtils.getBean(MailAccount.class);
/**
* 获取邮件发送实例
*/
public static MailAccount getMailAccount() {
return ACCOUNT;
}
/**
* 获取邮件发送实例 (自定义发送人以及授权码)
*
* @param user 发送人
* @param pass 授权码
*/
public static MailAccount getMailAccount(String from, String user, String pass) {
ACCOUNT.setFrom(StringUtils.blankToDefault(from, ACCOUNT.getFrom()));
ACCOUNT.setUser(StringUtils.blankToDefault(user, ACCOUNT.getUser()));
ACCOUNT.setPass(StringUtils.blankToDefault(pass, ACCOUNT.getPass()));
return ACCOUNT;
}
/**
* 使用配置文件中设置的账户发送文本邮件,发送给单个或多个收件人<br>
* 多个收件人可以使用逗号“,”分隔,也可以通过分号“;”分隔
*
* @param to 收件人
* @param subject 标题
* @param content 正文
* @param files 附件列表
* @return message-id
* @since 3.2.0
*/
public static String sendText(String to, String subject, String content, File... files) {
return send(to, subject, content, false, files);
}
/**
* 使用配置文件中设置的账户发送HTML邮件发送给单个或多个收件人<br>
* 多个收件人可以使用逗号“,”分隔,也可以通过分号“;”分隔
*
* @param to 收件人
* @param subject 标题
* @param content 正文
* @param files 附件列表
* @return message-id
* @since 3.2.0
*/
public static String sendHtml(String to, String subject, String content, File... files) {
return send(to, subject, content, true, files);
}
/**
* 使用配置文件中设置的账户发送邮件,发送单个或多个收件人<br>
* 多个收件人可以使用逗号“,”分隔,也可以通过分号“;”分隔
*
* @param to 收件人
* @param subject 标题
* @param content 正文
* @param isHtml 是否为HTML
* @param files 附件列表
* @return message-id
*/
public static String send(String to, String subject, String content, boolean isHtml, File... files) {
return send(splitAddress(to), subject, content, isHtml, files);
}
/**
* 使用配置文件中设置的账户发送邮件,发送单个或多个收件人<br>
* 多个收件人、抄送人、密送人可以使用逗号“,”分隔,也可以通过分号“;”分隔
*
* @param to 收件人,可以使用逗号“,”分隔,也可以通过分号“;”分隔
* @param cc 抄送人,可以使用逗号“,”分隔,也可以通过分号“;”分隔
* @param bcc 密送人,可以使用逗号“,”分隔,也可以通过分号“;”分隔
* @param subject 标题
* @param content 正文
* @param isHtml 是否为HTML
* @param files 附件列表
* @return message-id
* @since 4.0.3
*/
public static String send(String to, String cc, String bcc, String subject, String content, boolean isHtml, File... files) {
return send(splitAddress(to), splitAddress(cc), splitAddress(bcc), subject, content, isHtml, files);
}
/**
* 使用配置文件中设置的账户发送文本邮件,发送给多人
*
* @param tos 收件人列表
* @param subject 标题
* @param content 正文
* @param files 附件列表
* @return message-id
*/
public static String sendText(Collection<String> tos, String subject, String content, File... files) {
return send(tos, subject, content, false, files);
}
/**
* 使用配置文件中设置的账户发送HTML邮件发送给多人
*
* @param tos 收件人列表
* @param subject 标题
* @param content 正文
* @param files 附件列表
* @return message-id
* @since 3.2.0
*/
public static String sendHtml(Collection<String> tos, String subject, String content, File... files) {
return send(tos, subject, content, true, files);
}
/**
* 使用配置文件中设置的账户发送邮件,发送给多人
*
* @param tos 收件人列表
* @param subject 标题
* @param content 正文
* @param isHtml 是否为HTML
* @param files 附件列表
* @return message-id
*/
public static String send(Collection<String> tos, String subject, String content, boolean isHtml, File... files) {
return send(tos, null, null, subject, content, isHtml, files);
}
/**
* 使用配置文件中设置的账户发送邮件,发送给多人
*
* @param tos 收件人列表
* @param ccs 抄送人列表可以为null或空
* @param bccs 密送人列表可以为null或空
* @param subject 标题
* @param content 正文
* @param isHtml 是否为HTML
* @param files 附件列表
* @return message-id
* @since 4.0.3
*/
public static String send(Collection<String> tos, Collection<String> ccs, Collection<String> bccs, String subject, String content, boolean isHtml, File... files) {
return send(getMailAccount(), true, tos, ccs, bccs, subject, content, null, isHtml, files);
}
// ------------------------------------------------------------------------------------------------------------------------------- Custom MailAccount
/**
* 发送邮件给多人
*
* @param mailAccount 邮件认证对象
* @param to 收件人,多个收件人逗号或者分号隔开
* @param subject 标题
* @param content 正文
* @param isHtml 是否为HTML格式
* @param files 附件列表
* @return message-id
* @since 3.2.0
*/
public static String send(MailAccount mailAccount, String to, String subject, String content, boolean isHtml, File... files) {
return send(mailAccount, splitAddress(to), subject, content, isHtml, files);
}
/**
* 发送邮件给多人
*
* @param mailAccount 邮件帐户信息
* @param tos 收件人列表
* @param subject 标题
* @param content 正文
* @param isHtml 是否为HTML格式
* @param files 附件列表
* @return message-id
*/
public static String send(MailAccount mailAccount, Collection<String> tos, String subject, String content, boolean isHtml, File... files) {
return send(mailAccount, tos, null, null, subject, content, isHtml, files);
}
/**
* 发送邮件给多人
*
* @param mailAccount 邮件帐户信息
* @param tos 收件人列表
* @param ccs 抄送人列表可以为null或空
* @param bccs 密送人列表可以为null或空
* @param subject 标题
* @param content 正文
* @param isHtml 是否为HTML格式
* @param files 附件列表
* @return message-id
* @since 4.0.3
*/
public static String send(MailAccount mailAccount, Collection<String> tos, Collection<String> ccs, Collection<String> bccs, String subject, String content, boolean isHtml, File... files) {
return send(mailAccount, false, tos, ccs, bccs, subject, content, null, isHtml, files);
}
/**
* 使用配置文件中设置的账户发送HTML邮件发送给单个或多个收件人<br>
* 多个收件人可以使用逗号“,”分隔,也可以通过分号“;”分隔
*
* @param to 收件人
* @param subject 标题
* @param content 正文
* @param imageMap 图片与占位符占位符格式为cid:$IMAGE_PLACEHOLDER
* @param files 附件列表
* @return message-id
* @since 3.2.0
*/
public static String sendHtml(String to, String subject, String content, Map<String, InputStream> imageMap, File... files) {
return send(to, subject, content, imageMap, true, files);
}
/**
* 使用配置文件中设置的账户发送邮件,发送单个或多个收件人<br>
* 多个收件人可以使用逗号“,”分隔,也可以通过分号“;”分隔
*
* @param to 收件人
* @param subject 标题
* @param content 正文
* @param imageMap 图片与占位符占位符格式为cid:$IMAGE_PLACEHOLDER
* @param isHtml 是否为HTML
* @param files 附件列表
* @return message-id
*/
public static String send(String to, String subject, String content, Map<String, InputStream> imageMap, boolean isHtml, File... files) {
return send(splitAddress(to), subject, content, imageMap, isHtml, files);
}
/**
* 使用配置文件中设置的账户发送邮件,发送单个或多个收件人<br>
* 多个收件人、抄送人、密送人可以使用逗号“,”分隔,也可以通过分号“;”分隔
*
* @param to 收件人,可以使用逗号“,”分隔,也可以通过分号“;”分隔
* @param cc 抄送人,可以使用逗号“,”分隔,也可以通过分号“;”分隔
* @param bcc 密送人,可以使用逗号“,”分隔,也可以通过分号“;”分隔
* @param subject 标题
* @param content 正文
* @param imageMap 图片与占位符占位符格式为cid:$IMAGE_PLACEHOLDER
* @param isHtml 是否为HTML
* @param files 附件列表
* @return message-id
* @since 4.0.3
*/
public static String send(String to, String cc, String bcc, String subject, String content, Map<String, InputStream> imageMap, boolean isHtml, File... files) {
return send(splitAddress(to), splitAddress(cc), splitAddress(bcc), subject, content, imageMap, isHtml, files);
}
/**
* 使用配置文件中设置的账户发送HTML邮件发送给多人
*
* @param tos 收件人列表
* @param subject 标题
* @param content 正文
* @param imageMap 图片与占位符占位符格式为cid:$IMAGE_PLACEHOLDER
* @param files 附件列表
* @return message-id
* @since 3.2.0
*/
public static String sendHtml(Collection<String> tos, String subject, String content, Map<String, InputStream> imageMap, File... files) {
return send(tos, subject, content, imageMap, true, files);
}
/**
* 使用配置文件中设置的账户发送邮件,发送给多人
*
* @param tos 收件人列表
* @param subject 标题
* @param content 正文
* @param imageMap 图片与占位符占位符格式为cid:$IMAGE_PLACEHOLDER
* @param isHtml 是否为HTML
* @param files 附件列表
* @return message-id
*/
public static String send(Collection<String> tos, String subject, String content, Map<String, InputStream> imageMap, boolean isHtml, File... files) {
return send(tos, null, null, subject, content, imageMap, isHtml, files);
}
/**
* 使用配置文件中设置的账户发送邮件,发送给多人
*
* @param tos 收件人列表
* @param ccs 抄送人列表可以为null或空
* @param bccs 密送人列表可以为null或空
* @param subject 标题
* @param content 正文
* @param imageMap 图片与占位符占位符格式为cid:$IMAGE_PLACEHOLDER
* @param isHtml 是否为HTML
* @param files 附件列表
* @return message-id
* @since 4.0.3
*/
public static String send(Collection<String> tos, Collection<String> ccs, Collection<String> bccs, String subject, String content, Map<String, InputStream> imageMap, boolean isHtml, File... files) {
return send(getMailAccount(), true, tos, ccs, bccs, subject, content, imageMap, isHtml, files);
}
// ------------------------------------------------------------------------------------------------------------------------------- Custom MailAccount
/**
* 发送邮件给多人
*
* @param mailAccount 邮件认证对象
* @param to 收件人,多个收件人逗号或者分号隔开
* @param subject 标题
* @param content 正文
* @param imageMap 图片与占位符占位符格式为cid:$IMAGE_PLACEHOLDER
* @param isHtml 是否为HTML格式
* @param files 附件列表
* @return message-id
* @since 3.2.0
*/
public static String send(MailAccount mailAccount, String to, String subject, String content, Map<String, InputStream> imageMap, boolean isHtml, File... files) {
return send(mailAccount, splitAddress(to), subject, content, imageMap, isHtml, files);
}
/**
* 发送邮件给多人
*
* @param mailAccount 邮件帐户信息
* @param tos 收件人列表
* @param subject 标题
* @param content 正文
* @param imageMap 图片与占位符占位符格式为cid:$IMAGE_PLACEHOLDER
* @param isHtml 是否为HTML格式
* @param files 附件列表
* @return message-id
* @since 4.6.3
*/
public static String send(MailAccount mailAccount, Collection<String> tos, String subject, String content, Map<String, InputStream> imageMap, boolean isHtml, File... files) {
return send(mailAccount, tos, null, null, subject, content, imageMap, isHtml, files);
}
/**
* 发送邮件给多人
*
* @param mailAccount 邮件帐户信息
* @param tos 收件人列表
* @param ccs 抄送人列表可以为null或空
* @param bccs 密送人列表可以为null或空
* @param subject 标题
* @param content 正文
* @param imageMap 图片与占位符占位符格式为cid:$IMAGE_PLACEHOLDER
* @param isHtml 是否为HTML格式
* @param files 附件列表
* @return message-id
* @since 4.6.3
*/
public static String send(MailAccount mailAccount, Collection<String> tos, Collection<String> ccs, Collection<String> bccs, String subject, String content, Map<String, InputStream> imageMap,
boolean isHtml, File... files) {
return send(mailAccount, false, tos, ccs, bccs, subject, content, imageMap, isHtml, files);
}
/**
* 根据配置文件,获取邮件客户端会话
*
* @param mailAccount 邮件账户配置
* @param isSingleton 是否单例(全局共享会话)
* @return {@link Session}
* @since 5.5.7
*/
public static Session getSession(MailAccount mailAccount, boolean isSingleton) {
Authenticator authenticator = null;
if (mailAccount.isAuth()) {
authenticator = new UserPassAuthenticator(mailAccount.getUser(), mailAccount.getPass());
}
return isSingleton ? Session.getDefaultInstance(mailAccount.getSmtpProps(), authenticator) //
: Session.getInstance(mailAccount.getSmtpProps(), authenticator);
}
// ------------------------------------------------------------------------------------------------------------------------ Private method start
/**
* 发送邮件给多人
*
* @param mailAccount 邮件帐户信息
* @param useGlobalSession 是否全局共享Session
* @param tos 收件人列表
* @param ccs 抄送人列表可以为null或空
* @param bccs 密送人列表可以为null或空
* @param subject 标题
* @param content 正文
* @param imageMap 图片与占位符占位符格式为cid:${cid}
* @param isHtml 是否为HTML格式
* @param files 附件列表
* @return message-id
* @since 4.6.3
*/
private static String send(MailAccount mailAccount, boolean useGlobalSession, Collection<String> tos, Collection<String> ccs, Collection<String> bccs, String subject, String content,
Map<String, InputStream> imageMap, boolean isHtml, File... files) {
final Mail mail = Mail.create(mailAccount).setUseGlobalSession(useGlobalSession);
// 可选抄送人
if (CollUtil.isNotEmpty(ccs)) {
mail.setCcs(ccs.toArray(new String[0]));
}
// 可选密送人
if (CollUtil.isNotEmpty(bccs)) {
mail.setBccs(bccs.toArray(new String[0]));
}
mail.setTos(tos.toArray(new String[0]));
mail.setTitle(subject);
mail.setContent(content);
mail.setHtml(isHtml);
mail.setFiles(files);
// 图片
if (MapUtil.isNotEmpty(imageMap)) {
for (Map.Entry<String, InputStream> entry : imageMap.entrySet()) {
mail.addImage(entry.getKey(), entry.getValue());
// 关闭流
IoUtil.close(entry.getValue());
}
}
return mail.send();
}
/**
* 将多个联系人转为列表,分隔符为逗号或者分号
*
* @param addresses 多个联系人如果为空返回null
* @return 联系人列表
*/
private static List<String> splitAddress(String addresses) {
if (StrUtil.isBlank(addresses)) {
return null;
}
List<String> result;
if (StrUtil.contains(addresses, CharUtil.COMMA)) {
result = StrUtil.splitTrim(addresses, CharUtil.COMMA);
} else if (StrUtil.contains(addresses, ';')) {
result = StrUtil.splitTrim(addresses, ';');
} else {
result = CollUtil.newArrayList(addresses);
}
return result;
}
// ------------------------------------------------------------------------------------------------------------------------ Private method end
}

View File

@ -0,0 +1,40 @@
package com.ruoyi.common.utils.file;
/**
* 媒体类型工具类
*
* @author ruoyi
*/
public class MimeTypeUtils {
public static final String IMAGE_PNG = "image/png";
public static final String IMAGE_JPG = "image/jpg";
public static final String IMAGE_JPEG = "image/jpeg";
public static final String IMAGE_BMP = "image/bmp";
public static final String IMAGE_GIF = "image/gif";
public static final String[] IMAGE_EXTENSION = {"bmp", "gif", "jpg", "jpeg", "png"};
public static final String[] FLASH_EXTENSION = {"swf", "flv"};
public static final String[] MEDIA_EXTENSION = {"swf", "flv", "mp3", "wav", "wma", "wmv", "mid", "avi", "mpg",
"asf", "rm", "rmvb"};
public static final String[] VIDEO_EXTENSION = {"mp4", "avi", "rmvb"};
public static final String[] DEFAULT_ALLOWED_EXTENSION = {
// 图片
"bmp", "gif", "jpg", "jpeg", "png",
// word excel powerpoint
"doc", "docx", "xls", "xlsx", "ppt", "pptx", "html", "htm", "txt",
// 压缩文件
"rar", "zip", "gz", "bz2",
// 视频格式
"mp4", "avi", "rmvb",
// pdf
"pdf"};
}

View File

@ -1,9 +1,17 @@
package com.ruoyi.common.utils.poi;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.io.resource.ClassPathResource;
import cn.hutool.core.util.IdUtil;
import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.ExcelWriter;
import com.alibaba.excel.write.builder.ExcelWriterSheetBuilder;
import com.alibaba.excel.write.metadata.WriteSheet;
import com.alibaba.excel.write.metadata.fill.FillConfig;
import com.alibaba.excel.write.metadata.fill.FillWrapper;
import com.alibaba.excel.write.style.column.LongestMatchColumnWidthStyleStrategy;
import com.ruoyi.common.convert.ExcelBigNumberConvert;
import com.ruoyi.common.excel.CellMergeStrategy;
import com.ruoyi.common.excel.DefaultExcelListener;
import com.ruoyi.common.excel.ExcelListener;
import com.ruoyi.common.excel.ExcelResult;
@ -16,7 +24,10 @@ import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
import java.util.Collection;
import java.util.List;
import java.util.Map;
/**
* Excel相关处理
@ -69,27 +80,125 @@ public class ExcelUtil {
*
* @param list 导出数据集合
* @param sheetName 工作表的名称
* @return 结果
* @param clazz 实体类
* @param response 响应体
*/
public static <T> void exportExcel(List<T> list, String sheetName, Class<T> clazz, HttpServletResponse response) {
exportExcel(list, sheetName, clazz, false, response);
}
/**
* 导出excel
*
* @param list 导出数据集合
* @param sheetName 工作表的名称
* @param clazz 实体类
* @param merge 是否合并单元格
* @param response 响应体
*/
public static <T> void exportExcel(List<T> list, String sheetName, Class<T> clazz, boolean merge, HttpServletResponse response) {
try {
String filename = encodingFilename(sheetName);
response.reset();
FileUtils.setAttachmentResponseHeader(response, filename);
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=UTF-8");
resetResponse(sheetName, response);
ServletOutputStream os = response.getOutputStream();
EasyExcel.write(os, clazz)
ExcelWriterSheetBuilder builder = EasyExcel.write(os, clazz)
.autoCloseStream(false)
// 自动适配
.registerWriteHandler(new LongestMatchColumnWidthStyleStrategy())
// 大数值自动转换 防止失真
.registerConverter(new ExcelBigNumberConvert())
.sheet(sheetName).doWrite(list);
.sheet(sheetName);
if (merge) {
// 合并处理器
builder.registerWriteHandler(new CellMergeStrategy(list, true));
}
builder.doWrite(list);
} catch (IOException e) {
throw new RuntimeException("导出Excel异常");
}
}
/**
* 单表多数据模板导出 模板格式为 {.属性}
*
* @param filename 文件名
* @param templatePath 模板路径 resource 目录下的路径包括模板文件名
* 例如: excel/temp.xlsx
* 重点: 模板文件必须放置到启动类对应的 resource 目录下
* @param data 模板需要的数据
*/
public static void exportTemplate(List<Object> data, String filename, String templatePath, HttpServletResponse response) {
try {
resetResponse(filename, response);
ClassPathResource templateResource = new ClassPathResource(templatePath);
ExcelWriter excelWriter = EasyExcel.write(response.getOutputStream())
.withTemplate(templateResource.getStream())
.autoCloseStream(false)
// 大数值自动转换 防止失真
.registerConverter(new ExcelBigNumberConvert())
.build();
WriteSheet writeSheet = EasyExcel.writerSheet().build();
if (CollUtil.isEmpty(data)) {
throw new IllegalArgumentException("数据为空");
}
// 单表多数据导出 模板格式为 {.属性}
for (Object d : data) {
excelWriter.fill(d, writeSheet);
}
excelWriter.finish();
} catch (IOException e) {
throw new RuntimeException("导出Excel异常");
}
}
/**
* 多表多数据模板导出 模板格式为 {key.属性}
*
* @param filename 文件名
* @param templatePath 模板路径 resource 目录下的路径包括模板文件名
* 例如: excel/temp.xlsx
* 重点: 模板文件必须放置到启动类对应的 resource 目录下
* @param data 模板需要的数据
*/
public static void exportTemplateMultiList(Map<String, Object> data, String filename, String templatePath, HttpServletResponse response) {
try {
resetResponse(filename, response);
ClassPathResource templateResource = new ClassPathResource(templatePath);
ExcelWriter excelWriter = EasyExcel.write(response.getOutputStream())
.withTemplate(templateResource.getStream())
.autoCloseStream(false)
// 大数值自动转换 防止失真
.registerConverter(new ExcelBigNumberConvert())
.build();
WriteSheet writeSheet = EasyExcel.writerSheet().build();
if (CollUtil.isEmpty(data)) {
throw new IllegalArgumentException("数据为空");
}
for (Map.Entry<String, Object> map : data.entrySet()) {
// 设置列表后续还有数据
FillConfig fillConfig = FillConfig.builder().forceNewRow(Boolean.TRUE).build();
if (map.getValue() instanceof Collection) {
// 多表导出必须使用 FillWrapper
excelWriter.fill(new FillWrapper(map.getKey(), (Collection<?>) map.getValue()), fillConfig, writeSheet);
} else {
excelWriter.fill(map.getValue(), writeSheet);
}
}
excelWriter.finish();
} catch (IOException e) {
throw new RuntimeException("导出Excel异常");
}
}
/**
* 重置响应体
*/
private static void resetResponse(String sheetName, HttpServletResponse response) throws UnsupportedEncodingException {
String filename = encodingFilename(sheetName);
response.reset();
FileUtils.setAttachmentResponseHeader(response, filename);
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=UTF-8");
}
/**
* 解析导出值 0=男,1=女,2=未知
*
@ -103,7 +212,7 @@ public class ExcelUtil {
String[] convertSource = converterExp.split(",");
for (String item : convertSource) {
String[] itemArray = item.split("=");
if (StringUtils.containsAny(separator, propertyValue)) {
if (StringUtils.containsAny(propertyValue, separator)) {
for (String value : propertyValue.split(separator)) {
if (itemArray[0].equals(value)) {
propertyString.append(itemArray[1] + separator);
@ -132,7 +241,7 @@ public class ExcelUtil {
String[] convertSource = converterExp.split(",");
for (String item : convertSource) {
String[] itemArray = item.split("=");
if (StringUtils.containsAny(separator, propertyValue)) {
if (StringUtils.containsAny(propertyValue, separator)) {
for (String value : propertyValue.split(separator)) {
if (itemArray[1].equals(value)) {
propertyString.append(itemArray[0] + separator);

View File

@ -6,11 +6,11 @@ import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import org.redisson.api.*;
import java.time.Duration;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.TimeUnit;
import java.util.function.Consumer;
/**
@ -107,7 +107,7 @@ public class RedisUtils {
} catch (Exception e) {
long timeToLive = bucket.remainTimeToLive();
bucket.set(value);
bucket.expire(timeToLive, TimeUnit.MILLISECONDS);
bucket.expire(Duration.ofMillis(timeToLive));
}
} else {
bucket.set(value);
@ -119,13 +119,12 @@ public class RedisUtils {
*
* @param key 缓存的键值
* @param value 缓存的值
* @param timeout 时间
* @param timeUnit 时间颗粒度
* @param duration 时间
*/
public static <T> void setCacheObject(final String key, final T value, final long timeout, final TimeUnit timeUnit) {
public static <T> void setCacheObject(final String key, final T value, final Duration duration) {
RBucket<T> result = CLIENT.getBucket(key);
result.set(value);
result.expire(timeout, timeUnit);
result.expire(duration);
}
/**
@ -149,20 +148,19 @@ public class RedisUtils {
* @return true=设置成功false=设置失败
*/
public static boolean expire(final String key, final long timeout) {
return expire(key, timeout, TimeUnit.SECONDS);
return expire(key, Duration.ofSeconds(timeout));
}
/**
* 设置有效时间
*
* @param key Redis键
* @param timeout 超时时间
* @param unit 时间单位
* @param key Redis键
* @param duration 超时时间
* @return true=设置成功false=设置失败
*/
public static boolean expire(final String key, final long timeout, final TimeUnit unit) {
public static boolean expire(final String key, final Duration duration) {
RBucket rBucket = CLIENT.getBucket(key);
return rBucket.expire(timeout, unit);
return rBucket.expire(duration);
}
/**
@ -366,6 +364,50 @@ public class RedisUtils {
return rMap.getAll(hKeys);
}
/**
* 设置原子值
*
* @param key Redis键
* @param value 值
*/
public static void setAtomicValue(String key, long value) {
RAtomicLong atomic = CLIENT.getAtomicLong(key);
atomic.set(value);
}
/**
* 获取原子值
*
* @param key Redis键
* @return 当前值
*/
public static long getAtomicValue(String key) {
RAtomicLong atomic = CLIENT.getAtomicLong(key);
return atomic.get();
}
/**
* 递增原子值
*
* @param key Redis键
* @return 当前值
*/
public static long incrAtomicValue(String key) {
RAtomicLong atomic = CLIENT.getAtomicLong(key);
return atomic.incrementAndGet();
}
/**
* 递减原子值
*
* @param key Redis键
* @return 当前值
*/
public static long decrAtomicValue(String key) {
RAtomicLong atomic = CLIENT.getAtomicLong(key);
return atomic.decrementAndGet();
}
/**
* 获得缓存的基本对象列表
*

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>ruoyi-vue-plus</artifactId>
<groupId>com.ruoyi</groupId>
<version>4.0.1</version>
<version>4.2.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
@ -23,6 +23,22 @@
<artifactId>ruoyi-common</artifactId>
</dependency>
<dependency>
<groupId>com.ruoyi</groupId>
<artifactId>ruoyi-sms</artifactId>
</dependency>
<!-- 短信 用哪个导入哪个依赖 -->
<!-- <dependency>-->
<!-- <groupId>com.aliyun</groupId>-->
<!-- <artifactId>dysmsapi20170525</artifactId>-->
<!-- </dependency>-->
<!-- <dependency>-->
<!-- <groupId>com.tencentcloudapi</groupId>-->
<!-- <artifactId>tencentcloud-sdk-java</artifactId>-->
<!-- </dependency>-->
</dependencies>
</project>

View File

@ -0,0 +1,48 @@
package com.ruoyi.demo.controller;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.utils.email.MailUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.RequiredArgsConstructor;
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 java.io.File;
/**
* 邮件发送案例
*
* @author Michelle.Chung
*/
@Validated
@Api(value = "邮件发送案例", tags = {"邮件发送案例"})
@RequiredArgsConstructor
@RestController
@RequestMapping("/demo/mail")
public class MailController {
@ApiOperation("发送邮件")
@GetMapping("/sendSimpleMessage")
public R<Void> sendSimpleMessage(@ApiParam("接收人") String to,
@ApiParam("标题") String subject,
@ApiParam("内容") String text) {
MailUtils.sendText(to, subject, text);
return R.ok();
}
@ApiOperation("发送邮件(带附件)")
@GetMapping("/sendMessageWithAttachment")
public R<Void> sendMessageWithAttachment(@ApiParam("接收人") String to,
@ApiParam("标题") String subject,
@ApiParam("内容") String text,
@ApiParam("附件路径") String filePath) {
MailUtils.sendText(to, subject, text, new File(filePath));
return R.ok();
}
}

View File

@ -12,7 +12,7 @@ import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.concurrent.TimeUnit;
import java.time.Duration;
/**
* spring-cache 演示案例
@ -87,7 +87,7 @@ public class RedisCacheController {
@GetMapping("/test6")
public R<Boolean> test6(String key, String value) {
RedisUtils.setCacheObject(key, value);
boolean flag = RedisUtils.expire(key, 10, TimeUnit.SECONDS);
boolean flag = RedisUtils.expire(key, Duration.ofSeconds(10));
System.out.println("***********" + flag);
try {
Thread.sleep(11 * 1000);

View File

@ -0,0 +1,72 @@
package com.ruoyi.demo.controller;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.utils.spring.SpringUtils;
import com.ruoyi.sms.config.properties.SmsProperties;
import com.ruoyi.sms.core.SmsTemplate;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.RequiredArgsConstructor;
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 java.util.HashMap;
import java.util.Map;
/**
* 短信演示案例
* 请先阅读文档 否则无法使用
*
* @author Lion Li
* @version 4.2.0
*/
@Validated
@Api(value = "短信演示案例", tags = {"短信演示案例"})
@RequiredArgsConstructor
@RestController
@RequestMapping("/demo/sms")
public class SmsController {
private final SmsProperties smsProperties;
// private final SmsTemplate smsTemplate; // 可以使用spring注入
// private final AliyunSmsTemplate smsTemplate; // 也可以注入某个厂家的模板工具
@ApiOperation("发送短信Aliyun")
@GetMapping("/sendAliyun")
public R<Object> sendAliyun(@ApiParam("电话号") String phones,
@ApiParam("模板ID") String templateId) {
if (!smsProperties.getEnabled()) {
return R.fail("当前系统没有开启短信功能!");
}
if (!SpringUtils.containsBean("aliyunSmsTemplate")) {
return R.fail("阿里云依赖未引入!");
}
SmsTemplate smsTemplate = SpringUtils.getBean(SmsTemplate.class);
Map<String, String> map = new HashMap<>(1);
map.put("code", "1234");
Object send = smsTemplate.send(phones, templateId, map);
return R.ok(send);
}
@ApiOperation("发送短信Tencent")
@GetMapping("/sendTencent")
public R<Object> sendTencent(@ApiParam("电话号") String phones,
@ApiParam("模板ID") String templateId) {
if (!smsProperties.getEnabled()) {
return R.fail("当前系统没有开启短信功能!");
}
if (!SpringUtils.containsBean("tencentSmsTemplate")) {
return R.fail("腾讯云依赖未引入!");
}
SmsTemplate smsTemplate = SpringUtils.getBean(SmsTemplate.class);
Map<String, String> map = new HashMap<>(1);
// map.put("2", "测试测试");
map.put("1", "1234");
Object send = smsTemplate.send(phones, templateId, map);
return R.ok(send);
}
}

View File

@ -45,7 +45,7 @@ public class TestBatchController extends BaseController {
List<TestDemo> list = new ArrayList<>();
for (int i = 0; i < 1000; i++) {
TestDemo testDemo = new TestDemo();
testDemo.setOrderNum(-1L);
testDemo.setOrderNum(-1);
testDemo.setTestKey("批量新增");
testDemo.setValue("测试新增");
list.add(testDemo);
@ -65,7 +65,7 @@ public class TestBatchController extends BaseController {
List<TestDemo> list = new ArrayList<>();
for (int i = 0; i < 1000; i++) {
TestDemo testDemo = new TestDemo();
testDemo.setOrderNum(-1L);
testDemo.setOrderNum(-1);
testDemo.setTestKey("批量新增");
testDemo.setValue("测试新增");
list.add(testDemo); }

View File

@ -29,6 +29,7 @@ import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.io.File;
import java.util.Arrays;
import java.util.List;
import java.util.concurrent.TimeUnit;
@ -70,7 +71,7 @@ public class TestDemoController extends BaseController {
@ApiOperation("导入测试-校验")
@ApiImplicitParams({
@ApiImplicitParam(name = "file", value = "导入文件", dataType = "java.io.File", required = true),
@ApiImplicitParam(name = "file", value = "导入文件", paramType = "query", dataTypeClass = File.class, required = true),
})
@Log(title = "测试单表", businessType = BusinessType.IMPORT)
@SaCheckPermission("demo:demo:import")
@ -117,7 +118,7 @@ public class TestDemoController extends BaseController {
@ApiOperation("新增测试单表")
@SaCheckPermission("demo:demo:add")
@Log(title = "测试单表", businessType = BusinessType.INSERT)
@RepeatSubmit(interval = 2, timeUnit = TimeUnit.SECONDS, message = "不允许重复提交")
@RepeatSubmit(interval = 2, timeUnit = TimeUnit.SECONDS, message = "{repeat.submit.message}")
@PostMapping()
public R<Void> add(@RequestBody TestDemoBo bo) {
// 使用校验工具对标 @Validated(AddGroup.class) 注解

View File

@ -0,0 +1,102 @@
package com.ruoyi.demo.controller;
import cn.hutool.core.collection.CollUtil;
import com.ruoyi.common.utils.poi.ExcelUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import lombok.Data;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* 测试Excel功能
*
* @author Lion Li
*/
@Api(value = "测试Excel功能", tags = {"测试Excel功能"})
@RestController
@RequestMapping("/demo/excel")
public class TestExcelController {
/**
* 单列表多数据
*/
@ApiOperation(value = "单列表多数据")
@GetMapping("/exportTemplateOne")
public void exportTemplateOne(HttpServletResponse response) {
Map<String,String> map = new HashMap<>();
map.put("title","单列表多数据");
map.put("test1","数据测试1");
map.put("test2","数据测试2");
map.put("test3","数据测试3");
map.put("test4","数据测试4");
map.put("testTest","666");
List<TestObj> list = new ArrayList<>();
list.add(new TestObj("单列表测试1", "列表测试1", "列表测试2", "列表测试3", "列表测试4"));
list.add(new TestObj("单列表测试2", "列表测试5", "列表测试6", "列表测试7", "列表测试8"));
list.add(new TestObj("单列表测试3", "列表测试9", "列表测试10", "列表测试11", "列表测试12"));
ExcelUtil.exportTemplate(CollUtil.newArrayList(map,list),"单列表.xlsx", "excel/单列表.xlsx", response);
}
/**
* 多列表多数据
*/
@ApiOperation(value = "多列表多数据")
@GetMapping("/exportTemplateMuliti")
public void exportTemplateMuliti(HttpServletResponse response) {
Map<String,String> map = new HashMap<>();
map.put("title1","标题1");
map.put("title2","标题2");
map.put("title3","标题3");
map.put("title4","标题4");
map.put("author","Lion Li");
List<TestObj1> list1 = new ArrayList<>();
list1.add(new TestObj1("list1测试1", "list1测试2", "list1测试3"));
list1.add(new TestObj1("list1测试4", "list1测试5", "list1测试6"));
list1.add(new TestObj1("list1测试7", "list1测试8", "list1测试9"));
List<TestObj1> list2 = new ArrayList<>();
list2.add(new TestObj1("list2测试1", "list2测试2", "list2测试3"));
list2.add(new TestObj1("list2测试4", "list2测试5", "list2测试6"));
List<TestObj1> list3 = new ArrayList<>();
list3.add(new TestObj1("list3测试1", "list3测试2", "list3测试3"));
List<TestObj1> list4 = new ArrayList<>();
list4.add(new TestObj1("list4测试1", "list4测试2", "list4测试3"));
list4.add(new TestObj1("list4测试4", "list4测试5", "list4测试6"));
list4.add(new TestObj1("list4测试7", "list4测试8", "list4测试9"));
list4.add(new TestObj1("list4测试10", "list4测试11", "list4测试12"));
Map<String,Object> multiListMap = new HashMap<>();
multiListMap.put("map",map);
multiListMap.put("data1",list1);
multiListMap.put("data2",list2);
multiListMap.put("data3",list3);
multiListMap.put("data4",list4);
ExcelUtil.exportTemplateMultiList(multiListMap, "多列表.xlsx", "excel/多列表.xlsx", response);
}
@Data
@AllArgsConstructor
static class TestObj1 {
private String test1;
private String test2;
private String test3;
}
@Data
@AllArgsConstructor
static class TestObj {
private String name;
private String list1;
private String list2;
private String list3;
private String list4;
}
}

View File

@ -39,7 +39,7 @@ public class TestDemo extends BaseEntity {
* 排序号
*/
@OrderBy(asc = false, sort = 1)
private Long orderNum;
private Integer orderNum;
/**
* key键

View File

@ -17,7 +17,7 @@ import lombok.EqualsAndHashCode;
@Data
@EqualsAndHashCode(callSuper = true)
@TableName("test_tree")
public class TestTree extends TreeEntity {
public class TestTree extends TreeEntity<TestTree> {
private static final long serialVersionUID = 1L;

View File

@ -49,7 +49,7 @@ public class TestDemoBo extends BaseEntity {
*/
@ApiModelProperty("排序号")
@NotNull(message = "排序号不能为空", groups = {AddGroup.class, EditGroup.class})
private Long orderNum;
private Integer orderNum;
/**
* key键

View File

@ -21,7 +21,7 @@ import javax.validation.constraints.NotNull;
@Data
@EqualsAndHashCode(callSuper = true)
@ApiModel("测试树表业务对象")
public class TestTreeBo extends TreeEntity {
public class TestTreeBo extends TreeEntity<TestTreeBo> {
/**
* 主键

View File

@ -48,7 +48,7 @@ public class TestDemoVo {
*/
@ExcelProperty(value = "排序号")
@ApiModelProperty("排序号")
private Long orderNum;
private Integer orderNum;
/**
* key键

View File

@ -54,5 +54,5 @@ public interface TestDemoMapper extends BaseMapperPlus<TestDemoMapper, TestDemo,
@DataColumn(key = "deptName", value = "dept_id"),
@DataColumn(key = "userName", value = "user_id")
})
int deleteBatchIds(@Param(Constants.COLLECTION) Collection<?> idList);
int deleteBatchIds(@Param(Constants.COLL) Collection<?> idList);
}

Binary file not shown.

Binary file not shown.

View File

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

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>ruoyi-extend</artifactId>
<groupId>com.ruoyi</groupId>
<version>4.0.1</version>
<version>4.2.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<packaging>jar</packaging>

View File

@ -4,14 +4,12 @@
<parent>
<artifactId>ruoyi-extend</artifactId>
<groupId>com.ruoyi</groupId>
<version>4.0.1</version>
<version>4.2.0</version>
</parent>
<artifactId>ruoyi-xxl-job-admin</artifactId>
<packaging>jar</packaging>
<properties>
<mybatis-spring-boot-starter.version>2.1.4</mybatis-spring-boot-starter.version>
<mysql-connector-java.version>8.0.23</mysql-connector-java.version>
</properties>
<dependencyManagement>
@ -62,13 +60,12 @@
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>${mybatis-spring-boot-starter.version}</version>
<version>${spring-boot.mybatis}</version>
</dependency>
<!-- mysql -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>${mysql-connector-java.version}</version>
</dependency>
<dependency>

View File

@ -56,13 +56,13 @@ public class IndexController {
@PermissionLimit(limit = false)
public ModelAndView toLogin(HttpServletRequest request, HttpServletResponse response, ModelAndView modelAndView) {
if (loginService.ifLogin(request, response) != null) {
modelAndView.setView(new RedirectView("/" , true, false));
modelAndView.setView(new RedirectView("/", true, false));
return modelAndView;
}
return new ModelAndView("login");
}
@RequestMapping(value = "login" , method = RequestMethod.POST)
@RequestMapping(value = "login", method = RequestMethod.POST)
@ResponseBody
@PermissionLimit(limit = false)
public ReturnT<String> loginDo(HttpServletRequest request, HttpServletResponse response, String userName, String password, String ifRemember) {
@ -70,7 +70,7 @@ public class IndexController {
return loginService.login(request, response, userName, password, ifRem);
}
@RequestMapping(value = "logout" , method = RequestMethod.POST)
@RequestMapping(value = "logout", method = RequestMethod.POST)
@ResponseBody
@PermissionLimit(limit = false)
public ReturnT<String> logout(HttpServletRequest request, HttpServletResponse response) {

View File

@ -37,19 +37,19 @@ public class JobApiController {
*/
@RequestMapping("/{uri}")
@ResponseBody
@PermissionLimit(limit=false)
@PermissionLimit(limit = false)
public ReturnT<String> api(HttpServletRequest request, @PathVariable("uri") String uri, @RequestBody(required = false) String data) {
// valid
if (!"POST".equalsIgnoreCase(request.getMethod())) {
return new ReturnT<String>(ReturnT.FAIL_CODE, "invalid request, HttpMethod not support.");
}
if (uri==null || uri.trim().length()==0) {
if (uri == null || uri.trim().length() == 0) {
return new ReturnT<String>(ReturnT.FAIL_CODE, "invalid request, uri-mapping empty.");
}
if (XxlJobAdminConfig.getAdminConfig().getAccessToken()!=null
&& XxlJobAdminConfig.getAdminConfig().getAccessToken().trim().length()>0
&& !XxlJobAdminConfig.getAdminConfig().getAccessToken().equals(request.getHeader(XxlJobRemotingUtil.XXL_JOB_ACCESS_TOKEN))) {
if (XxlJobAdminConfig.getAdminConfig().getAccessToken() != null
&& XxlJobAdminConfig.getAdminConfig().getAccessToken().trim().length() > 0
&& !XxlJobAdminConfig.getAdminConfig().getAccessToken().equals(request.getHeader(XxlJobRemotingUtil.XXL_JOB_ACCESS_TOKEN))) {
return new ReturnT<String>(ReturnT.FAIL_CODE, "The access token is wrong.");
}
@ -64,7 +64,7 @@ public class JobApiController {
RegistryParam registryParam = GsonTool.fromJson(data, RegistryParam.class);
return adminBiz.registryRemove(registryParam);
} else {
return new ReturnT<String>(ReturnT.FAIL_CODE, "invalid request, uri-mapping("+ uri +") not found.");
return new ReturnT<String>(ReturnT.FAIL_CODE, "invalid request, uri-mapping(" + uri + ") not found.");
}
}

View File

@ -47,10 +47,10 @@ public class JobCodeController {
JobInfoController.validPermission(request, jobInfo.getJobGroup());
// Glue类型-字典
model.addAttribute("GlueTypeEnum" , GlueTypeEnum.values());
model.addAttribute("GlueTypeEnum", GlueTypeEnum.values());
model.addAttribute("jobInfo" , jobInfo);
model.addAttribute("jobLogGlues" , jobLogGlues);
model.addAttribute("jobInfo", jobInfo);
model.addAttribute("jobLogGlues", jobLogGlues);
return "jobcode/jobcode.index";
}

View File

@ -52,9 +52,9 @@ public class JobGroupController {
// package result
Map<String, Object> maps = new HashMap<String, Object>();
maps.put("recordsTotal" , list_count); // 总记录数
maps.put("recordsFiltered" , list_count); // 过滤后的总记录数
maps.put("data" , list); // 分页列表
maps.put("recordsTotal", list_count); // 总记录数
maps.put("recordsFiltered", list_count); // 过滤后的总记录数
maps.put("data", list); // 分页列表
return maps;
}

View File

@ -49,11 +49,11 @@ public class JobInfoController {
public String index(HttpServletRequest request, Model model, @RequestParam(required = false, defaultValue = "-1") int jobGroup) {
// 枚举-字典
model.addAttribute("ExecutorRouteStrategyEnum" , ExecutorRouteStrategyEnum.values()); // 路由策略-列表
model.addAttribute("GlueTypeEnum" , GlueTypeEnum.values()); // Glue类型-字典
model.addAttribute("ExecutorBlockStrategyEnum" , ExecutorBlockStrategyEnum.values()); // 阻塞处理策略-字典
model.addAttribute("ScheduleTypeEnum" , ScheduleTypeEnum.values()); // 调度类型
model.addAttribute("MisfireStrategyEnum" , MisfireStrategyEnum.values()); // 调度过期策略
model.addAttribute("ExecutorRouteStrategyEnum", ExecutorRouteStrategyEnum.values()); // 路由策略-列表
model.addAttribute("GlueTypeEnum", GlueTypeEnum.values()); // Glue类型-字典
model.addAttribute("ExecutorBlockStrategyEnum", ExecutorBlockStrategyEnum.values()); // 阻塞处理策略-字典
model.addAttribute("ScheduleTypeEnum", ScheduleTypeEnum.values()); // 调度类型
model.addAttribute("MisfireStrategyEnum", MisfireStrategyEnum.values()); // 调度过期策略
// 执行器列表
List<XxlJobGroup> jobGroupList_all = xxlJobGroupDao.findAll();
@ -64,8 +64,8 @@ public class JobInfoController {
throw new XxlJobException(I18nUtil.getString("jobgroup_empty"));
}
model.addAttribute("JobGroupList" , jobGroupList);
model.addAttribute("jobGroup" , jobGroup);
model.addAttribute("JobGroupList", jobGroupList);
model.addAttribute("jobGroup", jobGroup);
return "jobinfo/jobinfo.index";
}

View File

@ -1,7 +1,7 @@
package com.xxl.job.admin.controller;
import com.xxl.job.admin.core.complete.XxlJobCompleter;
import com.xxl.job.admin.core.exception.XxlJobException;
import com.xxl.job.admin.core.complete.XxlJobCompleter;
import com.xxl.job.admin.core.model.XxlJobGroup;
import com.xxl.job.admin.core.model.XxlJobInfo;
import com.xxl.job.admin.core.model.XxlJobLog;
@ -60,7 +60,7 @@ public class JobLogController {
throw new XxlJobException(I18nUtil.getString("jobgroup_empty"));
}
model.addAttribute("JobGroupList" , jobGroupList);
model.addAttribute("JobGroupList", jobGroupList);
// 任务
if (jobId > 0) {
@ -69,7 +69,7 @@ public class JobLogController {
throw new RuntimeException(I18nUtil.getString("jobinfo_field_id") + I18nUtil.getString("system_unvalid"));
}
model.addAttribute("jobInfo" , jobInfo);
model.addAttribute("jobInfo", jobInfo);
// valid permission
JobInfoController.validPermission(request, jobInfo.getJobGroup());
@ -112,9 +112,9 @@ public class JobLogController {
// package result
Map<String, Object> maps = new HashMap<String, Object>();
maps.put("recordsTotal" , list_count); // 总记录数
maps.put("recordsFiltered" , list_count); // 过滤后的总记录数
maps.put("data" , list); // 分页列表
maps.put("recordsTotal", list_count); // 总记录数
maps.put("recordsFiltered", list_count); // 过滤后的总记录数
maps.put("data", list); // 分页列表
return maps;
}
@ -128,11 +128,11 @@ public class JobLogController {
throw new RuntimeException(I18nUtil.getString("joblog_logid_unvalid"));
}
model.addAttribute("triggerCode" , jobLog.getTriggerCode());
model.addAttribute("handleCode" , jobLog.getHandleCode());
model.addAttribute("executorAddress" , jobLog.getExecutorAddress());
model.addAttribute("triggerTime" , jobLog.getTriggerTime().getTime());
model.addAttribute("logId" , jobLog.getId());
model.addAttribute("triggerCode", jobLog.getTriggerCode());
model.addAttribute("handleCode", jobLog.getHandleCode());
model.addAttribute("executorAddress", jobLog.getExecutorAddress());
model.addAttribute("triggerTime", jobLog.getTriggerTime().getTime());
model.addAttribute("logId", jobLog.getId());
return "joblog/joblog.detail";
}

View File

@ -40,7 +40,7 @@ public class UserController {
// 执行器列表
List<XxlJobGroup> groupList = xxlJobGroupDao.findAll();
model.addAttribute("groupList" , groupList);
model.addAttribute("groupList", groupList);
return "user/user.index";
}
@ -65,9 +65,9 @@ public class UserController {
// package result
Map<String, Object> maps = new HashMap<String, Object>();
maps.put("recordsTotal" , list_count); // 总记录数
maps.put("recordsFiltered" , list_count); // 过滤后的总记录数
maps.put("data" , list); // 分页列表
maps.put("recordsTotal", list_count); // 总记录数
maps.put("recordsFiltered", list_count); // 过滤后的总记录数
maps.put("data", list); // 分页列表
return maps;
}

View File

@ -29,15 +29,14 @@ public class CookieInterceptor implements AsyncHandlerInterceptor {
for (Cookie ck : request.getCookies()) {
cookieMap.put(ck.getName(), ck);
}
modelAndView.addObject("cookieMap" , cookieMap);
modelAndView.addObject("cookieMap", cookieMap);
}
// static method
if (modelAndView != null) {
modelAndView.addObject("I18nUtil" , FtlUtil.generateStaticModel(I18nUtil.class.getName()));
modelAndView.addObject("I18nUtil", FtlUtil.generateStaticModel(I18nUtil.class.getName()));
}
AsyncHandlerInterceptor.super.postHandle(request, response, handler, modelAndView);
}
}

View File

@ -27,7 +27,7 @@ public class PermissionInterceptor implements AsyncHandlerInterceptor {
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
if (!(handler instanceof HandlerMethod)) {
return AsyncHandlerInterceptor.super.preHandle(request, response, handler);
return true; // proceed with the next interceptor
}
// if need login
@ -44,7 +44,7 @@ public class PermissionInterceptor implements AsyncHandlerInterceptor {
XxlJobUser loginUser = loginService.ifLogin(request, response);
if (loginUser == null) {
response.setStatus(302);
response.setHeader("location" , request.getContextPath() + "/toLogin");
response.setHeader("location", request.getContextPath() + "/toLogin");
return false;
}
if (needAdminuser && loginUser.getRole() != 1) {
@ -53,7 +53,7 @@ public class PermissionInterceptor implements AsyncHandlerInterceptor {
request.setAttribute(LoginService.LOGIN_IDENTITY_KEY, loginUser);
}
return AsyncHandlerInterceptor.super.preHandle(request, response, handler);
return true; // proceed with the next interceptor
}
}

View File

@ -1,8 +1,8 @@
package com.xxl.job.admin.controller.resolver;
import com.xxl.job.admin.core.exception.XxlJobException;
import com.xxl.job.admin.core.util.JacksonUtil;
import com.xxl.job.core.biz.model.ReturnT;
import com.xxl.job.admin.core.util.JacksonUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
@ -29,7 +29,7 @@ public class WebExceptionResolver implements HandlerExceptionResolver {
HttpServletResponse response, Object handler, Exception ex) {
if (!(ex instanceof XxlJobException)) {
logger.error("WebExceptionResolver:{}" , ex);
logger.error("WebExceptionResolver:{}", ex);
}
// if json
@ -43,7 +43,7 @@ public class WebExceptionResolver implements HandlerExceptionResolver {
}
// error result
ReturnT<String> errorResult = new ReturnT<String>(ReturnT.FAIL_CODE, ex.toString().replaceAll("\n" , "<br/>"));
ReturnT<String> errorResult = new ReturnT<String>(ReturnT.FAIL_CODE, ex.toString().replaceAll("\n", "<br/>"));
// response
ModelAndView mv = new ModelAndView();
@ -57,7 +57,7 @@ public class WebExceptionResolver implements HandlerExceptionResolver {
return mv;
} else {
mv.addObject("exceptionMsg" , errorResult.getMsg());
mv.addObject("exceptionMsg", errorResult.getMsg());
mv.setViewName("/common/common.exception");
return mv;
}

View File

@ -44,9 +44,9 @@ public class JobAlarmer implements ApplicationContextAware, InitializingBean {
public boolean alarm(XxlJobInfo info, XxlJobLog jobLog) {
boolean result = false;
if (jobAlarmList!=null && jobAlarmList.size()>0) {
if (jobAlarmList != null && jobAlarmList.size() > 0) {
result = true; // success means all-success
for (JobAlarm alarm: jobAlarmList) {
for (JobAlarm alarm : jobAlarmList) {
boolean resultItem = false;
try {
resultItem = alarm.doAlarm(info, jobLog);

View File

@ -32,18 +32,19 @@ public class EmailJobAlarm implements JobAlarm {
*
* @param jobLog
*/
public boolean doAlarm(XxlJobInfo info, XxlJobLog jobLog){
@Override
public boolean doAlarm(XxlJobInfo info, XxlJobLog jobLog) {
boolean alarmResult = true;
// send monitor email
if (info!=null && info.getAlarmEmail()!=null && info.getAlarmEmail().trim().length()>0) {
if (info != null && info.getAlarmEmail() != null && info.getAlarmEmail().trim().length() > 0) {
// alarmContent
String alarmContent = "Alarm Job LogId=" + jobLog.getId();
if (jobLog.getTriggerCode() != ReturnT.SUCCESS_CODE) {
alarmContent += "<br>TriggerMsg=<br>" + jobLog.getTriggerMsg();
}
if (jobLog.getHandleCode()>0 && jobLog.getHandleCode() != ReturnT.SUCCESS_CODE) {
if (jobLog.getHandleCode() > 0 && jobLog.getHandleCode() != ReturnT.SUCCESS_CODE) {
alarmContent += "<br>HandleCode=" + jobLog.getHandleMsg();
}
@ -52,13 +53,13 @@ public class EmailJobAlarm implements JobAlarm {
String personal = I18nUtil.getString("admin_name_full");
String title = I18nUtil.getString("jobconf_monitor");
String content = MessageFormat.format(loadEmailJobAlarmTemplate(),
group!=null?group.getTitle():"null",
info.getId(),
info.getJobDesc(),
alarmContent);
group != null ? group.getTitle() : "null",
info.getId(),
info.getJobDesc(),
alarmContent);
Set<String> emailSet = new HashSet<String>(Arrays.asList(info.getAlarmEmail().split(",")));
for (String email: emailSet) {
for (String email : emailSet) {
// make mail
try {
@ -88,28 +89,28 @@ public class EmailJobAlarm implements JobAlarm {
*
* @return
*/
private static final String loadEmailJobAlarmTemplate(){
private static final String loadEmailJobAlarmTemplate() {
String mailBodyTemplate = "<h5>" + I18nUtil.getString("jobconf_monitor_detail") + "</span>" +
"<table border=\"1\" cellpadding=\"3\" style=\"border-collapse:collapse; width:80%;\" >\n" +
" <thead style=\"font-weight: bold;color: #ffffff;background-color: #ff8c00;\" >" +
" <tr>\n" +
" <td width=\"20%\" >"+ I18nUtil.getString("jobinfo_field_jobgroup") +"</td>\n" +
" <td width=\"10%\" >"+ I18nUtil.getString("jobinfo_field_id") +"</td>\n" +
" <td width=\"20%\" >"+ I18nUtil.getString("jobinfo_field_jobdesc") +"</td>\n" +
" <td width=\"10%\" >"+ I18nUtil.getString("jobconf_monitor_alarm_title") +"</td>\n" +
" <td width=\"40%\" >"+ I18nUtil.getString("jobconf_monitor_alarm_content") +"</td>\n" +
" </tr>\n" +
" </thead>\n" +
" <tbody>\n" +
" <tr>\n" +
" <td>{0}</td>\n" +
" <td>{1}</td>\n" +
" <td>{2}</td>\n" +
" <td>"+ I18nUtil.getString("jobconf_monitor_alarm_type") +"</td>\n" +
" <td>{3}</td>\n" +
" </tr>\n" +
" </tbody>\n" +
"</table>";
"<table border=\"1\" cellpadding=\"3\" style=\"border-collapse:collapse; width:80%;\" >\n" +
" <thead style=\"font-weight: bold;color: #ffffff;background-color: #ff8c00;\" >" +
" <tr>\n" +
" <td width=\"20%\" >" + I18nUtil.getString("jobinfo_field_jobgroup") + "</td>\n" +
" <td width=\"10%\" >" + I18nUtil.getString("jobinfo_field_id") + "</td>\n" +
" <td width=\"20%\" >" + I18nUtil.getString("jobinfo_field_jobdesc") + "</td>\n" +
" <td width=\"10%\" >" + I18nUtil.getString("jobconf_monitor_alarm_title") + "</td>\n" +
" <td width=\"40%\" >" + I18nUtil.getString("jobconf_monitor_alarm_content") + "</td>\n" +
" </tr>\n" +
" </thead>\n" +
" <tbody>\n" +
" <tr>\n" +
" <td>{0}</td>\n" +
" <td>{1}</td>\n" +
" <td>{2}</td>\n" +
" <td>" + I18nUtil.getString("jobconf_monitor_alarm_type") + "</td>\n" +
" <td>{3}</td>\n" +
" </tr>\n" +
" </tbody>\n" +
"</table>";
return mailBodyTemplate;
}

View File

@ -32,7 +32,7 @@ public class XxlJobCompleter {
// text最大64kb 避免长度过长
if (xxlJobLog.getHandleMsg().length() > 15000) {
xxlJobLog.setHandleMsg( xxlJobLog.getHandleMsg().substring(0, 15000) );
xxlJobLog.setHandleMsg(xxlJobLog.getHandleMsg().substring(0, 15000));
}
// fresh handle
@ -43,18 +43,18 @@ public class XxlJobCompleter {
/**
* do somethind to finish job
*/
private static void finishJob(XxlJobLog xxlJobLog){
private static void finishJob(XxlJobLog xxlJobLog) {
// 1、handle success, to trigger child job
String triggerChildMsg = null;
if (XxlJobContext.HANDLE_COCE_SUCCESS == xxlJobLog.getHandleCode()) {
if (XxlJobContext.HANDLE_CODE_SUCCESS == xxlJobLog.getHandleCode()) {
XxlJobInfo xxlJobInfo = XxlJobAdminConfig.getAdminConfig().getXxlJobInfoDao().loadById(xxlJobLog.getJobId());
if (xxlJobInfo!=null && xxlJobInfo.getChildJobId()!=null && xxlJobInfo.getChildJobId().trim().length()>0) {
triggerChildMsg = "<br><br><span style=\"color:#00c0ef;\" > >>>>>>>>>>>"+ I18nUtil.getString("jobconf_trigger_child_run") +"<<<<<<<<<<< </span><br>";
if (xxlJobInfo != null && xxlJobInfo.getChildJobId() != null && xxlJobInfo.getChildJobId().trim().length() > 0) {
triggerChildMsg = "<br><br><span style=\"color:#00c0ef;\" > >>>>>>>>>>>" + I18nUtil.getString("jobconf_trigger_child_run") + "<<<<<<<<<<< </span><br>";
String[] childJobIds = xxlJobInfo.getChildJobId().split(",");
for (int i = 0; i < childJobIds.length; i++) {
int childJobId = (childJobIds[i]!=null && childJobIds[i].trim().length()>0 && isNumeric(childJobIds[i]))?Integer.valueOf(childJobIds[i]):-1;
int childJobId = (childJobIds[i] != null && childJobIds[i].trim().length() > 0 && isNumeric(childJobIds[i])) ? Integer.valueOf(childJobIds[i]) : -1;
if (childJobId > 0) {
JobTriggerPoolHelper.trigger(childJobId, TriggerTypeEnum.PARENT, -1, null, null, null);
@ -62,16 +62,16 @@ public class XxlJobCompleter {
// add msg
triggerChildMsg += MessageFormat.format(I18nUtil.getString("jobconf_callback_child_msg1"),
(i+1),
childJobIds.length,
childJobIds[i],
(triggerChildResult.getCode()==ReturnT.SUCCESS_CODE?I18nUtil.getString("system_success"):I18nUtil.getString("system_fail")),
triggerChildResult.getMsg());
(i + 1),
childJobIds.length,
childJobIds[i],
(triggerChildResult.getCode() == ReturnT.SUCCESS_CODE ? I18nUtil.getString("system_success") : I18nUtil.getString("system_fail")),
triggerChildResult.getMsg());
} else {
triggerChildMsg += MessageFormat.format(I18nUtil.getString("jobconf_callback_child_msg2"),
(i+1),
childJobIds.length,
childJobIds[i]);
(i + 1),
childJobIds.length,
childJobIds[i]);
}
}
@ -79,7 +79,7 @@ public class XxlJobCompleter {
}
if (triggerChildMsg != null) {
xxlJobLog.setHandleMsg( xxlJobLog.getHandleMsg() + triggerChildMsg );
xxlJobLog.setHandleMsg(xxlJobLog.getHandleMsg() + triggerChildMsg);
}
// 2、fix_delay trigger next
@ -87,7 +87,7 @@ public class XxlJobCompleter {
}
private static boolean isNumeric(String str){
private static boolean isNumeric(String str) {
try {
int result = Integer.valueOf(str);
return true;

View File

@ -23,6 +23,7 @@ import java.util.Arrays;
public class XxlJobAdminConfig implements InitializingBean, DisposableBean {
private static XxlJobAdminConfig adminConfig = null;
public static XxlJobAdminConfig getAdminConfig() {
return adminConfig;
}

View File

@ -1,18 +1,18 @@
/*
* All content copyright Terracotta, Inc., unless otherwise indicated. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy
* of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy
* of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
*
*/
package com.xxl.job.admin.core.cron;
@ -31,14 +31,14 @@ import java.util.TimeZone;
import java.util.TreeSet;
/**
* Provides a parser and evaluator for unix-like cron expressions. Cron
* Provides a parser and evaluator for unix-like cron expressions. Cron
* expressions provide the ability to specify complex time combinations such as
* &quot;At 8:00am every Monday through Friday&quot; or &quot;At 1:30am every
* last Friday of the month&quot;.
* &quot;At 8:00am every Monday through Friday&quot; or &quot;At 1:30am every
* last Friday of the month&quot;.
* <P>
* Cron expressions are comprised of 6 required fields and one optional field
* separated by white space. The fields respectively are described as follows:
*
*
* <table cellspacing="8">
* <tr>
* <th align="left">Field Name</th>
@ -98,7 +98,7 @@ import java.util.TreeSet;
* </tr>
* </table>
* <P>
* The '*' character is used to specify all values. For example, &quot;*&quot;
* The '*' character is used to specify all values. For example, &quot;*&quot;
* in the minute field means &quot;every minute&quot;.
* <P>
* The '?' character is allowed for the day-of-month and day-of-week fields. It
@ -113,55 +113,55 @@ import java.util.TreeSet;
* Wednesday, and Friday&quot;.
* <P>
* The '/' character is used to specify increments. For example &quot;0/15&quot;
* in the seconds field means &quot;the seconds 0, 15, 30, and 45&quot;. And
* in the seconds field means &quot;the seconds 0, 15, 30, and 45&quot;. And
* &quot;5/15&quot; in the seconds field means &quot;the seconds 5, 20, 35, and
* 50&quot;. Specifying '*' before the '/' is equivalent to specifying 0 is
* the value to start with. Essentially, for each field in the expression, there
* is a set of numbers that can be turned on or off. For seconds and minutes,
* is a set of numbers that can be turned on or off. For seconds and minutes,
* the numbers range from 0 to 59. For hours 0 to 23, for days of the month 0 to
* 31, and for months 0 to 11 (JAN to DEC). The &quot;/&quot; character simply helps you turn
* on every &quot;nth&quot; value in the given set. Thus &quot;7/6&quot; in the
* month field only turns on month &quot;7&quot;, it does NOT mean every 6th
* month, please note that subtlety.
* month field only turns on month &quot;7&quot;, it does NOT mean every 6th
* month, please note that subtlety.
* <P>
* The 'L' character is allowed for the day-of-month and day-of-week fields.
* This character is short-hand for &quot;last&quot;, but it has different
* meaning in each of the two fields. For example, the value &quot;L&quot; in
* the day-of-month field means &quot;the last day of the month&quot; - day 31
* for January, day 28 for February on non-leap years. If used in the
* day-of-week field by itself, it simply means &quot;7&quot; or
* This character is short-hand for &quot;last&quot;, but it has different
* meaning in each of the two fields. For example, the value &quot;L&quot; in
* the day-of-month field means &quot;the last day of the month&quot; - day 31
* for January, day 28 for February on non-leap years. If used in the
* day-of-week field by itself, it simply means &quot;7&quot; or
* &quot;SAT&quot;. But if used in the day-of-week field after another value, it
* means &quot;the last xxx day of the month&quot; - for example &quot;6L&quot;
* means &quot;the last friday of the month&quot;. You can also specify an offset
* from the last day of the month, such as "L-3" which would mean the third-to-last
* day of the calendar month. <i>When using the 'L' option, it is important not to
* means &quot;the last friday of the month&quot;. You can also specify an offset
* from the last day of the month, such as "L-3" which would mean the third-to-last
* day of the calendar month. <i>When using the 'L' option, it is important not to
* specify lists, or ranges of values, as you'll get confusing/unexpected results.</i>
* <P>
* The 'W' character is allowed for the day-of-month field. This character
* is used to specify the weekday (Monday-Friday) nearest the given day. As an
* example, if you were to specify &quot;15W&quot; as the value for the
* The 'W' character is allowed for the day-of-month field. This character
* is used to specify the weekday (Monday-Friday) nearest the given day. As an
* example, if you were to specify &quot;15W&quot; as the value for the
* day-of-month field, the meaning is: &quot;the nearest weekday to the 15th of
* the month&quot;. So if the 15th is a Saturday, the trigger will fire on
* the month&quot;. So if the 15th is a Saturday, the trigger will fire on
* Friday the 14th. If the 15th is a Sunday, the trigger will fire on Monday the
* 16th. If the 15th is a Tuesday, then it will fire on Tuesday the 15th.
* 16th. If the 15th is a Tuesday, then it will fire on Tuesday the 15th.
* However if you specify &quot;1W&quot; as the value for day-of-month, and the
* 1st is a Saturday, the trigger will fire on Monday the 3rd, as it will not
* 'jump' over the boundary of a month's days. The 'W' character can only be
* 1st is a Saturday, the trigger will fire on Monday the 3rd, as it will not
* 'jump' over the boundary of a month's days. The 'W' character can only be
* specified when the day-of-month is a single day, not a range or list of days.
* <P>
* The 'L' and 'W' characters can also be combined for the day-of-month
* expression to yield 'LW', which translates to &quot;last weekday of the
* The 'L' and 'W' characters can also be combined for the day-of-month
* expression to yield 'LW', which translates to &quot;last weekday of the
* month&quot;.
* <P>
* The '#' character is allowed for the day-of-week field. This character is
* used to specify &quot;the nth&quot; XXX day of the month. For example, the
* value of &quot;6#3&quot; in the day-of-week field means the third Friday of
* the month (day 6 = Friday and &quot;#3&quot; = the 3rd one in the month).
* Other examples: &quot;2#1&quot; = the first Monday of the month and
* used to specify &quot;the nth&quot; XXX day of the month. For example, the
* value of &quot;6#3&quot; in the day-of-week field means the third Friday of
* the month (day 6 = Friday and &quot;#3&quot; = the 3rd one in the month).
* Other examples: &quot;2#1&quot; = the first Monday of the month and
* &quot;4#5&quot; = the fifth Wednesday of the month. Note that if you specify
* &quot;#5&quot; and there is not 5 of the given day-of-week in the month, then
* no firing will occur that month. If the '#' character is used, there can
* only be one expression in the day-of-week field (&quot;3#1,6#3&quot; is
* only be one expression in the day-of-week field (&quot;3#1,6#3&quot; is
* not valid, since there are two expressions).
* <P>
* <!--The 'C' character is allowed for the day-of-month and day-of-week fields.
@ -174,35 +174,33 @@ import java.util.TreeSet;
* <P>
* The legal characters and the names of months and days of the week are not
* case sensitive.
*
*
* <p>
* <b>NOTES:</b>
* <ul>
* <li>Support for specifying both a day-of-week and a day-of-month value is
* not complete (you'll need to use the '?' character in one of these fields).
* </li>
* <li>Overflowing ranges is supported - that is, having a larger number on
* the left hand side than the right. You might do 22-2 to catch 10 o'clock
* at night until 2 o'clock in the morning, or you might have NOV-FEB. It is
* very important to note that overuse of overflowing ranges creates ranges
* that don't make sense and no effort has been made to determine which
* interpretation CronExpression chooses. An example would be
* <li>Overflowing ranges is supported - that is, having a larger number on
* the left hand side than the right. You might do 22-2 to catch 10 o'clock
* at night until 2 o'clock in the morning, or you might have NOV-FEB. It is
* very important to note that overuse of overflowing ranges creates ranges
* that don't make sense and no effort has been made to determine which
* interpretation CronExpression chooses. An example would be
* "0 0 14-6 ? * FRI-MON". </li>
* </ul>
* </p>
*
*
*
* @author Sharada Jambula, James House
* @author Contributions from Mads Henderson
* @author Refactoring from CronTrigger to CronExpression by Aaron Craven
*
* <p>
* Borrowed from quartz v2.3.1
*
*/
public final class CronExpression implements Serializable, Cloneable {
private static final long serialVersionUID = 12423409423L;
protected static final int SECOND = 0;
protected static final int MINUTE = 1;
protected static final int HOUR = 2;
@ -214,9 +212,10 @@ public final class CronExpression implements Serializable, Cloneable {
protected static final int NO_SPEC_INT = 98; // '?'
protected static final Integer ALL_SPEC = ALL_SPEC_INT;
protected static final Integer NO_SPEC = NO_SPEC_INT;
protected static final Map<String, Integer> monthMap = new HashMap<String, Integer>(20);
protected static final Map<String, Integer> dayMap = new HashMap<String, Integer>(60);
static {
monthMap.put("JAN", 0);
monthMap.put("FEB", 1);
@ -256,35 +255,33 @@ public final class CronExpression implements Serializable, Cloneable {
protected transient boolean nearestWeekday = false;
protected transient int lastdayOffset = 0;
protected transient boolean expressionParsed = false;
public static final int MAX_YEAR = Calendar.getInstance().get(Calendar.YEAR) + 100;
/**
* Constructs a new <CODE>CronExpression</CODE> based on the specified
* Constructs a new <CODE>CronExpression</CODE> based on the specified
* parameter.
*
*
* @param cronExpression String representation of the cron expression the
* new object should represent
* @throws java.text.ParseException
* if the string expression cannot be parsed into a valid
* <CODE>CronExpression</CODE>
* @throws ParseException if the string expression cannot be parsed into a valid
* <CODE>CronExpression</CODE>
*/
public CronExpression(String cronExpression) throws ParseException {
if (cronExpression == null) {
throw new IllegalArgumentException("cronExpression cannot be null");
}
this.cronExpression = cronExpression.toUpperCase(Locale.US);
buildExpression(this.cronExpression);
}
/**
* Constructs a new {@code CronExpression} as a copy of an existing
* instance.
*
* @param expression
* The existing cron expression to be copied
*
* @param expression The existing cron expression to be copied
*/
public CronExpression(CronExpression expression) {
/*
@ -307,28 +304,28 @@ public final class CronExpression implements Serializable, Cloneable {
* Indicates whether the given date satisfies the cron expression. Note that
* milliseconds are ignored, so two Dates falling on different milliseconds
* of the same second will always have the same result here.
*
*
* @param date the date to evaluate
* @return a boolean indicating whether the given date satisfies the cron
* expression
* expression
*/
public boolean isSatisfiedBy(Date date) {
Calendar testDateCal = Calendar.getInstance(getTimeZone());
testDateCal.setTime(date);
testDateCal.set(Calendar.MILLISECOND, 0);
Date originalDate = testDateCal.getTime();
testDateCal.add(Calendar.SECOND, -1);
Date timeAfter = getTimeAfter(testDateCal.getTime());
return ((timeAfter != null) && (timeAfter.equals(originalDate)));
}
/**
* Returns the next date/time <I>after</I> the given date/time which
* satisfies the cron expression.
*
*
* @param date the date/time at which to begin the search for the next valid
* date/time
* @return the next valid date/time
@ -336,48 +333,48 @@ public final class CronExpression implements Serializable, Cloneable {
public Date getNextValidTimeAfter(Date date) {
return getTimeAfter(date);
}
/**
* Returns the next date/time <I>after</I> the given date/time which does
* <I>not</I> satisfy the expression
*
* @param date the date/time at which to begin the search for the next
*
* @param date the date/time at which to begin the search for the next
* invalid date/time
* @return the next valid date/time
*/
public Date getNextInvalidTimeAfter(Date date) {
long difference = 1000;
//move back to the nearest second so differences will be accurate
Calendar adjustCal = Calendar.getInstance(getTimeZone());
adjustCal.setTime(date);
adjustCal.set(Calendar.MILLISECOND, 0);
Date lastDate = adjustCal.getTime();
Date newDate;
//FUTURE_TODO: (QUARTZ-481) IMPROVE THIS! The following is a BAD solution to this problem. Performance will be very bad here, depending on the cron expression. It is, however A solution.
//keep getting the next included time until it's farther than one second
// apart. At that point, lastDate is the last valid fire time. We return
// the second immediately following it.
while (difference == 1000) {
newDate = getTimeAfter(lastDate);
if(newDate == null)
if (newDate == null)
break;
difference = newDate.getTime() - lastDate.getTime();
if (difference == 1000) {
lastDate = newDate;
}
}
return new Date(lastDate.getTime() + 1000);
}
/**
* Returns the time zone for which this <code>CronExpression</code>
* Returns the time zone for which this <code>CronExpression</code>
* will be resolved.
*/
public TimeZone getTimeZone() {
@ -389,16 +386,16 @@ public final class CronExpression implements Serializable, Cloneable {
}
/**
* Sets the time zone for which this <code>CronExpression</code>
* Sets the time zone for which this <code>CronExpression</code>
* will be resolved.
*/
public void setTimeZone(TimeZone timeZone) {
this.timeZone = timeZone;
}
/**
* Returns the string representation of the <CODE>CronExpression</CODE>
*
*
* @return a string representation of the <CODE>CronExpression</CODE>
*/
@Override
@ -407,30 +404,30 @@ public final class CronExpression implements Serializable, Cloneable {
}
/**
* Indicates whether the specified cron expression can be parsed into a
* Indicates whether the specified cron expression can be parsed into a
* valid cron expression
*
*
* @param cronExpression the expression to evaluate
* @return a boolean indicating whether the given expression is a valid cron
* expression
* expression
*/
public static boolean isValidExpression(String cronExpression) {
try {
new CronExpression(cronExpression);
} catch (ParseException pe) {
return false;
}
return true;
}
public static void validateExpression(String cronExpression) throws ParseException {
new CronExpression(cronExpression);
}
////////////////////////////////////////////////////////////////////////////
//
// Expression Parsing Functions
@ -467,23 +464,23 @@ public final class CronExpression implements Serializable, Cloneable {
int exprOn = SECOND;
StringTokenizer exprsTok = new StringTokenizer(expression, " \t",
false);
false);
while (exprsTok.hasMoreTokens() && exprOn <= YEAR) {
String expr = exprsTok.nextToken().trim();
// throw an exception if L is used with other days of the month
if(exprOn == DAY_OF_MONTH && expr.indexOf('L') != -1 && expr.length() > 1 && expr.contains(",")) {
if (exprOn == DAY_OF_MONTH && expr.indexOf('L') != -1 && expr.length() > 1 && expr.contains(",")) {
throw new ParseException("Support for specifying 'L' and 'LW' with other days of the month is not implemented", -1);
}
// throw an exception if L is used with other days of the week
if(exprOn == DAY_OF_WEEK && expr.indexOf('L') != -1 && expr.length() > 1 && expr.contains(",")) {
if (exprOn == DAY_OF_WEEK && expr.indexOf('L') != -1 && expr.length() > 1 && expr.contains(",")) {
throw new ParseException("Support for specifying 'L' with other days of the week is not implemented", -1);
}
if(exprOn == DAY_OF_WEEK && expr.indexOf('#') != -1 && expr.indexOf('#', expr.indexOf('#') +1) != -1) {
if (exprOn == DAY_OF_WEEK && expr.indexOf('#') != -1 && expr.indexOf('#', expr.indexOf('#') + 1) != -1) {
throw new ParseException("Support for specifying multiple \"nth\" days is not implemented.", -1);
}
StringTokenizer vTok = new StringTokenizer(expr, ",");
while (vTok.hasMoreTokens()) {
String v = vTok.nextToken();
@ -495,7 +492,7 @@ public final class CronExpression implements Serializable, Cloneable {
if (exprOn <= DAY_OF_WEEK) {
throw new ParseException("Unexpected end of expression.",
expression.length());
expression.length());
}
if (exprOn <= YEAR) {
@ -512,14 +509,14 @@ public final class CronExpression implements Serializable, Cloneable {
if (!dayOfMSpec || dayOfWSpec) {
if (!dayOfWSpec || dayOfMSpec) {
throw new ParseException(
"Support for specifying both a day-of-week AND a day-of-month parameter is not implemented.", 0);
"Support for specifying both a day-of-week AND a day-of-month parameter is not implemented.", 0);
}
}
} catch (ParseException pe) {
throw pe;
} catch (Exception e) {
throw new ParseException("Illegal cron expression format ("
+ e.toString() + ")", 0);
+ e.toString() + ")", 0);
}
}
@ -556,7 +553,7 @@ public final class CronExpression implements Serializable, Cloneable {
sval = getDayOfWeekNumber(sub);
if (sval < 0) {
throw new ParseException("Invalid Day-of-Week value: '"
+ sub + "'", i);
+ sub + "'", i);
}
if (s.length() > i + 3) {
c = s.charAt(i + 3);
@ -566,8 +563,8 @@ public final class CronExpression implements Serializable, Cloneable {
eval = getDayOfWeekNumber(sub);
if (eval < 0) {
throw new ParseException(
"Invalid Day-of-Week value: '" + sub
+ "'", i);
"Invalid Day-of-Week value: '" + sub
+ "'", i);
}
} else if (c == '#') {
try {
@ -578,8 +575,8 @@ public final class CronExpression implements Serializable, Cloneable {
}
} catch (Exception e) {
throw new ParseException(
"A numeric value between 1 and 5 must follow the '#' option",
i);
"A numeric value between 1 and 5 must follow the '#' option",
i);
}
} else if (c == 'L') {
lastdayOfWeek = true;
@ -589,8 +586,8 @@ public final class CronExpression implements Serializable, Cloneable {
} else {
throw new ParseException(
"Illegal characters for this position: '" + sub + "'",
i);
"Illegal characters for this position: '" + sub + "'",
i);
}
if (eval != -1) {
incr = 1;
@ -601,22 +598,22 @@ public final class CronExpression implements Serializable, Cloneable {
if (c == '?') {
i++;
if ((i + 1) < s.length()
&& (s.charAt(i) != ' ' && s.charAt(i + 1) != '\t')) {
if ((i + 1) < s.length()
&& (s.charAt(i) != ' ' && s.charAt(i + 1) != '\t')) {
throw new ParseException("Illegal character after '?': "
+ s.charAt(i), i);
+ s.charAt(i), i);
}
if (type != DAY_OF_WEEK && type != DAY_OF_MONTH) {
throw new ParseException(
"'?' can only be specified for Day-of-Month or Day-of-Week.",
i);
"'?' can only be specified for Day-of-Month or Day-of-Week.",
i);
}
if (type == DAY_OF_WEEK && !lastdayOfMonth) {
int val = daysOfMonth.last();
if (val == NO_SPEC_INT) {
throw new ParseException(
"'?' can only be specified for Day-of-Month -OR- Day-of-Week.",
i);
"'?' can only be specified for Day-of-Month -OR- Day-of-Week.",
i);
}
}
@ -629,8 +626,8 @@ public final class CronExpression implements Serializable, Cloneable {
addToSet(ALL_SPEC_INT, -1, incr, type);
return i + 1;
} else if (c == '/'
&& ((i + 1) >= s.length() || s.charAt(i + 1) == ' ' || s
.charAt(i + 1) == '\t')) {
&& ((i + 1) >= s.length() || s.charAt(i + 1) == ' ' || s
.charAt(i + 1) == '\t')) {
throw new ParseException("'/' must be followed by an integer.", i);
} else if (c == '*') {
i++;
@ -663,18 +660,18 @@ public final class CronExpression implements Serializable, Cloneable {
if (type == DAY_OF_WEEK) {
addToSet(7, 7, 0, type);
}
if(type == DAY_OF_MONTH && s.length() > i) {
if (type == DAY_OF_MONTH && s.length() > i) {
c = s.charAt(i);
if(c == '-') {
ValueSet vs = getValue(0, s, i+1);
if (c == '-') {
ValueSet vs = getValue(0, s, i + 1);
lastdayOffset = vs.value;
if(lastdayOffset > 30)
throw new ParseException("Offset from last day must be <= 30", i+1);
if (lastdayOffset > 30)
throw new ParseException("Offset from last day must be <= 30", i + 1);
i = vs.pos;
}
if(s.length() > i) {
}
if (s.length() > i) {
c = s.charAt(i);
if(c == 'W') {
if (c == 'W') {
nearestWeekday = true;
i++;
}
@ -719,7 +716,7 @@ public final class CronExpression implements Serializable, Cloneable {
protected int checkNext(int pos, String s, int val, int type)
throws ParseException {
int end = -1;
int i = pos;
@ -732,7 +729,7 @@ public final class CronExpression implements Serializable, Cloneable {
if (c == 'L') {
if (type == DAY_OF_WEEK) {
if(val < 1 || val > 7)
if (val < 1 || val > 7)
throw new ParseException("Day-of-Week values must be between 1 and 7", -1);
lastdayOfWeek = true;
} else {
@ -743,15 +740,15 @@ public final class CronExpression implements Serializable, Cloneable {
i++;
return i;
}
if (c == 'W') {
if (type == DAY_OF_MONTH) {
nearestWeekday = true;
} else {
throw new ParseException("'W' option is not valid here. (pos=" + i + ")", i);
}
if(val > 31)
throw new ParseException("The 'W' option does not make sense with values larger than 31 (max number of days in a month)", i);
if (val > 31)
throw new ParseException("The 'W' option does not make sense with values larger than 31 (max number of days in a month)", i);
TreeSet<Integer> set = getSet(type);
set.add(val);
i++;
@ -770,8 +767,8 @@ public final class CronExpression implements Serializable, Cloneable {
}
} catch (Exception e) {
throw new ParseException(
"A numeric value between 1 and 5 must follow the '#' option",
i);
"A numeric value between 1 and 5 must follow the '#' option",
i);
}
TreeSet<Integer> set = getSet(type);
@ -857,7 +854,7 @@ public final class CronExpression implements Serializable, Cloneable {
public String getCronExpression() {
return cronExpression;
}
public String getExpressionSummary() {
StringBuilder buf = new StringBuilder();
@ -966,36 +963,36 @@ public final class CronExpression implements Serializable, Cloneable {
protected void addToSet(int val, int end, int incr, int type)
throws ParseException {
TreeSet<Integer> set = getSet(type);
if (type == SECOND || type == MINUTE) {
if ((val < 0 || val > 59 || end > 59) && (val != ALL_SPEC_INT)) {
throw new ParseException(
"Minute and Second values must be between 0 and 59",
-1);
"Minute and Second values must be between 0 and 59",
-1);
}
} else if (type == HOUR) {
if ((val < 0 || val > 23 || end > 23) && (val != ALL_SPEC_INT)) {
throw new ParseException(
"Hour values must be between 0 and 23", -1);
"Hour values must be between 0 and 23", -1);
}
} else if (type == DAY_OF_MONTH) {
if ((val < 1 || val > 31 || end > 31) && (val != ALL_SPEC_INT)
&& (val != NO_SPEC_INT)) {
if ((val < 1 || val > 31 || end > 31) && (val != ALL_SPEC_INT)
&& (val != NO_SPEC_INT)) {
throw new ParseException(
"Day of month values must be between 1 and 31", -1);
"Day of month values must be between 1 and 31", -1);
}
} else if (type == MONTH) {
if ((val < 1 || val > 12 || end > 12) && (val != ALL_SPEC_INT)) {
throw new ParseException(
"Month values must be between 1 and 12", -1);
"Month values must be between 1 and 12", -1);
}
} else if (type == DAY_OF_WEEK) {
if ((val == 0 || val > 7 || end > 7) && (val != ALL_SPEC_INT)
&& (val != NO_SPEC_INT)) {
&& (val != NO_SPEC_INT)) {
throw new ParseException(
"Day-of-Week values must be between 1 and 7", -1);
"Day-of-Week values must be between 1 and 7", -1);
}
}
@ -1005,7 +1002,7 @@ public final class CronExpression implements Serializable, Cloneable {
} else {
set.add(NO_SPEC);
}
return;
}
@ -1061,20 +1058,34 @@ public final class CronExpression implements Serializable, Cloneable {
}
}
// if the end of the range is before the start, then we need to overflow into
// the next day, month etc. This is done by adding the maximum amount for that
// if the end of the range is before the start, then we need to overflow into
// the next day, month etc. This is done by adding the maximum amount for that
// type, and using modulus max to determine the value being added.
int max = -1;
if (stopAt < startAt) {
switch (type) {
case SECOND : max = 60; break;
case MINUTE : max = 60; break;
case HOUR : max = 24; break;
case MONTH : max = 12; break;
case DAY_OF_WEEK : max = 7; break;
case DAY_OF_MONTH : max = 31; break;
case YEAR : throw new IllegalArgumentException("Start year must be less than stop year");
default : throw new IllegalArgumentException("Unexpected type encountered");
case SECOND:
max = 60;
break;
case MINUTE:
max = 60;
break;
case HOUR:
max = 24;
break;
case MONTH:
max = 12;
break;
case DAY_OF_WEEK:
max = 7;
break;
case DAY_OF_MONTH:
max = 31;
break;
case YEAR:
throw new IllegalArgumentException("Start year must be less than stop year");
default:
throw new IllegalArgumentException("Unexpected type encountered");
}
stopAt += max;
}
@ -1088,7 +1099,7 @@ public final class CronExpression implements Serializable, Cloneable {
int i2 = i % max;
// 1-indexed ranges should not include 0, and should include their max
if (i2 == 0 && (type == MONTH || type == DAY_OF_WEEK || type == DAY_OF_MONTH) ) {
if (i2 == 0 && (type == MONTH || type == DAY_OF_WEEK || type == DAY_OF_MONTH)) {
i2 = max;
}
@ -1130,7 +1141,7 @@ public final class CronExpression implements Serializable, Cloneable {
c = s.charAt(i);
}
ValueSet val = new ValueSet();
val.pos = (i < s.length()) ? i : i + 1;
val.value = Integer.parseInt(s1.toString());
return val;
@ -1171,7 +1182,7 @@ public final class CronExpression implements Serializable, Cloneable {
public Date getTimeAfter(Date afterTime) {
// Computation is based on Gregorian year only.
Calendar cl = new java.util.GregorianCalendar(getTimeZone());
Calendar cl = new java.util.GregorianCalendar(getTimeZone());
// move ahead one second, since we're computing the time *after* the
// given time
@ -1185,7 +1196,7 @@ public final class CronExpression implements Serializable, Cloneable {
while (!gotOne) {
//if (endTime != null && cl.getTime().after(endTime)) return null;
if(cl.get(Calendar.YEAR) > 2999) { // prevent endless loop...
if (cl.get(Calendar.YEAR) > 2999) { // prevent endless loop...
return null;
}
@ -1255,20 +1266,20 @@ public final class CronExpression implements Serializable, Cloneable {
// 1-based
t = -1;
int tmon = mon;
// get day...................................................
boolean dayOfMSpec = !daysOfMonth.contains(NO_SPEC);
boolean dayOfWSpec = !daysOfWeek.contains(NO_SPEC);
if (dayOfMSpec && !dayOfWSpec) { // get day by day of month rule
st = daysOfMonth.tailSet(day);
if (lastdayOfMonth) {
if(!nearestWeekday) {
if (!nearestWeekday) {
t = day;
day = getLastDayOfMonth(mon, cl.get(Calendar.YEAR));
day -= lastdayOffset;
if(t > day) {
if (t > day) {
mon++;
if(mon > 12) {
if (mon > 12) {
mon = 1;
tmon = 3333; // ensure test of mon != tmon further below fails
cl.add(Calendar.YEAR, 1);
@ -1279,72 +1290,72 @@ public final class CronExpression implements Serializable, Cloneable {
t = day;
day = getLastDayOfMonth(mon, cl.get(Calendar.YEAR));
day -= lastdayOffset;
java.util.Calendar tcal = java.util.Calendar.getInstance(getTimeZone());
Calendar tcal = Calendar.getInstance(getTimeZone());
tcal.set(Calendar.SECOND, 0);
tcal.set(Calendar.MINUTE, 0);
tcal.set(Calendar.HOUR_OF_DAY, 0);
tcal.set(Calendar.DAY_OF_MONTH, day);
tcal.set(Calendar.MONTH, mon - 1);
tcal.set(Calendar.YEAR, cl.get(Calendar.YEAR));
int ldom = getLastDayOfMonth(mon, cl.get(Calendar.YEAR));
int dow = tcal.get(Calendar.DAY_OF_WEEK);
if(dow == Calendar.SATURDAY && day == 1) {
if (dow == Calendar.SATURDAY && day == 1) {
day += 2;
} else if(dow == Calendar.SATURDAY) {
} else if (dow == Calendar.SATURDAY) {
day -= 1;
} else if(dow == Calendar.SUNDAY && day == ldom) {
} else if (dow == Calendar.SUNDAY && day == ldom) {
day -= 2;
} else if(dow == Calendar.SUNDAY) {
} else if (dow == Calendar.SUNDAY) {
day += 1;
}
tcal.set(Calendar.SECOND, sec);
tcal.set(Calendar.MINUTE, min);
tcal.set(Calendar.HOUR_OF_DAY, hr);
tcal.set(Calendar.DAY_OF_MONTH, day);
tcal.set(Calendar.MONTH, mon - 1);
Date nTime = tcal.getTime();
if(nTime.before(afterTime)) {
if (nTime.before(afterTime)) {
day = 1;
mon++;
}
}
} else if(nearestWeekday) {
} else if (nearestWeekday) {
t = day;
day = daysOfMonth.first();
java.util.Calendar tcal = java.util.Calendar.getInstance(getTimeZone());
Calendar tcal = Calendar.getInstance(getTimeZone());
tcal.set(Calendar.SECOND, 0);
tcal.set(Calendar.MINUTE, 0);
tcal.set(Calendar.HOUR_OF_DAY, 0);
tcal.set(Calendar.DAY_OF_MONTH, day);
tcal.set(Calendar.MONTH, mon - 1);
tcal.set(Calendar.YEAR, cl.get(Calendar.YEAR));
int ldom = getLastDayOfMonth(mon, cl.get(Calendar.YEAR));
int dow = tcal.get(Calendar.DAY_OF_WEEK);
if(dow == Calendar.SATURDAY && day == 1) {
if (dow == Calendar.SATURDAY && day == 1) {
day += 2;
} else if(dow == Calendar.SATURDAY) {
} else if (dow == Calendar.SATURDAY) {
day -= 1;
} else if(dow == Calendar.SUNDAY && day == ldom) {
} else if (dow == Calendar.SUNDAY && day == ldom) {
day -= 2;
} else if(dow == Calendar.SUNDAY) {
} else if (dow == Calendar.SUNDAY) {
day += 1;
}
tcal.set(Calendar.SECOND, sec);
tcal.set(Calendar.MINUTE, min);
tcal.set(Calendar.HOUR_OF_DAY, hr);
tcal.set(Calendar.DAY_OF_MONTH, day);
tcal.set(Calendar.MONTH, mon - 1);
Date nTime = tcal.getTime();
if(nTime.before(afterTime)) {
if (nTime.before(afterTime)) {
day = daysOfMonth.first();
mon++;
}
@ -1361,7 +1372,7 @@ public final class CronExpression implements Serializable, Cloneable {
day = daysOfMonth.first();
mon++;
}
if (day != t || mon != tmon) {
cl.set(Calendar.SECOND, 0);
cl.set(Calendar.MINUTE, 0);
@ -1442,8 +1453,8 @@ public final class CronExpression implements Serializable, Cloneable {
daysToAdd = (nthdayOfWeek - weekOfMonth) * 7;
day += daysToAdd;
if (daysToAdd < 0
|| day > getLastDayOfMonth(mon, cl
.get(Calendar.YEAR))) {
|| day > getLastDayOfMonth(mon, cl
.get(Calendar.YEAR))) {
cl.set(Calendar.SECOND, 0);
cl.set(Calendar.MINUTE, 0);
cl.set(Calendar.HOUR_OF_DAY, 0);
@ -1501,7 +1512,7 @@ public final class CronExpression implements Serializable, Cloneable {
}
} else { // dayOfWSpec && !dayOfMSpec
throw new UnsupportedOperationException(
"Support for specifying both a day-of-week AND a day-of-month parameter is not implemented.");
"Support for specifying both a day-of-week AND a day-of-month parameter is not implemented.");
}
cl.set(Calendar.DAY_OF_MONTH, day);
@ -1575,35 +1586,35 @@ public final class CronExpression implements Serializable, Cloneable {
/**
* Advance the calendar to the particular hour paying particular attention
* to daylight saving problems.
*
* @param cal the calendar to operate on
*
* @param cal the calendar to operate on
* @param hour the hour to set
*/
protected void setCalendarHour(Calendar cal, int hour) {
cal.set(java.util.Calendar.HOUR_OF_DAY, hour);
if (cal.get(java.util.Calendar.HOUR_OF_DAY) != hour && hour != 24) {
cal.set(java.util.Calendar.HOUR_OF_DAY, hour + 1);
cal.set(Calendar.HOUR_OF_DAY, hour);
if (cal.get(Calendar.HOUR_OF_DAY) != hour && hour != 24) {
cal.set(Calendar.HOUR_OF_DAY, hour + 1);
}
}
/**
* NOT YET IMPLEMENTED: Returns the time before the given time
* that the <code>CronExpression</code> matches.
*/
public Date getTimeBefore(Date endTime) {
*/
public Date getTimeBefore(Date endTime) {
// FUTURE_TODO: implement QUARTZ-423
return null;
}
/**
* NOT YET IMPLEMENTED: Returns the final time that the
* NOT YET IMPLEMENTED: Returns the final time that the
* <code>CronExpression</code> will match.
*/
public Date getFinalFireTime() {
// FUTURE_TODO: implement QUARTZ-423
return null;
}
protected boolean isLeapYear(int year) {
return ((year % 4 == 0 && year % 100 != 0) || (year % 400 == 0));
}
@ -1637,21 +1648,21 @@ public final class CronExpression implements Serializable, Cloneable {
return 31;
default:
throw new IllegalArgumentException("Illegal month number: "
+ monthNum);
+ monthNum);
}
}
private void readObject(java.io.ObjectInputStream stream)
throws java.io.IOException, ClassNotFoundException {
stream.defaultReadObject();
try {
buildExpression(cronExpression);
} catch (Exception ignore) {
} // never happens
}
}
@Override
@Deprecated
public Object clone() {

View File

@ -7,6 +7,7 @@ public class XxlJobException extends RuntimeException {
public XxlJobException() {
}
public XxlJobException(String message) {
super(message);
}

View File

@ -19,8 +19,9 @@ public class XxlJobGroup {
// registry list
private List<String> registryList; // 执行器地址列表(系统注册)
public List<String> getRegistryList() {
if (addressList!=null && addressList.trim().length()>0) {
if (addressList != null && addressList.trim().length() > 0) {
registryList = new ArrayList<String>(Arrays.asList(addressList.split(",")));
}
return registryList;

View File

@ -31,7 +31,7 @@ public class XxlJobInfo {
private int executorTimeout; // 任务执行超时时间,单位秒
private int executorFailRetryCount; // 失败重试次数
private String glueType; // GLUE类型 #com.xxl.job.core.glue.GlueTypeEnum
private String glueType; // GLUE类型 #com.xxl.job.core.glue.GlueTypeEnum
private String glueSource; // GLUE源代码
private String glueRemark; // GLUE备注
private Date glueUpdatetime; // GLUE更新时间

View File

@ -1,4 +1,4 @@
//package com.xxl.job.admin.core.jobbean;
package com.xxl.job.admin.core.old;//package com.xxl.job.admin.core.jobbean;
//
//import com.xxl.job.admin.core.thread.JobTriggerPoolHelper;
//import com.xxl.job.admin.core.trigger.TriggerTypeEnum;
@ -29,4 +29,4 @@
//
// }
//
//}
//}

View File

@ -1,4 +1,4 @@
//package com.xxl.job.admin.core.schedule;
package com.xxl.job.admin.core.old;//package com.xxl.job.admin.core.schedule;
//
//import com.xxl.job.admin.core.conf.XxlJobAdminConfig;
//import com.xxl.job.admin.core.jobbean.RemoteHttpJobBean;
@ -410,4 +410,4 @@
// return jobList;
// }*/
//
//}
//}

View File

@ -1,4 +1,4 @@
//package com.xxl.job.admin.core.quartz;
package com.xxl.job.admin.core.old;//package com.xxl.job.admin.core.quartz;
//
//import org.quartz.SchedulerConfigException;
//import org.quartz.spi.ThreadPool;

View File

@ -30,13 +30,14 @@ public enum ExecutorRouteStrategyEnum {
public String getTitle() {
return title;
}
public ExecutorRouter getRouter() {
return router;
}
public static ExecutorRouteStrategyEnum match(String name, ExecutorRouteStrategyEnum defaultItem){
public static ExecutorRouteStrategyEnum match(String name, ExecutorRouteStrategyEnum defaultItem) {
if (name != null) {
for (ExecutorRouteStrategyEnum item: ExecutorRouteStrategyEnum.values()) {
for (ExecutorRouteStrategyEnum item : ExecutorRouteStrategyEnum.values()) {
if (item.name().equals(name)) {
return item;
}

View File

@ -17,7 +17,7 @@ public abstract class ExecutorRouter {
* route address
*
* @param addressList
* @return ReturnT.content=address
* @return ReturnT.content=address
*/
public abstract ReturnT<String> route(TriggerParam triggerParam, List<String> addressList);

View File

@ -26,13 +26,13 @@ public class ExecutorRouteBusyover extends ExecutorRouter {
idleBeatResult = executorBiz.idleBeat(new IdleBeatParam(triggerParam.getJobId()));
} catch (Exception e) {
logger.error(e.getMessage(), e);
idleBeatResult = new ReturnT<String>(ReturnT.FAIL_CODE, ""+e );
idleBeatResult = new ReturnT<String>(ReturnT.FAIL_CODE, "" + e);
}
idleBeatResultSB.append( (idleBeatResultSB.length()>0)?"<br><br>":"")
.append(I18nUtil.getString("jobconf_idleBeat") + "")
.append("<br>address").append(address)
.append("<br>code").append(idleBeatResult.getCode())
.append("<br>msg").append(idleBeatResult.getMsg());
idleBeatResultSB.append((idleBeatResultSB.length() > 0) ? "<br><br>" : "")
.append(I18nUtil.getString("jobconf_idleBeat") + "")
.append("<br>address").append(address)
.append("<br>code").append(idleBeatResult.getCode())
.append("<br>msg").append(idleBeatResult.getMsg());
// beat success
if (idleBeatResult.getCode() == ReturnT.SUCCESS_CODE) {

View File

@ -13,8 +13,8 @@ import java.util.TreeMap;
/**
* 分组下机器地址相同不同JOB均匀散列在不同机器上保证分组下机器分配JOB平均且每个JOB固定调度其中一台机器
* a、virtual node解决不均衡问题
* b、hash method replace hashCodeString的hashCode可能重复需要进一步扩大hashCode的取值范围
* a、virtual node解决不均衡问题
* b、hash method replace hashCodeString的hashCode可能重复需要进一步扩大hashCode的取值范围
* Created by xuxueli on 17/3/10.
*/
public class ExecutorRouteConsistentHash extends ExecutorRouter {
@ -23,6 +23,7 @@ public class ExecutorRouteConsistentHash extends ExecutorRouter {
/**
* get hash code on 2^32 ring (md5散列的方式计算hash值)
*
* @param key
* @return
*/
@ -48,9 +49,9 @@ public class ExecutorRouteConsistentHash extends ExecutorRouter {
// hash code, Truncate to 32-bits
long hashCode = ((long) (digest[3] & 0xFF) << 24)
| ((long) (digest[2] & 0xFF) << 16)
| ((long) (digest[1] & 0xFF) << 8)
| (digest[0] & 0xFF);
| ((long) (digest[2] & 0xFF) << 16)
| ((long) (digest[1] & 0xFF) << 8)
| (digest[0] & 0xFF);
long truncateHashCode = hashCode & 0xffffffffL;
return truncateHashCode;
@ -61,7 +62,7 @@ public class ExecutorRouteConsistentHash extends ExecutorRouter {
// ------A1------A2-------A3------
// -----------J1------------------
TreeMap<Long, String> addressRing = new TreeMap<Long, String>();
for (String address: addressList) {
for (String address : addressList) {
for (int i = 0; i < VIRTUAL_NODE_NUM; i++) {
long addressHash = hash("SHARD-" + address + "-NODE-" + i);
addressRing.put(addressHash, address);

View File

@ -26,13 +26,13 @@ public class ExecutorRouteFailover extends ExecutorRouter {
beatResult = executorBiz.beat();
} catch (Exception e) {
logger.error(e.getMessage(), e);
beatResult = new ReturnT<String>(ReturnT.FAIL_CODE, ""+e );
beatResult = new ReturnT<String>(ReturnT.FAIL_CODE, "" + e);
}
beatResultSB.append( (beatResultSB.length()>0)?"<br><br>":"")
.append(I18nUtil.getString("jobconf_beat") + "")
.append("<br>address").append(address)
.append("<br>code").append(beatResult.getCode())
.append("<br>msg").append(beatResult.getMsg());
beatResultSB.append((beatResultSB.length() > 0) ? "<br><br>" : "")
.append(I18nUtil.getString("jobconf_beat") + "")
.append("<br>address").append(address)
.append("<br>code").append(beatResult.getCode())
.append("<br>msg").append(beatResult.getMsg());
// beat success
if (beatResult.getCode() == ReturnT.SUCCESS_CODE) {

View File

@ -12,7 +12,7 @@ import java.util.List;
public class ExecutorRouteFirst extends ExecutorRouter {
@Override
public ReturnT<String> route(TriggerParam triggerParam, List<String> addressList){
public ReturnT<String> route(TriggerParam triggerParam, List<String> addressList) {
return new ReturnT<String>(addressList.get(0));
}

View File

@ -10,9 +10,9 @@ import java.util.concurrent.ConcurrentMap;
/**
* 单个JOB对应的每个执行器使用频率最低的优先被选举
* a(*)、LFU(Least Frequently Used):最不经常使用,频率/次数
* b、LRU(Least Recently Used):最近最久未使用,时间
*
* a(*)、LFU(Least Frequently Used):最不经常使用,频率/次数
* b、LRU(Least Recently Used):最近最久未使用,时间
* <p>
* Created by xuxueli on 17/3/10.
*/
public class ExecutorRouteLFU extends ExecutorRouter {
@ -25,7 +25,7 @@ public class ExecutorRouteLFU extends ExecutorRouter {
// cache clear
if (System.currentTimeMillis() > CACHE_VALID_TIME) {
jobLfuMap.clear();
CACHE_VALID_TIME = System.currentTimeMillis() + 1000*60*60*24;
CACHE_VALID_TIME = System.currentTimeMillis() + 1000 * 60 * 60 * 24;
}
// lfu item init
@ -36,20 +36,20 @@ public class ExecutorRouteLFU extends ExecutorRouter {
}
// put new
for (String address: addressList) {
if (!lfuItemMap.containsKey(address) || lfuItemMap.get(address) >1000000 ) {
for (String address : addressList) {
if (!lfuItemMap.containsKey(address) || lfuItemMap.get(address) > 1000000) {
lfuItemMap.put(address, new Random().nextInt(addressList.size())); // 初始化时主动Random一次缓解首次压力
}
}
// remove old
List<String> delKeys = new ArrayList<>();
for (String existKey: lfuItemMap.keySet()) {
for (String existKey : lfuItemMap.keySet()) {
if (!addressList.contains(existKey)) {
delKeys.add(existKey);
}
}
if (delKeys.size() > 0) {
for (String delKey: delKeys) {
for (String delKey : delKeys) {
lfuItemMap.remove(delKey);
}
}

View File

@ -12,9 +12,9 @@ import java.util.concurrent.ConcurrentMap;
/**
* 单个JOB对应的每个执行器最久为使用的优先被选举
* a、LFU(Least Frequently Used):最不经常使用,频率/次数
* b(*)、LRU(Least Recently Used):最近最久未使用,时间
*
* a、LFU(Least Frequently Used):最不经常使用,频率/次数
* b(*)、LRU(Least Recently Used):最近最久未使用,时间
* <p>
* Created by xuxueli on 17/3/10.
*/
public class ExecutorRouteLRU extends ExecutorRouter {
@ -27,7 +27,7 @@ public class ExecutorRouteLRU extends ExecutorRouter {
// cache clear
if (System.currentTimeMillis() > CACHE_VALID_TIME) {
jobLRUMap.clear();
CACHE_VALID_TIME = System.currentTimeMillis() + 1000*60*60*24;
CACHE_VALID_TIME = System.currentTimeMillis() + 1000 * 60 * 60 * 24;
}
// init lru
@ -43,20 +43,20 @@ public class ExecutorRouteLRU extends ExecutorRouter {
}
// put new
for (String address: addressList) {
for (String address : addressList) {
if (!lruItem.containsKey(address)) {
lruItem.put(address, address);
}
}
// remove old
List<String> delKeys = new ArrayList<>();
for (String existKey: lruItem.keySet()) {
for (String existKey : lruItem.keySet()) {
if (!addressList.contains(existKey)) {
delKeys.add(existKey);
}
}
if (delKeys.size() > 0) {
for (String delKey: delKeys) {
for (String delKey : delKeys) {
lruItem.remove(delKey);
}
}

View File

@ -13,7 +13,7 @@ public class ExecutorRouteLast extends ExecutorRouter {
@Override
public ReturnT<String> route(TriggerParam triggerParam, List<String> addressList) {
return new ReturnT<String>(addressList.get(addressList.size()-1));
return new ReturnT<String>(addressList.get(addressList.size() - 1));
}
}

View File

@ -22,7 +22,7 @@ public class ExecutorRouteRound extends ExecutorRouter {
// cache clear
if (System.currentTimeMillis() > CACHE_VALID_TIME) {
routeCountEachJob.clear();
CACHE_VALID_TIME = System.currentTimeMillis() + 1000*60*60*24;
CACHE_VALID_TIME = System.currentTimeMillis() + 1000 * 60 * 60 * 24;
}
AtomicInteger count = routeCountEachJob.get(jobId);
@ -39,7 +39,7 @@ public class ExecutorRouteRound extends ExecutorRouter {
@Override
public ReturnT<String> route(TriggerParam triggerParam, List<String> addressList) {
String address = addressList.get(count(triggerParam.getJobId())%addressList.size());
String address = addressList.get(count(triggerParam.getJobId()) % addressList.size());
return new ReturnT<String>(address);
}

View File

@ -27,8 +27,8 @@ public enum MisfireStrategyEnum {
return title;
}
public static MisfireStrategyEnum match(String name, MisfireStrategyEnum defaultItem){
for (MisfireStrategyEnum item: MisfireStrategyEnum.values()) {
public static MisfireStrategyEnum match(String name, MisfireStrategyEnum defaultItem) {
for (MisfireStrategyEnum item : MisfireStrategyEnum.values()) {
if (item.name().equals(name)) {
return item;
}

View File

@ -34,8 +34,8 @@ public enum ScheduleTypeEnum {
return title;
}
public static ScheduleTypeEnum match(String name, ScheduleTypeEnum defaultItem){
for (ScheduleTypeEnum item: ScheduleTypeEnum.values()) {
public static ScheduleTypeEnum match(String name, ScheduleTypeEnum defaultItem) {
for (ScheduleTypeEnum item : ScheduleTypeEnum.values()) {
if (item.name().equals(name)) {
return item;
}

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