From 270c17829eaa20ab5a5889ed7f7127e9b4c902ca Mon Sep 17 00:00:00 2001 From: hailin Date: Wed, 14 Jan 2026 04:57:25 -0800 Subject: [PATCH] fix(mining-admin-service): move mining routes before :category/:key parameter route NestJS matches routes in definition order. The :category/:key route was matching mining/status before the specific mining routes. Moved mining routes before the parameter routes to fix routing. Co-Authored-By: Claude Opus 4.5 --- .../src/api/controllers/config.controller.ts | 46 +++++++++---------- 1 file changed, 22 insertions(+), 24 deletions(-) diff --git a/backend/services/mining-admin-service/src/api/controllers/config.controller.ts b/backend/services/mining-admin-service/src/api/controllers/config.controller.ts index 1d610075..8d824ac0 100644 --- a/backend/services/mining-admin-service/src/api/controllers/config.controller.ts +++ b/backend/services/mining-admin-service/src/api/controllers/config.controller.ts @@ -37,28 +37,6 @@ export class ConfigController { return { success: true }; } - @Get(':category/:key') - @ApiOperation({ summary: '获取单个配置' }) - @ApiParam({ name: 'category' }) - @ApiParam({ name: 'key' }) - async getConfig(@Param('category') category: string, @Param('key') key: string) { - return this.configService.getConfig(category, key); - } - - @Post() - @ApiOperation({ summary: '设置配置' }) - async setConfig(@Body() dto: SetConfigDto, @Req() req: any) { - await this.configService.setConfig(req.admin.id, dto.category, dto.key, dto.value, dto.description); - return { success: true }; - } - - @Delete(':category/:key') - @ApiOperation({ summary: '删除配置' }) - async deleteConfig(@Param('category') category: string, @Param('key') key: string, @Req() req: any) { - await this.configService.deleteConfig(req.admin.id, category, key); - return { success: true }; - } - @Get('mining/status') @ApiOperation({ summary: '获取挖矿状态' }) async getMiningStatus() { @@ -71,11 +49,9 @@ export class ConfigController { } const result = await response.json(); this.logger.log(`Mining service response: ${JSON.stringify(result)}`); - // mining-service 返回 { success, data, timestamp },需要解包 data if (result.data) { return result.data; } - // 如果没有 data 字段,返回错误状态 return { initialized: false, isActive: false, @@ -130,4 +106,26 @@ export class ConfigController { return { success: false, message: 'Failed to deactivate mining' }; } } + + @Get(':category/:key') + @ApiOperation({ summary: '获取单个配置' }) + @ApiParam({ name: 'category' }) + @ApiParam({ name: 'key' }) + async getConfig(@Param('category') category: string, @Param('key') key: string) { + return this.configService.getConfig(category, key); + } + + @Post() + @ApiOperation({ summary: '设置配置' }) + async setConfig(@Body() dto: SetConfigDto, @Req() req: any) { + await this.configService.setConfig(req.admin.id, dto.category, dto.key, dto.value, dto.description); + return { success: true }; + } + + @Delete(':category/:key') + @ApiOperation({ summary: '删除配置' }) + async deleteConfig(@Param('category') category: string, @Param('key') key: string, @Req() req: any) { + await this.configService.deleteConfig(req.admin.id, category, key); + return { success: true }; + } }