package com.xuqm.tenant.controller; import com.xuqm.common.model.ApiResponse; import com.xuqm.tenant.entity.FeatureServiceEntity; 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>> list( @PathVariable String appId, @AuthenticationPrincipal String tenantId) { appService.getById(appId, tenantId); return ResponseEntity.ok(ApiResponse.success(featureServiceManager.listByApp(appId))); } @PostMapping("/toggle") public ResponseEntity> toggle( @PathVariable String appId, @RequestParam FeatureServiceEntity.Platform platform, @RequestParam FeatureServiceEntity.ServiceType serviceType, @RequestParam boolean enable, @AuthenticationPrincipal String tenantId) { appService.getById(appId, tenantId); return ResponseEntity.ok(ApiResponse.success( featureServiceManager.toggle(appId, platform, serviceType, enable))); } @PostMapping("/{id}/regenerate-key") public ResponseEntity> regenerateKey( @PathVariable String appId, @PathVariable String id, @AuthenticationPrincipal String tenantId) { appService.getById(appId, tenantId); return ResponseEntity.ok(ApiResponse.success(featureServiceManager.regenerateKey(id))); } }