From a55fbacfe003642e3dfcfd8fac6080642cac205a Mon Sep 17 00:00:00 2001 From: CaptainB Date: Tue, 20 Jun 2023 11:23:27 +0800 Subject: [PATCH] =?UTF-8?q?build:=20license=20=E7=9B=B8=E5=85=B3=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/LicenseValidateController.java | 21 ++++++++++++ .../io/metersphere/sdk/dto/LicenseDTO.java | 15 +++++++++ .../metersphere/sdk/dto/LicenseInfoDTO.java | 33 +++++++++++++++++++ .../sdk/service/LicenseService.java | 12 +++++++ 4 files changed, 81 insertions(+) create mode 100644 backend/framework/sdk/src/main/java/io/metersphere/sdk/controller/LicenseValidateController.java create mode 100644 backend/framework/sdk/src/main/java/io/metersphere/sdk/dto/LicenseDTO.java create mode 100644 backend/framework/sdk/src/main/java/io/metersphere/sdk/dto/LicenseInfoDTO.java create mode 100644 backend/framework/sdk/src/main/java/io/metersphere/sdk/service/LicenseService.java diff --git a/backend/framework/sdk/src/main/java/io/metersphere/sdk/controller/LicenseValidateController.java b/backend/framework/sdk/src/main/java/io/metersphere/sdk/controller/LicenseValidateController.java new file mode 100644 index 0000000000..c76546a56d --- /dev/null +++ b/backend/framework/sdk/src/main/java/io/metersphere/sdk/controller/LicenseValidateController.java @@ -0,0 +1,21 @@ +package io.metersphere.sdk.controller; + +import io.metersphere.sdk.dto.LicenseDTO; +import io.metersphere.sdk.service.LicenseService; +import io.metersphere.sdk.util.CommonBeanFactory; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@RequestMapping("/license") +public class LicenseValidateController { + @GetMapping("/validate") + public LicenseDTO validate() { + LicenseService licenseService = CommonBeanFactory.getBean(LicenseService.class); + if (licenseService != null) { + return licenseService.validate(); + } + return new LicenseDTO(); + } +} diff --git a/backend/framework/sdk/src/main/java/io/metersphere/sdk/dto/LicenseDTO.java b/backend/framework/sdk/src/main/java/io/metersphere/sdk/dto/LicenseDTO.java new file mode 100644 index 0000000000..f194d97ee1 --- /dev/null +++ b/backend/framework/sdk/src/main/java/io/metersphere/sdk/dto/LicenseDTO.java @@ -0,0 +1,15 @@ +package io.metersphere.sdk.dto; + +import lombok.Data; + +import java.io.Serializable; + +@Data +public class LicenseDTO implements Serializable { + private static final long serialVersionUID = 1L; + + private String status; + + private LicenseInfoDTO license; + +} \ No newline at end of file diff --git a/backend/framework/sdk/src/main/java/io/metersphere/sdk/dto/LicenseInfoDTO.java b/backend/framework/sdk/src/main/java/io/metersphere/sdk/dto/LicenseInfoDTO.java new file mode 100644 index 0000000000..c16c4b8a39 --- /dev/null +++ b/backend/framework/sdk/src/main/java/io/metersphere/sdk/dto/LicenseInfoDTO.java @@ -0,0 +1,33 @@ +package io.metersphere.sdk.dto; + +import lombok.Data; + +import java.io.Serializable; + +@Data +public class LicenseInfoDTO implements Serializable { + /** + * 客户名称 + */ + private String corporation; + /** + * 授权截止时间 + */ + private String expired; + /** + * 产品名称 + */ + private String product; + /** + * 产品版本 + */ + private String edition; + /** + * icense版本 + */ + private String licenseVersion; + /** + * 授权数量 + */ + private int count; +} diff --git a/backend/framework/sdk/src/main/java/io/metersphere/sdk/service/LicenseService.java b/backend/framework/sdk/src/main/java/io/metersphere/sdk/service/LicenseService.java new file mode 100644 index 0000000000..7e5452fcf7 --- /dev/null +++ b/backend/framework/sdk/src/main/java/io/metersphere/sdk/service/LicenseService.java @@ -0,0 +1,12 @@ +package io.metersphere.sdk.service; + + +import io.metersphere.sdk.dto.LicenseDTO; + +public interface LicenseService { + + LicenseDTO refreshLicense(); + + LicenseDTO validate(); + +}