From ab0d02a473e2bfb57cfd2bc7defcfbdacb802ce0 Mon Sep 17 00:00:00 2001
From: Zheng Jie <201507802@qq.com>
Date: Tue, 2 Apr 2024 20:22:02 +0800
Subject: [PATCH 01/14] update
---
README.md | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/README.md b/README.md
index ea0770a2..0312d08e 100644
--- a/README.md
+++ b/README.md
@@ -26,12 +26,13 @@
| github | https://github.com/elunez/eladmin | https://github.com/elunez/eladmin-web |
| 码云 | https://gitee.com/elunez/eladmin | https://gitee.com/elunez/eladmin-web |
-#### 赞助商 | Sponsor
-
-
-
+#### VPS推荐
+
+
+使用优惠码: `BWHCCNCXVV`,可获得 6.81% 的折扣, [查看介绍](https://bwhstock.in/)
+
#### 主要特性
- 使用最新技术栈,社区资源丰富。
- 高效率开发,代码生成器可一键生成前后端代码
From 3e659922559db3c73037ff0e5e0372b276e20003 Mon Sep 17 00:00:00 2001
From: Zheng Jie <201507802@qq.com>
Date: Fri, 24 May 2024 16:11:33 +0800
Subject: [PATCH 02/14] update README.md
---
README.md | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
diff --git a/README.md b/README.md
index 0312d08e..084873ab 100644
--- a/README.md
+++ b/README.md
@@ -26,12 +26,10 @@
| github | https://github.com/elunez/eladmin | https://github.com/elunez/eladmin-web |
| 码云 | https://gitee.com/elunez/eladmin | https://gitee.com/elunez/eladmin-web |
-#### VPS推荐
-
-
-
+#### 赞助商 | Sponsor
-使用优惠码: `BWHCCNCXVV`,可获得 6.81% 的折扣, [查看介绍](https://bwhstock.in/)
+
+
#### 主要特性
- 使用最新技术栈,社区资源丰富。
From 0494f6ad17b93817dbb5c8453e3d76242ca4a5d6 Mon Sep 17 00:00:00 2001
From: Zheng Jie <201507802@qq.com>
Date: Fri, 9 Aug 2024 20:03:02 +0800
Subject: [PATCH 03/14] =?UTF-8?q?feat:=20quartz=20=E5=88=86=E5=B8=83?=
=?UTF-8?q?=E5=BC=8F=E6=94=AF=E6=8C=81=EF=BC=8C=E9=BB=98=E8=AE=A4=E5=8D=95?=
=?UTF-8?q?=E6=9C=BA=E8=BF=90=E8=A1=8C=EF=BC=8C=E5=A6=82=E6=9E=9C=E9=9C=80?=
=?UTF-8?q?=E8=A6=81=E6=94=AF=E6=8C=81=E5=88=86=E5=B8=83=E5=BC=8F=E5=8F=AF?=
=?UTF-8?q?=E4=BB=A5=E6=9F=A5=E7=9C=8B=20application-quartz.yml=20?=
=?UTF-8?q?=E6=B3=A8=E9=87=8A?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
eladmin-system/pom.xml | 12 +-
.../modules/quartz/config/QuartzConfig.java | 24 ++-
.../modules/quartz/utils/QuartzManage.java | 9 +-
.../resources/config/application-quartz.yml | 29 +++
.../src/main/resources/config/application.yml | 1 +
sql/quartz.sql | 170 ++++++++++++++++++
6 files changed, 231 insertions(+), 14 deletions(-)
create mode 100644 eladmin-system/src/main/resources/config/application-quartz.yml
create mode 100644 sql/quartz.sql
diff --git a/eladmin-system/pom.xml b/eladmin-system/pom.xml
index 9119bc12..e1799196 100644
--- a/eladmin-system/pom.xml
+++ b/eladmin-system/pom.xml
@@ -45,6 +45,12 @@
spring-boot-starter-websocket
+
+
+ org.springframework.boot
+ spring-boot-starter-quartz
+
+
io.jsonwebtoken
@@ -62,12 +68,6 @@
${jjwt.version}
-
-
- org.quartz-scheduler
- quartz
-
-
ch.ethz.ganymed
diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/quartz/config/QuartzConfig.java b/eladmin-system/src/main/java/me/zhengjie/modules/quartz/config/QuartzConfig.java
index 99f2e50e..d542a36a 100644
--- a/eladmin-system/src/main/java/me/zhengjie/modules/quartz/config/QuartzConfig.java
+++ b/eladmin-system/src/main/java/me/zhengjie/modules/quartz/config/QuartzConfig.java
@@ -15,9 +15,13 @@
*/
package me.zhengjie.modules.quartz.config;
+import lombok.extern.slf4j.Slf4j;
import org.quartz.spi.TriggerFiredBundle;
+import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.config.AutowireCapableBeanFactory;
import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.Scope;
+import org.springframework.lang.NonNull;
import org.springframework.scheduling.quartz.AdaptableJobFactory;
import org.springframework.stereotype.Component;
@@ -26,7 +30,9 @@ import org.springframework.stereotype.Component;
* @author /
* @date 2019-01-07
*/
+@Slf4j
@Configuration
+@Scope("singleton")
public class QuartzConfig {
/**
@@ -37,16 +43,24 @@ public class QuartzConfig {
private final AutowireCapableBeanFactory capableBeanFactory;
+ @Autowired
public QuartzJobFactory(AutowireCapableBeanFactory capableBeanFactory) {
this.capableBeanFactory = capableBeanFactory;
}
+ @NonNull
@Override
- protected Object createJobInstance(TriggerFiredBundle bundle) throws Exception {
- //调用父类的方法,把Job注入到spring中
- Object jobInstance = super.createJobInstance(bundle);
- capableBeanFactory.autowireBean(jobInstance);
- return jobInstance;
+ protected Object createJobInstance(@NonNull TriggerFiredBundle bundle) throws Exception {
+ try {
+ // 调用父类的方法,把Job注入到spring中
+ Object jobInstance = super.createJobInstance(bundle);
+ capableBeanFactory.autowireBean(jobInstance);
+ log.debug("Job instance created and autowired: {}", jobInstance.getClass().getName());
+ return jobInstance;
+ } catch (Exception e) {
+ log.error("Error creating job instance for bundle: {}", bundle, e);
+ throw e;
+ }
}
}
}
diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/quartz/utils/QuartzManage.java b/eladmin-system/src/main/java/me/zhengjie/modules/quartz/utils/QuartzManage.java
index e0cf1e0a..4dbac76b 100644
--- a/eladmin-system/src/main/java/me/zhengjie/modules/quartz/utils/QuartzManage.java
+++ b/eladmin-system/src/main/java/me/zhengjie/modules/quartz/utils/QuartzManage.java
@@ -20,7 +20,6 @@ import me.zhengjie.exception.BadRequestException;
import me.zhengjie.modules.quartz.domain.QuartzJob;
import org.quartz.*;
import org.quartz.impl.triggers.CronTriggerImpl;
-import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.util.Date;
@@ -57,8 +56,12 @@ public class QuartzManage {
//重置启动时间
((CronTriggerImpl)cronTrigger).setStartTime(new Date());
- //执行定时任务
- scheduler.scheduleJob(jobDetail,cronTrigger);
+ //执行定时任务,如果是持久化的,这里会报错,捕获输出
+ try {
+ scheduler.scheduleJob(jobDetail,cronTrigger);
+ } catch (ObjectAlreadyExistsException e) {
+ log.warn("定时任务已存在,跳过加载");
+ }
// 暂停任务
if (quartzJob.getIsPause()) {
diff --git a/eladmin-system/src/main/resources/config/application-quartz.yml b/eladmin-system/src/main/resources/config/application-quartz.yml
new file mode 100644
index 00000000..561482c6
--- /dev/null
+++ b/eladmin-system/src/main/resources/config/application-quartz.yml
@@ -0,0 +1,29 @@
+# 配置 quartz 分布式支持, sql 文件在 sql 目录下,需要导入到数据库,并且需要修改 application.yml 文件的 active: dev 配置
+spring:
+ quartz:
+ # 必需,指定使用 JDBC 存储
+ job-store-type: jdbc
+ properties:
+ org:
+ quartz:
+ scheduler:
+ # 必需,指定调度器实例的名称
+ instanceName: eladmin
+ # 必需,指定调度器实例的 ID
+ instanceId: auto
+ threadPool:
+ # 可选,线程池的线程数量,可以根据需要调整
+ threadCount: 5
+ jobStore:
+ # 可选,如果你不需要集群,可以去掉
+ isClustered: true
+ # 可选,集群检查间隔时间,可以根据需要调整
+ clusterCheckinInterval: 10000
+ # 必需,指定 JDBC 驱动代理类
+ driverDelegateClass: org.quartz.impl.jdbcjobstore.StdJDBCDelegate
+ # 可选,是否使用属性存储,可以根据需要调整
+ useProperties: false
+ # 必需,指定表的前缀
+ tablePrefix: qrtz_
+ # 可选,指定误触发阈值,可以根据需要调整
+ misfireThreshold: 60000
\ No newline at end of file
diff --git a/eladmin-system/src/main/resources/config/application.yml b/eladmin-system/src/main/resources/config/application.yml
index 11884259..6eb7fd4e 100644
--- a/eladmin-system/src/main/resources/config/application.yml
+++ b/eladmin-system/src/main/resources/config/application.yml
@@ -8,6 +8,7 @@ spring:
freemarker:
check-template-location: false
profiles:
+ # 激活的环境,如果需要 quartz 分布式支持,需要修改 active: dev,quartz
active: dev
data:
redis:
diff --git a/sql/quartz.sql b/sql/quartz.sql
new file mode 100644
index 00000000..0c71cb59
--- /dev/null
+++ b/sql/quartz.sql
@@ -0,0 +1,170 @@
+drop table if exists qrtz_fired_triggers;
+drop table if exists qrtz_paused_trigger_grps;
+drop table if exists qrtz_scheduler_state;
+drop table if exists qrtz_locks;
+drop table if exists qrtz_simple_triggers;
+drop table if exists qrtz_simprop_triggers;
+drop table if exists qrtz_cron_triggers;
+drop table if exists qrtz_blob_triggers;
+drop table if exists qrtz_triggers;
+drop table if exists qrtz_job_details;
+drop table if exists qrtz_calendars;
+
+create table qrtz_job_details(
+sched_name varchar(120) not null,
+job_name varchar(200) not null,
+job_group varchar(200) not null,
+description varchar(250) null,
+job_class_name varchar(250) not null,
+is_durable varchar(1) not null,
+is_nonconcurrent varchar(1) not null,
+is_update_data varchar(1) not null,
+requests_recovery varchar(1) not null,
+job_data blob null,
+primary key (sched_name, job_name, job_group))
+engine=innodb;
+
+create table qrtz_triggers (
+sched_name varchar(120) not null,
+trigger_name varchar(200) not null,
+trigger_group varchar(200) not null,
+job_name varchar(200) not null,
+job_group varchar(200) not null,
+description varchar(250) null,
+next_fire_time bigint(13) null,
+prev_fire_time bigint(13) null,
+priority integer null,
+trigger_state varchar(16) not null,
+trigger_type varchar(8) not null,
+start_time bigint(13) not null,
+end_time bigint(13) null,
+calendar_name varchar(200) null,
+misfire_instr smallint(2) null,
+job_data blob null,
+primary key (sched_name, trigger_name, trigger_group),
+foreign key (sched_name, job_name, job_group)
+references qrtz_job_details(sched_name, job_name, job_group))
+engine=innodb;
+
+create table qrtz_simple_triggers (
+sched_name varchar(120) not null,
+trigger_name varchar(200) not null,
+trigger_group varchar(200) not null,
+repeat_count bigint(7) not null,
+repeat_interval bigint(12) not null,
+times_triggered bigint(10) not null,
+primary key (sched_name, trigger_name, trigger_group),
+foreign key (sched_name, trigger_name, trigger_group)
+references qrtz_triggers(sched_name, trigger_name, trigger_group))
+engine=innodb;
+
+create table qrtz_cron_triggers (
+sched_name varchar(120) not null,
+trigger_name varchar(200) not null,
+trigger_group varchar(200) not null,
+cron_expression varchar(120) not null,
+time_zone_id varchar(80),
+primary key (sched_name, trigger_name, trigger_group),
+foreign key (sched_name, trigger_name, trigger_group)
+references qrtz_triggers(sched_name, trigger_name, trigger_group))
+engine=innodb;
+
+create table qrtz_simprop_triggers (
+sched_name varchar(120) not null,
+trigger_name varchar(200) not null,
+trigger_group varchar(200) not null,
+str_prop_1 varchar(512) null,
+str_prop_2 varchar(512) null,
+str_prop_3 varchar(512) null,
+int_prop_1 int null,
+int_prop_2 int null,
+long_prop_1 bigint null,
+long_prop_2 bigint null,
+dec_prop_1 numeric(13, 4) null,
+dec_prop_2 numeric(13, 4) null,
+bool_prop_1 varchar(1) null,
+bool_prop_2 varchar(1) null,
+primary key (sched_name, trigger_name, trigger_group),
+foreign key (sched_name, trigger_name, trigger_group)
+references qrtz_triggers(sched_name, trigger_name, trigger_group))
+engine=innodb;
+
+create table qrtz_blob_triggers (
+sched_name varchar(120) not null,
+trigger_name varchar(200) not null,
+trigger_group varchar(200) not null,
+blob_data blob null,
+primary key (sched_name, trigger_name, trigger_group),
+index (sched_name, trigger_name, trigger_group),
+foreign key (sched_name, trigger_name, trigger_group)
+references qrtz_triggers(sched_name, trigger_name, trigger_group))
+engine=innodb;
+
+create table qrtz_calendars (
+sched_name varchar(120) not null,
+calendar_name varchar(200) not null,
+calendar blob not null,
+primary key (sched_name, calendar_name))
+engine=innodb;
+
+create table qrtz_paused_trigger_grps (
+sched_name varchar(120) not null,
+trigger_group varchar(200) not null,
+primary key (sched_name, trigger_group))
+engine=innodb;
+
+create table qrtz_fired_triggers (
+sched_name varchar(120) not null,
+entry_id varchar(95) not null,
+trigger_name varchar(200) not null,
+trigger_group varchar(200) not null,
+instance_name varchar(200) not null,
+fired_time bigint(13) not null,
+sched_time bigint(13) not null,
+priority integer not null,
+state varchar(16) not null,
+job_name varchar(200) null,
+job_group varchar(200) null,
+is_nonconcurrent varchar(1) null,
+requests_recovery varchar(1) null,
+primary key (sched_name, entry_id))
+engine=innodb;
+
+create table qrtz_scheduler_state (
+sched_name varchar(120) not null,
+instance_name varchar(200) not null,
+last_checkin_time bigint(13) not null,
+checkin_interval bigint(13) not null,
+primary key (sched_name, instance_name))
+engine=innodb;
+
+create table qrtz_locks (
+sched_name varchar(120) not null,
+lock_name varchar(40) not null,
+primary key (sched_name, lock_name))
+engine=innodb;
+
+create index idx_qrtz_j_req_recovery on qrtz_job_details(sched_name, requests_recovery);
+create index idx_qrtz_j_grp on qrtz_job_details(sched_name, job_group);
+
+create index idx_qrtz_t_j on qrtz_triggers(sched_name, job_name, job_group);
+create index idx_qrtz_t_jg on qrtz_triggers(sched_name, job_group);
+create index idx_qrtz_t_c on qrtz_triggers(sched_name, calendar_name);
+create index idx_qrtz_t_g on qrtz_triggers(sched_name, trigger_group);
+create index idx_qrtz_t_state on qrtz_triggers(sched_name, trigger_state);
+create index idx_qrtz_t_n_state on qrtz_triggers(sched_name, trigger_name, trigger_group, trigger_state);
+create index idx_qrtz_t_n_g_state on qrtz_triggers(sched_name, trigger_group, trigger_state);
+create index idx_qrtz_t_next_fire_time on qrtz_triggers(sched_name, next_fire_time);
+create index idx_qrtz_t_nft_st on qrtz_triggers(sched_name, trigger_state, next_fire_time);
+create index idx_qrtz_t_nft_misfire on qrtz_triggers(sched_name, misfire_instr, next_fire_time);
+create index idx_qrtz_t_nft_st_misfire on qrtz_triggers(sched_name, misfire_instr, next_fire_time, trigger_state);
+create index idx_qrtz_t_nft_st_misfire_grp on qrtz_triggers(sched_name, misfire_instr, next_fire_time, trigger_group, trigger_state);
+
+create index idx_qrtz_ft_trig_inst_name on qrtz_fired_triggers(sched_name, instance_name);
+create index idx_qrtz_ft_inst_job_req_rcvry on qrtz_fired_triggers(sched_name, instance_name, requests_recovery);
+create index idx_qrtz_ft_j_g on qrtz_fired_triggers(sched_name, job_name, job_group);
+create index idx_qrtz_ft_jg on qrtz_fired_triggers(sched_name, job_group);
+create index idx_qrtz_ft_t_g on qrtz_fired_triggers(sched_name, trigger_name, trigger_group);
+create index idx_qrtz_ft_tg on qrtz_fired_triggers(sched_name, trigger_group);
+
+commit;
\ No newline at end of file
From f4f76deaf9a1353b25f4df214c35340592c8e9a7 Mon Sep 17 00:00:00 2001
From: Zheng Jie <201507802@qq.com>
Date: Fri, 9 Aug 2024 20:21:32 +0800
Subject: [PATCH 04/14] =?UTF-8?q?fix:=20=E5=88=9D=E5=A7=8B=E5=8C=96sql?=
=?UTF-8?q?=E9=97=AE=E9=A2=98?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
sql/eladmin.sql | 1 -
1 file changed, 1 deletion(-)
diff --git a/sql/eladmin.sql b/sql/eladmin.sql
index 20ee0949..2711d6e9 100644
--- a/sql/eladmin.sql
+++ b/sql/eladmin.sql
@@ -615,7 +615,6 @@ INSERT INTO `sys_roles_menus` VALUES (112, 1);
INSERT INTO `sys_roles_menus` VALUES (113, 1);
INSERT INTO `sys_roles_menus` VALUES (114, 1);
INSERT INTO `sys_roles_menus` VALUES (116, 1);
-INSERT INTO `sys_roles_menus` VALUES (120, 1);
INSERT INTO `sys_roles_menus` VALUES (1, 2);
INSERT INTO `sys_roles_menus` VALUES (2, 2);
INSERT INTO `sys_roles_menus` VALUES (6, 2);
From 08f4860483b4091c5d1383c51380a894fc0952a5 Mon Sep 17 00:00:00 2001
From: l2063610646 <64514383+l2063610646@users.noreply.github.com>
Date: Thu, 19 Sep 2024 10:01:03 +0800
Subject: [PATCH 05/14] =?UTF-8?q?fix(LimitAspect):=20=E4=BF=AE=E5=A4=8Dlua?=
=?UTF-8?q?=E8=84=9A=E6=9C=AC=E6=89=A7=E8=A1=8C=E7=BB=93=E6=9D=9F=E5=90=8E?=
=?UTF-8?q?=EF=BC=8C=E7=B1=BB=E5=9E=8B=E8=BD=AC=E6=8D=A2=E5=A4=B1=E8=B4=A5?=
=?UTF-8?q?=E7=9A=84bug=20(#810)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
* fix(EmailServiceImpl): 解决由于jdk8之后默认禁用了部分tls协议,从而导致发送邮件失败的问题
1、测试jdk版本:jdk1.8.0_351
* fix(LimitAspect): 修复lua脚本执行结束后,类型转换失败的bug
1、测试jdk版本:jdk1.8.0_351、jdk11.0.18
类型转换失败,不能将值转换为Number,用Long进行替代
---
.../src/main/java/me/zhengjie/aspect/LimitAspect.java | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/eladmin-common/src/main/java/me/zhengjie/aspect/LimitAspect.java b/eladmin-common/src/main/java/me/zhengjie/aspect/LimitAspect.java
index 31f40404..4b9a7b8e 100644
--- a/eladmin-common/src/main/java/me/zhengjie/aspect/LimitAspect.java
+++ b/eladmin-common/src/main/java/me/zhengjie/aspect/LimitAspect.java
@@ -71,8 +71,8 @@ public class LimitAspect {
ImmutableList