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 <noreply@anthropic.com>
This commit is contained in:
parent
289ac0190c
commit
270c17829e
|
|
@ -37,28 +37,6 @@ export class ConfigController {
|
||||||
return { success: true };
|
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')
|
@Get('mining/status')
|
||||||
@ApiOperation({ summary: '获取挖矿状态' })
|
@ApiOperation({ summary: '获取挖矿状态' })
|
||||||
async getMiningStatus() {
|
async getMiningStatus() {
|
||||||
|
|
@ -71,11 +49,9 @@ export class ConfigController {
|
||||||
}
|
}
|
||||||
const result = await response.json();
|
const result = await response.json();
|
||||||
this.logger.log(`Mining service response: ${JSON.stringify(result)}`);
|
this.logger.log(`Mining service response: ${JSON.stringify(result)}`);
|
||||||
// mining-service 返回 { success, data, timestamp },需要解包 data
|
|
||||||
if (result.data) {
|
if (result.data) {
|
||||||
return result.data;
|
return result.data;
|
||||||
}
|
}
|
||||||
// 如果没有 data 字段,返回错误状态
|
|
||||||
return {
|
return {
|
||||||
initialized: false,
|
initialized: false,
|
||||||
isActive: false,
|
isActive: false,
|
||||||
|
|
@ -130,4 +106,26 @@ export class ConfigController {
|
||||||
return { success: false, message: 'Failed to deactivate mining' };
|
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 };
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue