|
@@ -4,12 +4,16 @@ 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 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;
|
|
|
|
|
|
@RestController
|
|
|
public class PublicController {
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private Environment env;
|
|
|
+
|
|
|
@Autowired
|
|
|
private HttpRequestUtil httpRequestUtil;
|
|
|
|
|
@@ -22,9 +26,14 @@ public class PublicController {
|
|
|
@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(), 1) + "/version.txt";
|
|
|
+ this.getClass().getProtectionDomain().getCodeSource().getLocation().getFile(), level) + "./version.txt";
|
|
|
return FileUtil.readUtf8String(path).trim();
|
|
|
}
|
|
|
|