Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
895 changes: 895 additions & 0 deletions API-INTERFACE-DOCUMENTATION.md

Large diffs are not rendered by default.

110 changes: 91 additions & 19 deletions business-app/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,6 @@
<artifactId>spring-boot-starter-web</artifactId>
</dependency>

<!-- Spring Boot Starter Data JPA -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>

<!-- Spring Boot Starter Security -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>

<!-- Spring Boot Starter Validation -->
<dependency>
<groupId>org.springframework.boot</groupId>
Expand All @@ -55,11 +43,11 @@
<version>${project.version}</version>
</dependency>

<!-- 数据库驱动 -->
<!-- 开源版企业服务实现(直接依赖) -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
<groupId>com.terrabase</groupId>
<artifactId>enterprise-impl-open</artifactId>
<version>${project.version}</version>
</dependency>

<!-- 测试依赖 -->
Expand All @@ -70,20 +58,104 @@
</dependency>

<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-test</artifactId>
<scope>test</scope>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
<version>2023.0.3.2</version>
</dependency>

</dependencies>

<build>
<plugins>
<!-- Spring Boot 应用构建插件 -->
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<mainClass>com.terrabase.business.BusinessApplication</mainClass>
</configuration>
<executions>
<execution>
<id>repackage</id>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>

<!-- Maven Shade Plugin - 用于创建SDK包 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.4.1</version>
<executions>
<execution>
<id>create-sdk</id>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<finalName>terrabase-sdk-${project.version}</finalName>
<createDependencyReducedPom>false</createDependencyReducedPom>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>com.terrabase.sdk.TerrabaseSDK</mainClass>
</transformer>
</transformers>
<filters>
<filter>
<artifact>*:*</artifact>
<excludes>
<exclude>META-INF/*.SF</exclude>
<exclude>META-INF/*.DSA</exclude>
<exclude>META-INF/*.RSA</exclude>
</excludes>
</filter>
</filters>
<shadedArtifactAttached>true</shadedArtifactAttached>
<shadedClassifierName>sdk</shadedClassifierName>
</configuration>
</execution>
</executions>
</plugin>

<!-- Maven Source Plugin - 生成源码包 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>3.2.1</version>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>

<!-- Maven Javadoc Plugin - 生成文档包 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.6.0</version>
<executions>
<execution>
<id>attach-javadocs</id>
<goals>
<goal>jar</goal>
</goals>
<configuration>
<encoding>UTF-8</encoding>
<charset>UTF-8</charset>
<docencoding>UTF-8</docencoding>
<doclint>none</doclint>
<quiet>true</quiet>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
package com.terrabase.business;

import com.alibaba.nacos.common.tls.TlsSystemConfig;
import com.terrabase.business.util.JarLoadUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.web.client.RestTemplate;

/**
* Terrabase 业务应用主启动类
* 基于Spring Boot框架,支持动态加载企业服务实现
*
* @author Yehong Pan
* @version 1.0.0
*/
@SpringBootApplication
public class BusinessApplication {
// static {
// // configure nacos SSL
// System.setProperty(TlsSystemConfig.TLS_ENABLE, "true");
// System.setProperty(TlsSystemConfig.CLIENT_AUTH, "true");
// System.setProperty(TlsSystemConfig.CLIENT_TRUST_CERT,
// "/opt/huawei/fce/runtime/security/server_cert/nacos/nacos.crt");
// }

private static final Logger logger = LoggerFactory.getLogger(BusinessApplication.class);

@Autowired
private JarLoadUtil jarLoadUtil;


public static void main(String[] args) {
logger.info("正在启动 Terrabase 业务应用...");
SpringApplication.run(BusinessApplication.class, args);
}

/**
* 配置RestTemplate Bean
*/
@Bean
public RestTemplate restTemplate() {
return new RestTemplate();
}

/**
* 应用启动后执行初始化逻辑
*/
@Bean
public CommandLineRunner init() {
return args -> {
logger.info("=== Terrabase 业务应用初始化开始 ===");

try {
// 检测企业模式
String enterpriseMode = jarLoadUtil.getEnterpriseMode();
logger.info("企业模式: {}", enterpriseMode);

if ("commercial".equals(enterpriseMode)) {
logger.info("商业版模式已启用");
} else {
logger.info("开源版模式已启用");
}

} catch (Exception e) {
logger.error("企业模式检测失败", e);
// 不抛出异常,让应用继续启动
logger.warn("应用将在默认模式下继续运行");
}

logger.info("=== Terrabase 业务应用初始化完成 ===");
};
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
package com.terrabase.business.controller;

import com.terrabase.business.util.JarLoadUtil;
import com.terrabase.enterprise.api.CertificateService;
import com.terrabase.enterprise.api.dto.CertCollectInfo;
import com.terrabase.enterprise.api.dto.LicenseInfo;
import com.terrabase.enterprise.api.response.ResultVo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
* 证书管理服务控制器
* 负责提供证书管理相关的REST API接口
*
* @author Yehong Pan
* @version 1.0.0
*/
@RestController
@RequestMapping("/api/enterprise/certificate")
@CrossOrigin(origins = "*")
public class CertificateController {

private static final Logger logger = LoggerFactory.getLogger(CertificateController.class);

@Autowired
private JarLoadUtil jarLoadUtil;

/**
* 获取证书列表
*/
@GetMapping("/list")
public ResponseEntity<Map<String, Object>> getCertificateList() {
try {
CertificateService certService = jarLoadUtil.loadCertificateService();
ResultVo<List<CertCollectInfo>> result = certService.listCertificateServiceList();

Map<String, Object> response = new HashMap<>();
if ("200".equals(result.getCode())) {
response.put("status", "success");
response.put("certificates", result.getData());
response.put("total", result.getData() != null ? result.getData().size() : 0);
response.put("timestamp", System.currentTimeMillis());
} else {
response.put("status", "failed");
response.put("error", result.getMsg());
response.put("code", result.getCode());
}

return ResponseEntity.ok(response);

} catch (Exception e) {
logger.error("获取证书列表失败", e);
Map<String, Object> error = new HashMap<>();
error.put("status", "failed");
error.put("error", "获取证书列表失败: " + e.getMessage());
return ResponseEntity.internalServerError().body(error);
}
}

/**
* 获取License信息
*/
@GetMapping("/license")
public ResponseEntity<Map<String, Object>> getLicenseInfo() {
try {
CertificateService certService = jarLoadUtil.loadCertificateService();
ResultVo<LicenseInfo> result = certService.getLicenseInfo();

Map<String, Object> response = new HashMap<>();
if ("200".equals(result.getCode())) {
response.put("status", "success");
response.put("license", result.getData());
response.put("timestamp", System.currentTimeMillis());
} else {
response.put("status", "failed");
response.put("error", result.getMsg());
response.put("code", result.getCode());
}

return ResponseEntity.ok(response);

} catch (Exception e) {
logger.error("获取License信息失败", e);
Map<String, Object> error = new HashMap<>();
error.put("status", "failed");
error.put("error", "获取License信息失败: " + e.getMessage());
return ResponseEntity.internalServerError().body(error);
}
}

}
Loading