增强文章控制器的安全性,添加JWT身份验证守卫;优化训练计划服务,简化日志记录逻辑,确保使用计划创建训练会话时的准确性;更新训练会话模型,允许训练计划ID为可空字段。

This commit is contained in:
2025-08-16 13:42:36 +08:00
parent fafb618c32
commit 477f5b4b79
4 changed files with 47 additions and 39 deletions

View File

@@ -6,7 +6,7 @@ import { CreateArticleDto, QueryArticlesDto, CreateArticleResponseDto, QueryArti
@ApiTags('articles')
@Controller('articles')
@UseGuards(JwtAuthGuard)
export class ArticlesController {
constructor(private readonly articlesService: ArticlesService) { }
@@ -15,12 +15,14 @@ export class ArticlesController {
@ApiOperation({ summary: '创建文章' })
@ApiBody({ type: CreateArticleDto })
@ApiResponse({ status: 200 })
@UseGuards(JwtAuthGuard)
async create(@Body() dto: CreateArticleDto): Promise<CreateArticleResponseDto> {
return this.articlesService.create(dto);
}
@Get('list')
@HttpCode(HttpStatus.OK)
@UseGuards(JwtAuthGuard)
@ApiOperation({ summary: '查询文章列表(分页)' })
async list(@Query() query: QueryArticlesDto): Promise<QueryArticlesResponseDto> {
return this.articlesService.query(query);
@@ -36,6 +38,7 @@ export class ArticlesController {
// 增加阅读数
@Post(':id/read-count')
@HttpCode(HttpStatus.OK)
@UseGuards(JwtAuthGuard)
@ApiOperation({ summary: '增加文章阅读数' })
async increaseReadCount(@Param('id') id: string): Promise<CreateArticleResponseDto> {
return this.articlesService.increaseReadCount(id);