wiki文档优化,系统升级信息获取和展示

This commit is contained in:
暮光:城中城
2019-04-21 16:46:14 +08:00
parent ad739a87e0
commit 7c8ab60c6d
18 changed files with 380 additions and 110 deletions

View File

@@ -9,6 +9,7 @@ import org.springframework.boot.web.servlet.support.SpringBootServletInitializer
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.core.env.Environment;
import org.springframework.scheduling.annotation.EnableScheduling;
import java.net.InetAddress;
import java.util.Optional;
@@ -16,6 +17,7 @@ import java.util.Optional;
/**
* 程序启动器
*/
@EnableScheduling
@SpringBootApplication
@ComponentScan(basePackages = {"com.zyplayer.doc.manage", "com.zyplayer.doc.data"})
public class Application extends SpringBootServletInitializer {

View File

@@ -1,13 +0,0 @@
package com.zyplayer.doc.manage.framework.config;
/**
* 开启zyplayer-doc-grpc服务
*
* @author 暮光:城中城
* @since 2018年11月11日
*/
//@EnableDocGrpc
//@Configuration
public class DocGrpcConfig {
}

View File

@@ -0,0 +1,47 @@
package com.zyplayer.doc.manage.task;
import cn.hutool.http.HttpRequest;
import com.alibaba.fastjson.JSON;
import com.zyplayer.doc.manage.utils.UpgradeUtil;
import com.zyplayer.doc.manage.utils.bean.UpgradeInfo;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import java.io.IOException;
import java.io.StringReader;
import java.util.Objects;
import java.util.Properties;
@Component
public class SchedulerTask {
@Value("${zyplayer.doc.manage.version:''}")
private String nowVersion;
@Value("${zyplayer.doc.manage.upgradePropertiesUrl:''}")
private String upgradePropertiesUrl;
// @Scheduled(cron = "0/10 * * * * ? ")
@Scheduled(cron = "0 0 1 * * ?")
public void upgradeTask() {
// 检查更新,访问的码云服务器获取升级内容的
if (StringUtils.isBlank(upgradePropertiesUrl)) {
return;
}
try {
String upgradeStr = HttpRequest.get(upgradePropertiesUrl).execute().body();
Properties properties = new Properties();
properties.load(new StringReader(upgradeStr));
if (Objects.equals(nowVersion, properties.getProperty("lastVersion"))) {
return;
}
properties.setProperty("nowVersion", nowVersion);
String jsonString = JSON.toJSONString(properties);
UpgradeUtil.upgradeInfo = JSON.parseObject(jsonString, UpgradeInfo.class);
} catch (Exception e) {
e.printStackTrace();
}
}
}

View File

@@ -0,0 +1,9 @@
package com.zyplayer.doc.manage.utils;
import com.zyplayer.doc.manage.utils.bean.UpgradeInfo;
import java.util.Properties;
public class UpgradeUtil {
public static UpgradeInfo upgradeInfo;
}

View File

@@ -0,0 +1,52 @@
package com.zyplayer.doc.manage.utils.bean;
/**
* 升级信息对象
*/
public class UpgradeInfo {
private String nowVersion;
private String lastVersion;
private String upgradeContent;
private String upgradeUrl;
private String nextStep;
public String getLastVersion() {
return lastVersion;
}
public void setLastVersion(String lastVersion) {
this.lastVersion = lastVersion;
}
public String getUpgradeContent() {
return upgradeContent;
}
public void setUpgradeContent(String upgradeContent) {
this.upgradeContent = upgradeContent;
}
public String getUpgradeUrl() {
return upgradeUrl;
}
public void setUpgradeUrl(String upgradeUrl) {
this.upgradeUrl = upgradeUrl;
}
public String getNextStep() {
return nextStep;
}
public void setNextStep(String nextStep) {
this.nextStep = nextStep;
}
public String getNowVersion() {
return nowVersion;
}
public void setNowVersion(String nowVersion) {
this.nowVersion = nowVersion;
}
}

View File

@@ -0,0 +1,19 @@
package com.zyplayer.doc.manage.web.manage;
import com.zyplayer.doc.core.json.DocResponseJson;
import com.zyplayer.doc.core.json.ResponseJson;
import com.zyplayer.doc.manage.utils.UpgradeUtil;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("/system/info")
public class SystemInfoController {
@PostMapping("/upgrade")
public ResponseJson<Object> upgradeInfo() {
return DocResponseJson.ok(UpgradeUtil.upgradeInfo);
}
}

View File

@@ -32,8 +32,12 @@ zyplayer:
proxy-request:
# 允许代理请求的域名,正则表达式,多个使用 ; 分割,必须设置,防止通过代理接口访问到内部资源,实在觉得没必要可设置为:.+
white-domain: \S+\.zyplayer\.com;127.0.1:8080;\S+\.xiaominfo\.com;
# zyplayer_doc_manage管理端的数据库配置
# zyplayer_doc_manage相关配置
manage:
# 版本和升级信息获取地址
version: 1.0.1
upgradePropertiesUrl: https://gitee.com/zyplayer/zyplayer-doc/raw/master/upgrade.properties
# 管理端的数据库配置
datasource:
driverClassName: com.mysql.jdbc.Driver
url: jdbc:mysql://127.0.0.1:3306/zyplayer_doc_manage?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&autoReconnect=true&useSSL=false