From 8655b7805f29f791c6b5929b55e67a1f925fc70b Mon Sep 17 00:00:00 2001 From: joey-home Date: Thu, 3 Sep 2026 21:39:53 +0800 Subject: [PATCH] =?UTF-8?q?fix(api):=20stores=20=E6=8E=A7=E5=88=B6?= =?UTF-8?q?=E5=99=A8=E6=98=BE=E5=BC=8F=20@Inject=20=E6=9C=8D=E5=8A=A1?= =?UTF-8?q?=E4=BE=9D=E8=B5=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit tsx/esbuild 不生成 design:paramtypes 装饰器元数据,裸类型构造参数在 dev 运行时注入 undefined,GET /api/platforms 返回 500。改为与 auth.controller.ts 一致的显式 @Inject(...)。 跨领域改动说明:前端联调平台上下文时发现该阻断性 bug,修复方式 沿用仓库既有模式,不影响服务层(原本即显式 token 注入)。 --- apps/api/src/stores/stores.controller.ts | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/apps/api/src/stores/stores.controller.ts b/apps/api/src/stores/stores.controller.ts index 4879f5e..6fdf7cf 100644 --- a/apps/api/src/stores/stores.controller.ts +++ b/apps/api/src/stores/stores.controller.ts @@ -5,6 +5,7 @@ import { Get, Headers, HttpCode, + Inject, Param, Patch, Post, @@ -39,7 +40,11 @@ type HttpResponse = { status: (status: number) => HttpResponse }; @ApiBearerAuth('access-token') @Controller() export class PlatformsController { - public constructor(private readonly platformsService: PlatformsService) {} + // tsx/esbuild 不生成 design:paramtypes 元数据,控制器依赖必须显式 @Inject(与 auth.controller 一致) + public constructor( + @Inject(PlatformsService) + private readonly platformsService: PlatformsService, + ) {} @Get('platforms') @ApiOperation({ summary: '获取已启用的平台及非敏感能力目录' }) @@ -75,7 +80,9 @@ export class PlatformsController { @ApiBearerAuth('access-token') @Controller('stores') export class StoresController { - public constructor(private readonly storesService: StoresService) {} + public constructor( + @Inject(StoresService) private readonly storesService: StoresService, + ) {} @Get() @ApiOperation({ summary: '按平台分页列出当前工作空间的门店' }) @@ -260,7 +267,9 @@ export class StoresController { @ApiBearerAuth('access-token') @Controller('operations') export class OperationsController { - public constructor(private readonly storesService: StoresService) {} + public constructor( + @Inject(StoresService) private readonly storesService: StoresService, + ) {} @Get(':operationId') @ApiOperation({ summary: '读取当前工作空间的异步操作状态' })