XuqmGroup-Server/tenant-service/src/main/java/com/xuqm/tenant/controller/FeatureServiceController.java
XuqmGroup 161218420c feat: IM admin APIs, appSecret security, remove SecretKey, CI/CD pipeline
- im-service: add admin register user and create group endpoints
- tenant-service: add reveal/reset appSecret with email verification
- tenant-service: remove secretKey from FeatureService (app appKey/appSecret is sufficient)
- tenant-service: service activation now requires ops approval via request-activation
- Add Jenkinsfile for parameterized build → Alibaba Cloud ACR → SSH deploy

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-24 20:53:48 +08:00

74 行
3.3 KiB
Java

package com.xuqm.tenant.controller;
import com.xuqm.common.model.ApiResponse;
import com.xuqm.tenant.entity.FeatureServiceEntity;
import com.xuqm.tenant.entity.ServiceActivationRequestEntity;
import com.xuqm.tenant.service.AppService;
import com.xuqm.tenant.service.FeatureServiceManager;
import org.springframework.http.ResponseEntity;
import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
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;
@RestController
@RequestMapping("/api/apps/{appId}/services")
public class FeatureServiceController {
private final FeatureServiceManager featureServiceManager;
private final AppService appService;
public FeatureServiceController(FeatureServiceManager featureServiceManager, AppService appService) {
this.featureServiceManager = featureServiceManager;
this.appService = appService;
}
@GetMapping
public ResponseEntity<ApiResponse<List<FeatureServiceEntity>>> list(
@PathVariable String appId, @AuthenticationPrincipal String tenantId) {
appService.getById(appId, tenantId);
return ResponseEntity.ok(ApiResponse.success(featureServiceManager.listByApp(appId)));
}
/** Disable a service (enable=false only; enabling requires ops approval via request-activation). */
@PostMapping("/toggle")
public ResponseEntity<ApiResponse<FeatureServiceEntity>> toggle(
@PathVariable String appId,
@RequestParam FeatureServiceEntity.Platform platform,
@RequestParam FeatureServiceEntity.ServiceType serviceType,
@RequestParam boolean enable,
@AuthenticationPrincipal String tenantId) {
appService.getById(appId, tenantId);
if (enable) {
throw new com.xuqm.common.exception.BusinessException(400, "开启服务请通过 request-activation 申请");
}
return ResponseEntity.ok(ApiResponse.success(
featureServiceManager.disable(appId, platform, serviceType)));
}
/** Submit an activation request for ops approval. */
@PostMapping("/request-activation")
public ResponseEntity<ApiResponse<ServiceActivationRequestEntity>> requestActivation(
@PathVariable String appId,
@RequestParam FeatureServiceEntity.Platform platform,
@RequestParam FeatureServiceEntity.ServiceType serviceType,
@RequestParam(required = false) String applyReason,
@AuthenticationPrincipal String tenantId) {
appService.getById(appId, tenantId);
return ResponseEntity.ok(ApiResponse.success(
featureServiceManager.submitActivationRequest(appId, platform, serviceType, applyReason)));
}
@GetMapping("/requests")
public ResponseEntity<ApiResponse<List<ServiceActivationRequestEntity>>> listRequests(
@PathVariable String appId, @AuthenticationPrincipal String tenantId) {
appService.getById(appId, tenantId);
return ResponseEntity.ok(ApiResponse.success(featureServiceManager.listRequestsByApp(appId)));
}
}