|
@@ -1,14 +1,19 @@
|
|
package com.backendsys.modules;
|
|
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.annotations.Anonymous;
|
|
import com.backendsys.modules.common.config.security.utils.HttpRequestUtil;
|
|
import com.backendsys.modules.common.config.security.utils.HttpRequestUtil;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
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.GetMapping;
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
@RestController
|
|
@RestController
|
|
public class PublicController {
|
|
public class PublicController {
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
+ private Environment env;
|
|
|
|
+
|
|
@Autowired
|
|
@Autowired
|
|
private HttpRequestUtil httpRequestUtil;
|
|
private HttpRequestUtil httpRequestUtil;
|
|
|
|
|
|
@@ -18,4 +23,18 @@ public class PublicController {
|
|
return httpRequestUtil.getIpAddr();
|
|
return httpRequestUtil.getIpAddr();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @Anonymous
|
|
|
|
+ @GetMapping("/api/version")
|
|
|
|
+ public String getVersion() {
|
|
|
|
+
|
|
|
|
+ Integer level = 1;
|
|
|
|
+ String activeProfile = env.getActiveProfiles()[0];
|
|
|
|
+ if ("local".equals(activeProfile)) level = 2;
|
|
|
|
+
|
|
|
|
+ // jar 包所在目录 + 文件名
|
|
|
|
+ String path = FileUtil.getParent(
|
|
|
|
+ this.getClass().getProtectionDomain().getCodeSource().getLocation().getFile(), level) + "./version.txt";
|
|
|
|
+ return FileUtil.readUtf8String(path).trim();
|
|
|
|
+ }
|
|
|
|
+
|
|
}
|
|
}
|