From 34ba209e4414f7f30339d780cf1b5b84867718db Mon Sep 17 00:00:00 2001 From: hailin Date: Thu, 5 Feb 2026 04:36:53 -0800 Subject: [PATCH] =?UTF-8?q?fix(app-assets):=20=E4=BF=AE=E5=A4=8D=E5=85=AC?= =?UTF-8?q?=E5=BC=80API=E8=B7=AF=E5=BE=84=E5=8F=8C=E9=87=8D=E5=89=8D?= =?UTF-8?q?=E7=BC=80=20+=20Kong=E7=BD=91=E5=85=B3=E8=B7=AF=E7=94=B1?= =?UTF-8?q?=E7=BC=BA=E5=A4=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 问题:移动端配置的开屏图/引导图无效 根因: 1. PublicAppAssetController 和 PublicSystemConfigController 的 @Controller('api/v1/xxx') 与 NestJS 全局前缀 api/v1 叠加, 导致实际端点为 api/v1/api/v1/xxx(双重前缀) 2. Kong 网关缺少 /api/v1/app-assets 和 /api/v1/system-config 路由 3. Flutter 端使用 /admin-service/api/v1/xxx 路径,不匹配任何 Kong 路由 修复: - 后端:Controller 路径去掉 api/v1 前缀,由全局前缀统一添加 - Kong:新增 admin-app-assets-public 和 admin-system-config-public 路由 - Flutter:API 路径改为 /app-assets 和 /system-config/display/settings 受影响文件: - backend/api-gateway/kong.yml (新增2条路由) - backend/.../app-asset.controller.ts (Controller路径修正) - backend/.../system-config.controller.ts (Controller路径修正) - frontend/.../app_asset_service.dart (API路径修正) - frontend/.../system_config_service.dart (API路径修正) Co-Authored-By: Claude Opus 4.5 --- backend/api-gateway/kong.yml | 8 ++++++++ .../src/api/controllers/app-asset.controller.ts | 2 +- .../src/api/controllers/system-config.controller.ts | 2 +- .../mobile-app/lib/core/services/app_asset_service.dart | 2 +- .../lib/core/services/system_config_service.dart | 2 +- 5 files changed, 12 insertions(+), 4 deletions(-) diff --git a/backend/api-gateway/kong.yml b/backend/api-gateway/kong.yml index 7e6f4c4f..35ecee9a 100644 --- a/backend/api-gateway/kong.yml +++ b/backend/api-gateway/kong.yml @@ -228,6 +228,14 @@ services: paths: - /api/v1/mobile/system strip_path: false + - name: admin-app-assets-public + paths: + - /api/v1/app-assets + strip_path: false + - name: admin-system-config-public + paths: + - /api/v1/system-config + strip_path: false # --------------------------------------------------------------------------- # Presence Service - 在线状态服务 diff --git a/backend/services/admin-service/src/api/controllers/app-asset.controller.ts b/backend/services/admin-service/src/api/controllers/app-asset.controller.ts index c51e64ae..03c9fd62 100644 --- a/backend/services/admin-service/src/api/controllers/app-asset.controller.ts +++ b/backend/services/admin-service/src/api/controllers/app-asset.controller.ts @@ -229,7 +229,7 @@ export class AdminAppAssetController { // ============================================================================= @ApiTags('App Assets (Public)') -@Controller('api/v1/app-assets') +@Controller('app-assets') export class PublicAppAssetController { constructor(private readonly prisma: PrismaService) {} diff --git a/backend/services/admin-service/src/api/controllers/system-config.controller.ts b/backend/services/admin-service/src/api/controllers/system-config.controller.ts index 560781b7..6ad1ad71 100644 --- a/backend/services/admin-service/src/api/controllers/system-config.controller.ts +++ b/backend/services/admin-service/src/api/controllers/system-config.controller.ts @@ -173,7 +173,7 @@ export class AdminSystemConfigController { * 移动端/公开系统配置控制器 * 用于 mobile-app 获取展示相关的配置 */ -@Controller('api/v1/system-config') +@Controller('system-config') export class PublicSystemConfigController { constructor( @Inject(SYSTEM_CONFIG_REPOSITORY) diff --git a/frontend/mobile-app/lib/core/services/app_asset_service.dart b/frontend/mobile-app/lib/core/services/app_asset_service.dart index 6dd1b96c..8604e212 100644 --- a/frontend/mobile-app/lib/core/services/app_asset_service.dart +++ b/frontend/mobile-app/lib/core/services/app_asset_service.dart @@ -179,7 +179,7 @@ class AppAssetService { Future _fetchFromApi() async { try { final response = await _apiClient.get( - '/admin-service/api/v1/app-assets', + '/app-assets', ); if (response.data is List) { return AppAssetConfig.fromList(response.data as List); diff --git a/frontend/mobile-app/lib/core/services/system_config_service.dart b/frontend/mobile-app/lib/core/services/system_config_service.dart index 10ce6a72..c91045d4 100644 --- a/frontend/mobile-app/lib/core/services/system_config_service.dart +++ b/frontend/mobile-app/lib/core/services/system_config_service.dart @@ -77,7 +77,7 @@ class SystemConfigService { try { final response = await _apiClient.get( - '/admin-service/api/v1/system-config/display/settings', + '/system-config/display/settings', ); _cachedDisplaySettings = DisplaySettings.fromJson(response.data);