- 新增 AuthRepository 处理用户认证和加密存储 - 实现 SDK 登录会话管理和自动通知模块 - 添加 IM SDK 登录集成和会话传递 - 更新 API 响应结构支持 userSig 字段 - 添加文件存储服务和上传功能 - 完善文档说明 SDK 架构和集成方式
84 行
3.0 KiB
Java
84 行
3.0 KiB
Java
package com.xuqm.tenant.controller;
|
|
|
|
import com.xuqm.common.model.ApiResponse;
|
|
import com.xuqm.tenant.entity.FeatureServiceEntity;
|
|
import com.xuqm.tenant.repository.AppRepository;
|
|
import com.xuqm.tenant.repository.FeatureServiceRepository;
|
|
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.RequestParam;
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
|
|
@RestController
|
|
@RequestMapping("/api/sdk")
|
|
public class SdkConfigController {
|
|
|
|
private final AppRepository appRepository;
|
|
private final FeatureServiceRepository featureServiceRepository;
|
|
|
|
@Value("${sdk.im-ws-url:wss://im.dev.xuqinmin.com/ws/im}")
|
|
private String imWsUrl;
|
|
|
|
@Value("${sdk.file-service-url:https://file.dev.xuqinmin.com}")
|
|
private String fileServiceUrl;
|
|
|
|
@Value("${sdk.im-api-url:https://im.dev.xuqinmin.com}")
|
|
private String imApiUrl;
|
|
|
|
public SdkConfigController(AppRepository appRepository,
|
|
FeatureServiceRepository featureServiceRepository) {
|
|
this.appRepository = appRepository;
|
|
this.featureServiceRepository = featureServiceRepository;
|
|
}
|
|
|
|
/**
|
|
* GET /api/sdk/config?appId=XXX — public, no auth required.
|
|
*
|
|
* Returns SDK configuration URLs and enabled feature flags for the given appId.
|
|
* Returns 404 if the appId does not exist in the system.
|
|
*/
|
|
@GetMapping("/config")
|
|
public ResponseEntity<ApiResponse<SdkConfigResponse>> getConfig(
|
|
@RequestParam String appId) {
|
|
|
|
if (!appRepository.existsById(appId)) {
|
|
return ResponseEntity.status(404)
|
|
.body(ApiResponse.error(404, "App not found: " + appId));
|
|
}
|
|
|
|
List<FeatureServiceEntity> features = featureServiceRepository.findByAppId(appId);
|
|
|
|
boolean imEnabled = features.stream()
|
|
.anyMatch(f -> f.getServiceType() == FeatureServiceEntity.ServiceType.IM && f.isEnabled());
|
|
boolean pushEnabled = features.stream()
|
|
.anyMatch(f -> f.getServiceType() == FeatureServiceEntity.ServiceType.PUSH && f.isEnabled());
|
|
boolean updateEnabled = features.stream()
|
|
.anyMatch(f -> f.getServiceType() == FeatureServiceEntity.ServiceType.UPDATE && f.isEnabled());
|
|
|
|
SdkConfigResponse response = new SdkConfigResponse(
|
|
imWsUrl,
|
|
fileServiceUrl,
|
|
imApiUrl,
|
|
Map.of(
|
|
"im", imEnabled,
|
|
"push", pushEnabled,
|
|
"update", updateEnabled
|
|
)
|
|
);
|
|
|
|
return ResponseEntity.ok(ApiResponse.success(response));
|
|
}
|
|
|
|
public record SdkConfigResponse(
|
|
String imWsUrl,
|
|
String fileServiceUrl,
|
|
String imApiUrl,
|
|
Map<String, Boolean> features
|
|
) {}
|
|
}
|