getAllJobs() {
+ return sysJobRepository.findAll();
+ }
+
+ public Boolean updateSysJob(SysJob sysJob) {
+ SysJob job = sysJobRepository.saveAndFlush(sysJob);
+ if (job != null) {
+ //更新成功
+ SchedulingRunnable schedulingRunnable = new SchedulingRunnable(sysJob.getBeanName(), sysJob.getMethodName(), sysJob.getMethodParams());
+ if (sysJob.getStatus() == 1) {
+ //定时任务是开启状态
+ cronTaskRegistrar.addCronTask(schedulingRunnable, sysJob.getCronExpression());
+ }else{
+ //定时任务是关闭状态,移除定时任务
+ cronTaskRegistrar.removeCronTask(schedulingRunnable);
+ }
+ return true;
+ }
+ return false;
+ }
+}
diff --git a/scheduling/src/main/java/org/javaboy/scheduling/taskdemo/SchedulingTaskDemo.java b/scheduling/src/main/java/org/javaboy/scheduling/taskdemo/SchedulingTaskDemo.java
new file mode 100644
index 0000000..e5c6fb4
--- /dev/null
+++ b/scheduling/src/main/java/org/javaboy/scheduling/taskdemo/SchedulingTaskDemo.java
@@ -0,0 +1,22 @@
+package org.javaboy.scheduling.taskdemo;
+
+import org.springframework.stereotype.Component;
+
+/**
+ * @author 江南一点雨
+ * @微信公众号 江南一点雨
+ * @网站 http://www.itboyhub.com
+ * @国际站 http://www.javaboy.org
+ * @微信 a_java_boy
+ * @GitHub https://github.com/lenve
+ * @Gitee https://gitee.com/lenve
+ */
+@Component
+public class SchedulingTaskDemo {
+ public void taskWithParams(String params) {
+ System.out.println("执行带参数的定时任务..." + params);
+ }
+ public void taskWithoutParams() {
+ System.out.println("执行不带参数的定时任务...");
+ }
+}
diff --git a/scheduling/src/main/resources/application.yaml b/scheduling/src/main/resources/application.yaml
new file mode 100644
index 0000000..1a8fc4a
--- /dev/null
+++ b/scheduling/src/main/resources/application.yaml
@@ -0,0 +1,14 @@
+spring:
+ datasource:
+ username: root
+ password: 123
+ url: jdbc:mysql:///scheduling2?serverTimezone=Asia/Shanghai
+
+ jpa:
+ database-platform: mysql
+ database: mysql
+ hibernate:
+ ddl-auto: update
+ properties:
+ hibernate:
+ dialect: org.hibernate.dialect.MySQL57Dialect
\ No newline at end of file
diff --git a/scheduling/src/main/resources/static/index.html b/scheduling/src/main/resources/static/index.html
new file mode 100644
index 0000000..6a89173
--- /dev/null
+++ b/scheduling/src/main/resources/static/index.html
@@ -0,0 +1,132 @@
+
+
+
+
+ 定时任务管理系统
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {{scope.row.cronExpression}}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 编辑作业
+ 删除作业
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/scheduling/src/test/java/org/javaboy/scheduling/SchedulingApplicationTests.java b/scheduling/src/test/java/org/javaboy/scheduling/SchedulingApplicationTests.java
new file mode 100644
index 0000000..23808a3
--- /dev/null
+++ b/scheduling/src/test/java/org/javaboy/scheduling/SchedulingApplicationTests.java
@@ -0,0 +1,13 @@
+package org.javaboy.scheduling;
+
+import org.junit.jupiter.api.Test;
+import org.springframework.boot.test.context.SpringBootTest;
+
+@SpringBootTest
+class SchedulingApplicationTests {
+
+ @Test
+ void contextLoads() {
+ }
+
+}