|
@@ -1,10 +1,9 @@
|
|
|
package com.backendsys.modules;
|
|
|
|
|
|
-import cn.hutool.core.io.FileUtil;
|
|
|
import com.backendsys.modules.common.config.security.annotations.Anonymous;
|
|
|
import com.backendsys.modules.common.config.security.utils.HttpRequestUtil;
|
|
|
+import com.backendsys.utils.CommonUtil;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.core.env.Environment;
|
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
@@ -12,7 +11,7 @@ import org.springframework.web.bind.annotation.RestController;
|
|
|
public class PublicController {
|
|
|
|
|
|
@Autowired
|
|
|
- private Environment env;
|
|
|
+ private CommonUtil commonUtil;
|
|
|
|
|
|
@Autowired
|
|
|
private HttpRequestUtil httpRequestUtil;
|
|
@@ -26,21 +25,7 @@ public class PublicController {
|
|
|
@Anonymous
|
|
|
@GetMapping("/api/version")
|
|
|
public String getVersion() {
|
|
|
-
|
|
|
- String activeProfile = env.getActiveProfiles()[0];
|
|
|
- if ("local".equals(activeProfile)) {
|
|
|
- // jar 包所在目录 + 文件名
|
|
|
- String path = FileUtil.getParent(
|
|
|
- this.getClass().getProtectionDomain().getCodeSource().getLocation().getFile(), 2) + "./version.txt";
|
|
|
- return FileUtil.readUtf8String(path).trim();
|
|
|
- } else {
|
|
|
- // 自动部署的目录
|
|
|
- String versionFile = "/app/build/version.txt"; // 上一级目录
|
|
|
- return FileUtil.exist(versionFile)
|
|
|
- ? FileUtil.readUtf8String(versionFile).trim()
|
|
|
- : "0.0.0";
|
|
|
- }
|
|
|
-
|
|
|
+ return commonUtil.getPushVersion();
|
|
|
}
|
|
|
|
|
|
}
|