init: AI培训与智能巡检系统

This commit is contained in:
selfrelease
2026-06-16 00:55:20 +08:00
commit c55598494b
201 changed files with 53131 additions and 0 deletions
+81
View File
@@ -0,0 +1,81 @@
import {
Body,
Controller,
Get,
Param,
ParseIntPipe,
Post,
Query,
UseGuards,
} from '@nestjs/common';
import {
IsInt,
IsOptional,
IsString,
MaxLength,
MinLength,
} from 'class-validator';
import { Type } from 'class-transformer';
import { ForumService } from './forum.service';
import { CurrentUser, JwtAuthGuard, type JwtPayload } from '../auth/roles';
class CreateThreadDto {
@IsString() @MinLength(1) @MaxLength(40)
board!: string;
@IsOptional() @Type(() => Number) @IsInt()
modelId?: number;
@IsString() @MinLength(2) @MaxLength(80)
title!: string;
@IsString() @MinLength(1) @MaxLength(5000)
body!: string;
}
class ReplyDto {
@IsString() @MinLength(1) @MaxLength(5000)
body!: string;
}
@Controller('api')
export class ForumController {
constructor(private readonly forum: ForumService) {}
@Get('boards')
boards() {
return this.forum.boards();
}
@Get('threads')
list(
@Query('board') board?: string,
@Query('modelId') modelId?: string,
) {
return this.forum.listThreads({
board,
modelId: modelId ? Number(modelId) : undefined,
});
}
@Get('threads/:id')
get(@Param('id', ParseIntPipe) id: number) {
return this.forum.getThread(id);
}
@Post('threads')
@UseGuards(JwtAuthGuard)
create(@Body() dto: CreateThreadDto, @CurrentUser() user: JwtPayload) {
return this.forum.createThread(user.sub, dto);
}
@Post('threads/:id/replies')
@UseGuards(JwtAuthGuard)
reply(
@Param('id', ParseIntPipe) id: number,
@Body() dto: ReplyDto,
@CurrentUser() user: JwtPayload,
) {
return this.forum.addReply(user.sub, id, dto.body);
}
}