feat:first commit
This commit is contained in:
38
domain/src/main/java/com/xiang/schedule/DynamicDomainSchedule.java
Executable file
38
domain/src/main/java/com/xiang/schedule/DynamicDomainSchedule.java
Executable file
@@ -0,0 +1,38 @@
|
||||
package com.xiang.schedule;
|
||||
|
||||
import com.xiang.service.DomainServiceImpl;
|
||||
import com.xiang.utils.IpUtils;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* @Author: xiang
|
||||
* @Date: 2025-06-10 17:21
|
||||
*/
|
||||
@Component
|
||||
@RequiredArgsConstructor
|
||||
@Slf4j
|
||||
public class DynamicDomainSchedule {
|
||||
|
||||
private final DomainServiceImpl domainService;
|
||||
|
||||
@Scheduled(cron = "0 0/5 * * * ? ")
|
||||
public void dynamicDomainSchedule() {
|
||||
String publicIp = "";
|
||||
try {
|
||||
publicIp = IpUtils.getPublicIp();
|
||||
} catch (Exception e) {
|
||||
log.error("获取公网ip失败,", e);
|
||||
}
|
||||
if (StringUtils.isNotBlank(publicIp)) {
|
||||
try {
|
||||
domainService.dynamicDomainAnalysis(publicIp);
|
||||
} catch (Exception e) {
|
||||
log.error("动态解析公网ip失败, ip:{}", publicIp, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user