71 行
2.5 KiB
Java
71 行
2.5 KiB
Java
|
|
package com.xuqm.tenant.controller;
|
||
|
|
|
||
|
|
import com.xuqm.common.model.ApiResponse;
|
||
|
|
import com.xuqm.tenant.config.PrivateDeploymentProperties;
|
||
|
|
import org.springframework.beans.factory.annotation.Value;
|
||
|
|
import org.springframework.http.ResponseEntity;
|
||
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
||
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||
|
|
import org.springframework.web.bind.annotation.RestController;
|
||
|
|
|
||
|
|
import java.util.LinkedHashMap;
|
||
|
|
import java.util.Map;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Public endpoint — returns deployment mode and enabled service capabilities.
|
||
|
|
* Safe to expose without authentication: contains no credentials.
|
||
|
|
*/
|
||
|
|
@RestController
|
||
|
|
@RequestMapping("/api/private/deployment")
|
||
|
|
public class PrivateDeploymentController {
|
||
|
|
|
||
|
|
private final PrivateDeploymentProperties deployProps;
|
||
|
|
|
||
|
|
@Value("${sdk.im-api-url:}")
|
||
|
|
private String imApiUrl;
|
||
|
|
|
||
|
|
@Value("${sdk.file-service-url:}")
|
||
|
|
private String fileServiceUrl;
|
||
|
|
|
||
|
|
@Value("${deployment.im-domain:}")
|
||
|
|
private String imDomain;
|
||
|
|
|
||
|
|
@Value("${deployment.push-domain:}")
|
||
|
|
private String pushDomain;
|
||
|
|
|
||
|
|
@Value("${deployment.update-domain:}")
|
||
|
|
private String updateDomain;
|
||
|
|
|
||
|
|
@Value("${deployment.license-domain:}")
|
||
|
|
private String licenseDomain;
|
||
|
|
|
||
|
|
public PrivateDeploymentController(PrivateDeploymentProperties deployProps) {
|
||
|
|
this.deployProps = deployProps;
|
||
|
|
}
|
||
|
|
|
||
|
|
@GetMapping("/status")
|
||
|
|
public ResponseEntity<ApiResponse<Map<String, Object>>> status() {
|
||
|
|
Map<String, Object> services = new LinkedHashMap<>();
|
||
|
|
|
||
|
|
services.put("file", serviceStatus(deployProps.isEnableFile(), fileServiceUrl));
|
||
|
|
services.put("im", serviceStatus(deployProps.isEnableIm(), imDomain));
|
||
|
|
services.put("push", serviceStatus(deployProps.isEnablePush(), pushDomain));
|
||
|
|
services.put("update", serviceStatus(deployProps.isEnableUpdate(), updateDomain));
|
||
|
|
services.put("license", serviceStatus(deployProps.isEnableLicense(), licenseDomain));
|
||
|
|
|
||
|
|
Map<String, Object> body = new LinkedHashMap<>();
|
||
|
|
body.put("mode", deployProps.getMode());
|
||
|
|
body.put("tenantRegisterEnabled", deployProps.isTenantRegisterEnabled());
|
||
|
|
body.put("services", services);
|
||
|
|
|
||
|
|
return ResponseEntity.ok(ApiResponse.success(body));
|
||
|
|
}
|
||
|
|
|
||
|
|
private Map<String, Object> serviceStatus(boolean enabled, String baseUrl) {
|
||
|
|
Map<String, Object> m = new LinkedHashMap<>();
|
||
|
|
m.put("enabled", enabled);
|
||
|
|
m.put("baseUrl", enabled ? baseUrl : null);
|
||
|
|
return m;
|
||
|
|
}
|
||
|
|
}
|