diff --git a/server/odc-service/src/main/java/com/oceanbase/odc/service/info/InfoAdapter.java b/server/odc-service/src/main/java/com/oceanbase/odc/service/info/InfoAdapter.java index 08292223df..0df0e09acb 100644 --- a/server/odc-service/src/main/java/com/oceanbase/odc/service/info/InfoAdapter.java +++ b/server/odc-service/src/main/java/com/oceanbase/odc/service/info/InfoAdapter.java @@ -15,6 +15,8 @@ */ package com.oceanbase.odc.service.info; +import java.time.OffsetDateTime; + import javax.servlet.http.HttpServletRequest; public interface InfoAdapter { @@ -25,6 +27,10 @@ public interface InfoAdapter { String getSupportGroupQRCodeUrl(); + String getBuildVersion(); + + OffsetDateTime getBuildTime(); + boolean isPasswordLoginEnabled(); default String ssoLoginName() { diff --git a/server/odc-service/src/main/java/com/oceanbase/odc/service/info/OdcInfoService.java b/server/odc-service/src/main/java/com/oceanbase/odc/service/info/OdcInfoService.java index 4b632ba550..70003d0bdc 100644 --- a/server/odc-service/src/main/java/com/oceanbase/odc/service/info/OdcInfoService.java +++ b/server/odc-service/src/main/java/com/oceanbase/odc/service/info/OdcInfoService.java @@ -106,10 +106,8 @@ public class OdcInfoService { @PostConstruct public void init() { staticOdcInfo = new OdcInfo(); - staticOdcInfo.setVersion(buildProperties.getVersion()); staticOdcInfo.setStartTime( instant2OffsetDateTime(Instant.ofEpochMilli(ManagementFactory.getRuntimeMXBean().getStartTime()))); - staticOdcInfo.setBuildTime(instant2OffsetDateTime(buildProperties.getTime())); staticOdcInfo.setHomePageText(infoProperties.getHomePageText()); staticOdcInfo.setSupportEmail(infoProperties.getSupportEmail()); staticOdcInfo.setSupportUrl(infoProperties.getSupportUrl()); @@ -139,6 +137,8 @@ public OffsetDateTime time() { public OdcInfo info() { OdcInfo odcInfo = ObjectUtil.deepCopy(this.staticOdcInfo, OdcInfo.class); String[] profiles = SpringContextUtil.getProfiles(); + odcInfo.setVersion(infoAdapter.getBuildVersion()); + odcInfo.setBuildTime(infoAdapter.getBuildTime()); odcInfo.setProfiles(profiles); odcInfo.setPasswordLoginEnabled(this.infoAdapter.isPasswordLoginEnabled()); odcInfo.setSsoLoginEnabled(Objects.nonNull(getLoginUrl())); diff --git a/server/starters/desktop-starter/src/main/java/com/oceanbase/odc/service/info/DesktopInfoAdapter.java b/server/starters/desktop-starter/src/main/java/com/oceanbase/odc/service/info/DesktopInfoAdapter.java index d5663a1a4f..48796f975d 100644 --- a/server/starters/desktop-starter/src/main/java/com/oceanbase/odc/service/info/DesktopInfoAdapter.java +++ b/server/starters/desktop-starter/src/main/java/com/oceanbase/odc/service/info/DesktopInfoAdapter.java @@ -16,9 +16,14 @@ package com.oceanbase.odc.service.info; +import java.time.OffsetDateTime; +import java.time.ZoneId; + import javax.servlet.http.HttpServletRequest; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; +import org.springframework.boot.info.BuildProperties; import org.springframework.context.annotation.Profile; import org.springframework.stereotype.Service; @@ -32,6 +37,9 @@ public class DesktopInfoAdapter implements InfoAdapter { @Value("${odc.help.supportGroupQRCodeUrl:#{null}}") private String supportGroupQRCodeUrl; + @Autowired + private BuildProperties buildProperties; + @Override public boolean isPasswordLoginEnabled() { return false; @@ -52,4 +60,13 @@ public String getSupportGroupQRCodeUrl() { return supportGroupQRCodeUrl; } + @Override + public String getBuildVersion() { + return buildProperties.getVersion(); + } + + @Override + public OffsetDateTime getBuildTime() { + return OffsetDateTime.ofInstant(buildProperties.getTime(), ZoneId.systemDefault()); + } } diff --git a/server/starters/web-starter/src/main/java/com/oceanbase/odc/service/info/WebInfoAdapter.java b/server/starters/web-starter/src/main/java/com/oceanbase/odc/service/info/WebInfoAdapter.java index 6468d2decb..be40577225 100644 --- a/server/starters/web-starter/src/main/java/com/oceanbase/odc/service/info/WebInfoAdapter.java +++ b/server/starters/web-starter/src/main/java/com/oceanbase/odc/service/info/WebInfoAdapter.java @@ -15,12 +15,15 @@ */ package com.oceanbase.odc.service.info; +import java.time.OffsetDateTime; +import java.time.ZoneId; import java.util.Set; import javax.servlet.http.HttpServletRequest; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; +import org.springframework.boot.info.BuildProperties; import org.springframework.context.annotation.Profile; import org.springframework.stereotype.Service; @@ -46,6 +49,8 @@ public class WebInfoAdapter implements InfoAdapter { private PlaysiteOpenApiProperties alipayOpenApiProperties; @Autowired protected IntegrationService integrationService; + @Autowired + private BuildProperties buildProperties; @Override public boolean isPasswordLoginEnabled() { @@ -97,4 +102,14 @@ public String getSupportGroupQRCodeUrl() { return supportGroupQRCodeUrl; } + @Override + public String getBuildVersion() { + return buildProperties.getVersion(); + } + + @Override + public OffsetDateTime getBuildTime() { + return OffsetDateTime.ofInstant(buildProperties.getTime(), ZoneId.systemDefault()); + } + }