Files
xservice-script/domain/src/main/java/com/xiang/schedule/DynamicDomainSchedule.java
2025-07-16 15:05:59 +08:00

39 lines
1.0 KiB
Java
Executable File
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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);
}
}
}
}