新增训练计划模块,包括控制器、服务、模型及数据传输对象,更新应用模块以引入新模块,同时在AI教练模块中添加体态评估功能,支持体重识别与更新,优化用户体重历史记录管理。
This commit is contained in:
37
src/articles/articles.controller.ts
Normal file
37
src/articles/articles.controller.ts
Normal file
@@ -0,0 +1,37 @@
|
||||
import { Body, Controller, Get, HttpCode, HttpStatus, Param, Post, Query, UseGuards } from '@nestjs/common';
|
||||
import { ApiBody, ApiOperation, ApiResponse, ApiTags } from '@nestjs/swagger';
|
||||
import { JwtAuthGuard } from '../common/guards/jwt-auth.guard';
|
||||
import { ArticlesService } from './articles.service';
|
||||
import { CreateArticleDto, QueryArticlesDto, CreateArticleResponseDto, QueryArticlesResponseDto } from './dto/article.dto';
|
||||
|
||||
@ApiTags('articles')
|
||||
@Controller('articles')
|
||||
@UseGuards(JwtAuthGuard)
|
||||
export class ArticlesController {
|
||||
constructor(private readonly articlesService: ArticlesService) { }
|
||||
|
||||
@Post('create')
|
||||
@HttpCode(HttpStatus.OK)
|
||||
@ApiOperation({ summary: '创建文章' })
|
||||
@ApiBody({ type: CreateArticleDto })
|
||||
@ApiResponse({ status: 200 })
|
||||
async create(@Body() dto: CreateArticleDto): Promise<CreateArticleResponseDto> {
|
||||
return this.articlesService.create(dto);
|
||||
}
|
||||
|
||||
@Get('list')
|
||||
@HttpCode(HttpStatus.OK)
|
||||
@ApiOperation({ summary: '查询文章列表(分页)' })
|
||||
async list(@Query() query: QueryArticlesDto): Promise<QueryArticlesResponseDto> {
|
||||
return this.articlesService.query(query);
|
||||
}
|
||||
|
||||
@Get(':id')
|
||||
@HttpCode(HttpStatus.OK)
|
||||
@ApiOperation({ summary: '获取文章详情并增加阅读数' })
|
||||
async getOne(@Param('id') id: string): Promise<CreateArticleResponseDto> {
|
||||
return this.articlesService.getAndIncreaseReadCount(id);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user