fix: quartz调度添加IP校验
This commit is contained in:
@@ -46,7 +46,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.dromara.dynamictp</groupId>
|
<groupId>org.dromara.dynamictp</groupId>
|
||||||
<artifactId>dynamic-tp-spring-boot-starter-adapter-webserver</artifactId>
|
<artifactId>dynamic-tp-spring-boot-starter-adapter-webserver</artifactId>
|
||||||
<version>1.1.6.1</version>
|
<version>1.1.7</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- 日志链路追踪 https://tlog.yomahub.com/pages/f62a84/#%E5%90%8C%E6%AD%A5%E6%97%A5%E5%BF%97-->
|
<!-- 日志链路追踪 https://tlog.yomahub.com/pages/f62a84/#%E5%90%8C%E6%AD%A5%E6%97%A5%E5%BF%97-->
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package org.nl.system.service.quartz.config;
|
package org.nl.system.service.quartz.config;
|
||||||
|
|
||||||
|
import cn.hutool.core.net.NetUtil;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.nl.system.service.quartz.ISysQuartzJobService;
|
import org.nl.system.service.quartz.ISysQuartzJobService;
|
||||||
import org.nl.system.service.quartz.dao.SysQuartzJob;
|
import org.nl.system.service.quartz.dao.SysQuartzJob;
|
||||||
@@ -36,5 +37,23 @@ public class JobRunner implements ApplicationRunner {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void run(ApplicationArguments applicationArguments) {
|
public void run(ApplicationArguments applicationArguments) {
|
||||||
|
//本机IP
|
||||||
|
String localIp = NetUtil.getLocalhostStr();
|
||||||
|
System.out.println("本机ip:" + localIp);
|
||||||
|
|
||||||
|
log.info("--------------------注入定时任务---------------------");
|
||||||
|
List<SysQuartzJob> quartzJobs = quartzJobService.findByIsPauseIsFalse();
|
||||||
|
quartzJobs.forEach(job -> {
|
||||||
|
if (localIp.equals(job.getJob_ip())) {
|
||||||
|
log.info("定时任务: [{}], 执行ip: {}, 定时任务开启", job.getJob_name(), localIp);
|
||||||
|
System.out.println("定时任务: " + job.getJob_name() + ", 执行ip: " + localIp + ", 定时任务开启");
|
||||||
|
quartzManage.addJob(job);
|
||||||
|
} else {
|
||||||
|
log.info("定时任务: [{}] 未开启, 本机ip: {} 与 调度ip: {} 不同", job.getJob_name(), localIp, job.getJob_ip());
|
||||||
|
System.out.println("定时任务 " + job.getJob_name() + " 未开启, 本机ip: " + localIp + " 与 调度ip: " + job.getJob_ip() + " 不同");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
log.info("--------------------定时任务注入完成---------------------");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -124,4 +124,9 @@ public class SysQuartzJob implements Serializable {
|
|||||||
|
|
||||||
@TableField(exist = false)
|
@TableField(exist = false)
|
||||||
private String uuid;
|
private String uuid;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 调度IP
|
||||||
|
*/
|
||||||
|
private String job_ip;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -121,6 +121,9 @@ public class ISysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> imp
|
|||||||
}catch (Exception ex){
|
}catch (Exception ex){
|
||||||
throw new RuntimeException();
|
throw new RuntimeException();
|
||||||
}
|
}
|
||||||
|
if (ObjectUtil.isNotEmpty(sysUser.getPassword())) {
|
||||||
|
sysUser.setPassword(SaSecureUtil.md5BySalt(sysUser.getPassword(), "salt"));
|
||||||
|
}
|
||||||
sysUser.setUpdate_time(new Date());
|
sysUser.setUpdate_time(new Date());
|
||||||
sysUser.setUpdate_id(SecurityUtils.getCurrentUserId());
|
sysUser.setUpdate_id(SecurityUtils.getCurrentUserId());
|
||||||
this.updateById(sysUser);
|
this.updateById(sysUser);
|
||||||
|
|||||||
Reference in New Issue
Block a user