Skip to content

Commit

Permalink
新增:版本更新消息推送功能
Browse files Browse the repository at this point in the history
  • Loading branch information
Yohann0617 committed Dec 30, 2024
1 parent 431d6f0 commit 9242fef
Showing 1 changed file with 17 additions and 9 deletions.
26 changes: 17 additions & 9 deletions src/main/java/com/yohann/ocihelper/task/OciTask.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ public class OciTask implements ApplicationRunner {
@Resource
private IOciCreateTaskService createTaskService;

private static volatile boolean isPushLatestVersion = false;

@Value("${web.account}")
private String account;
@Value("${web.password}")
Expand Down Expand Up @@ -137,15 +139,21 @@ private void saveVersion() {
}

private void pushVersionUpdateMsg() {
addTask("pushVersionUpdateMsg", () -> {
String nowVersion = kvService.getObj(new LambdaQueryWrapper<OciKv>()
.eq(OciKv::getCode, SysCfgEnum.SYS_INFO_VERSION.getCode())
.eq(OciKv::getType, SysCfgTypeEnum.SYS_INFO.getCode())
.select(OciKv::getValue), String::valueOf);
String latestVersion = CommonUtils.getLatestVersion();
if (!nowVersion.equals(latestVersion)) {
sysService.sendMessage(String.format("【oci-helper】版本更新啦!!!\n当前版本:%s\n最新版本:%s",
nowVersion, latestVersion));
String taskId = "pushVersionUpdateMsg";
addTask(taskId, () -> {
if (isPushLatestVersion) {
stopTask(taskId);
} else {
String nowVersion = kvService.getObj(new LambdaQueryWrapper<OciKv>()
.eq(OciKv::getCode, SysCfgEnum.SYS_INFO_VERSION.getCode())
.eq(OciKv::getType, SysCfgTypeEnum.SYS_INFO.getCode())
.select(OciKv::getValue), String::valueOf);
String latestVersion = CommonUtils.getLatestVersion();
if (!nowVersion.equals(latestVersion)) {
sysService.sendMessage(String.format("【oci-helper】版本更新啦!!!\n当前版本:%s\n最新版本:%s",
nowVersion, latestVersion));
isPushLatestVersion = true;
}
}
}, 0, 1, TimeUnit.MINUTES);
}
Expand Down

0 comments on commit 9242fef

Please sign in to comment.