This commit is contained in:
Jerry 2025-08-24 23:06:33 +08:00
parent ccda3ec271
commit 35eea17a8f
4 changed files with 16 additions and 9 deletions

View File

@ -8,6 +8,7 @@ import { AutoUpdateModule } from './core/auto-update/auto-update.module';
import { PersistenceModule } from './core/persistence/persistence.module'; import { PersistenceModule } from './core/persistence/persistence.module';
import { RedisModule } from './core/redis/redis.module'; import { RedisModule } from './core/redis/redis.module';
import { WsModule } from './core/ws/ws.module'; import { WsModule } from './core/ws/ws.module';
import { SystemWebModule } from './modules/system/systemWeb.module';
@Module({ @Module({
imports: [ imports: [
@ -20,6 +21,7 @@ import { WsModule } from './core/ws/ws.module';
AutoUpdateModule, AutoUpdateModule,
RedisModule, RedisModule,
WsModule, WsModule,
SystemWebModule,
], ],
}) })
export class AppModule {} export class AppModule {}

View File

@ -5,17 +5,21 @@ import {
UnauthorizedException, UnauthorizedException,
Inject, Inject,
} from '@nestjs/common'; } from '@nestjs/common';
import { ApiTags, ApiOperation, ApiBody } from '@nestjs/swagger'; import { ApiTags, ApiOperation, ApiBody, ApiProperty } from '@nestjs/swagger';
import { SystemWebService } from './system.service'; import { SystemWebService } from './systemWeb.service';
import { ToolsService } from '../../core/tools/tools.service'; import { ToolsService } from '../../core/tools/tools.service';
class TokenDto { class TokenDto {
@ApiProperty({
description: '密钥',
example: '1111',
})
token: string; token: string;
} }
@ApiTags('System') @ApiTags('System')
@Controller('system') @Controller('system')
export class SystemController { export class SystemWebController {
constructor( constructor(
@Inject(SystemWebService) @Inject(SystemWebService)
private readonly systemService: SystemWebService, private readonly systemService: SystemWebService,
@ -29,7 +33,7 @@ export class SystemController {
@Post('restart') @Post('restart')
@ApiOperation({ @ApiOperation({
summary: '系统重启', summary: '系统重启',
description: '传入正确的 token 后,核心执行重启', description: '核心执行重启',
}) })
@ApiBody({ type: TokenDto }) @ApiBody({ type: TokenDto })
async systemRestart(@Body() body: TokenDto): Promise<string> { async systemRestart(@Body() body: TokenDto): Promise<string> {
@ -46,7 +50,7 @@ export class SystemController {
@Post('getRestartTime') @Post('getRestartTime')
@ApiOperation({ @ApiOperation({
summary: '获取重启所需时间', summary: '获取重启所需时间',
description: '传入正确的 token返回上次核心重启的耗时', description: '返回上次核心重启的耗时',
}) })
@ApiBody({ type: TokenDto }) @ApiBody({ type: TokenDto })
async getRestartTime(@Body() body: TokenDto): Promise<string> { async getRestartTime(@Body() body: TokenDto): Promise<string> {

View File

@ -1,12 +1,13 @@
import { Module } from '@nestjs/common'; import { Module } from '@nestjs/common';
import { SystemController } from './system.controller'; import { SystemWebController } from './systemWeb.controller';
import { SystemWebService } from './system.service'; import { SystemWebService } from './systemWeb.service';
import { ToolsModule } from '../../core/tools/tools.module'; import { ToolsModule } from '../../core/tools/tools.module';
import { PathModule } from '../../core/path/path.module'; import { PathModule } from '../../core/path/path.module';
import { SystemModule } from '../../core/system/system.module';
@Module({ @Module({
imports: [ToolsModule, SystemModule, PathModule], imports: [ToolsModule, SystemModule, PathModule],
controllers: [SystemController], controllers: [SystemWebController],
providers: [SystemWebService], providers: [SystemWebService],
}) })
export class SystemModule {} export class SystemWebModule {}