diff --git a/backend/src/main/java/io/dataease/controller/AboutController.java b/backend/src/main/java/io/dataease/controller/AboutController.java new file mode 100644 index 0000000000..a4d9fa1e6d --- /dev/null +++ b/backend/src/main/java/io/dataease/controller/AboutController.java @@ -0,0 +1,32 @@ +package io.dataease.controller; + + +import io.dataease.commons.license.F2CLicenseResponse; +import io.dataease.service.AboutService; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; +import java.util.Map; + +@RequestMapping("/about") +@RestController +public class AboutController { + + @Resource + private AboutService aboutService; + + @PostMapping("/license/update") + public F2CLicenseResponse updateLicense(@RequestBody Map map) { + return aboutService.updateLicense(map.get("license")); + } + + @PostMapping("/license/validate") + public F2CLicenseResponse validateLicense(@RequestBody Map map) { + return aboutService.validateLicense(map.get("license")); + } + + @GetMapping("/build/version") + public Object getBuildVersion() { + return aboutService.getBuildVersion(); + } +} diff --git a/backend/src/main/java/io/dataease/service/AboutService.java b/backend/src/main/java/io/dataease/service/AboutService.java new file mode 100644 index 0000000000..70171f576b --- /dev/null +++ b/backend/src/main/java/io/dataease/service/AboutService.java @@ -0,0 +1,54 @@ +package io.dataease.service; + +import io.dataease.commons.license.DefaultLicenseService; +import io.dataease.commons.license.F2CLicenseResponse; +import io.dataease.commons.utils.CommonBeanFactory; +import io.dataease.commons.utils.LogUtil; +import org.apache.commons.io.FileUtils; +import org.apache.commons.lang3.StringUtils; +import org.springframework.core.env.Environment; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.io.File; +import java.util.Optional; + +@Service +public class AboutService { + private static final String BUILD_VERSION = "/opt/fit2cloud/conf/version"; + private static final String product = "dataease"; + + @Resource + private DefaultLicenseService defaultLicenseService; + + public F2CLicenseResponse updateLicense(String licenseKey) { + F2CLicenseResponse f2CLicenseResponse = defaultLicenseService.updateLicense(product, licenseKey); + return f2CLicenseResponse; + } + + public F2CLicenseResponse validateLicense(String licenseKey) { + if (StringUtils.isNotBlank(licenseKey)) { + return defaultLicenseService.validateLicense(product, licenseKey); + } else { + return defaultLicenseService.validateLicense(); + } + } + + public String getBuildVersion() { + try { + File file = new File(BUILD_VERSION); + if (file.exists()) { + String version = FileUtils.readFileToString(file, "UTF-8"); + if (StringUtils.isNotBlank(version)) { + return version; + } + } + String property = CommonBeanFactory.getBean(Environment.class).getProperty("cmp.version"); + String result = Optional.ofNullable(property).orElse("V1.0"); + return result; + } catch (Exception e) { + LogUtil.error("failed to get build version.", e); + } + return "unknown"; + } +} diff --git a/frontend/src/api/system/about.js b/frontend/src/api/system/about.js new file mode 100644 index 0000000000..b2a5d1739b --- /dev/null +++ b/frontend/src/api/system/about.js @@ -0,0 +1,24 @@ +import request from '@/utils/request' + +export function validate(data) { + return request({ + url: '/about/license/validate', + method: 'post', + data + }) +} + +export function buildVersion() { + return request({ + url: '/about/build/version', + method: 'get' + }) +} + +export function updateInfo(data) { + return request({ + url: '/about/license/update', + method: 'post', + data + }) +} diff --git a/frontend/src/assets/license_header.png b/frontend/src/assets/license_header.png new file mode 100644 index 0000000000..3dd7dc62bc Binary files /dev/null and b/frontend/src/assets/license_header.png differ diff --git a/frontend/src/layout/components/Licbar.vue b/frontend/src/layout/components/Licbar.vue index 1d8446cf53..66575df2fe 100644 --- a/frontend/src/layout/components/Licbar.vue +++ b/frontend/src/layout/components/Licbar.vue @@ -50,7 +50,11 @@ export default { background-color: #c92100; color: #fff; text-align: center; - padding: 6px 11px; + /* padding: 6px 11px; */ + position: fixed; + z-index: 1002; + top: 0; + width: 100%; } diff --git a/frontend/src/layout/components/Topbar.vue b/frontend/src/layout/components/Topbar.vue index ebb84789ec..86a7cb41cf 100644 --- a/frontend/src/layout/components/Topbar.vue +++ b/frontend/src/layout/components/Topbar.vue @@ -51,13 +51,16 @@ 重置密码 - + Docs - + + + 关于 + 退出 diff --git a/frontend/src/layout/index.vue b/frontend/src/layout/index.vue index 5a8fbb1abd..594e075b83 100644 --- a/frontend/src/layout/index.vue +++ b/frontend/src/layout/index.vue @@ -1,6 +1,6 @@