|
@@ -19,7 +19,10 @@ export class ContentController {
|
|
constructor(private readonly contentService: ContentService) {}
|
|
constructor(private readonly contentService: ContentService) {}
|
|
|
|
|
|
@Post()
|
|
@Post()
|
|
- @ApiOperation({ summary: '创建内容', description: '创建新的内容记录,自动生成新版本' })
|
|
|
|
|
|
+ @ApiOperation({
|
|
|
|
+ summary: '创建内容',
|
|
|
|
+ description: '创建新的内容记录,自动生成新版本',
|
|
|
|
+ })
|
|
@ApiResponse({ status: 201, description: '内容创建成功' })
|
|
@ApiResponse({ status: 201, description: '内容创建成功' })
|
|
@ApiResponse({ status: 400, description: '请求参数错误' })
|
|
@ApiResponse({ status: 400, description: '请求参数错误' })
|
|
create(@Body() createContentDto: CreateContentDto) {
|
|
create(@Body() createContentDto: CreateContentDto) {
|
|
@@ -34,11 +37,15 @@ export class ContentController {
|
|
}
|
|
}
|
|
|
|
|
|
@Get('chapter/:chapterId')
|
|
@Get('chapter/:chapterId')
|
|
- @ApiOperation({
|
|
|
|
- summary: '获取章节最新内容',
|
|
|
|
- description: '根据章节ID获取最新版本的内容'
|
|
|
|
|
|
+ @ApiOperation({
|
|
|
|
+ summary: '获取章节最新内容',
|
|
|
|
+ description: '根据章节ID获取最新版本的内容',
|
|
|
|
+ })
|
|
|
|
+ @ApiParam({
|
|
|
|
+ name: 'chapterId',
|
|
|
|
+ description: '章节ID',
|
|
|
|
+ example: 'book_1_20240101120000_abc123',
|
|
})
|
|
})
|
|
- @ApiParam({ name: 'chapterId', description: '章节ID', example: 'book_1_20240101120000_abc123' })
|
|
|
|
@ApiResponse({ status: 200, description: '获取成功' })
|
|
@ApiResponse({ status: 200, description: '获取成功' })
|
|
@ApiResponse({ status: 404, description: '内容不存在' })
|
|
@ApiResponse({ status: 404, description: '内容不存在' })
|
|
findByChapterId(@Param('chapterId') chapterId: string) {
|
|
findByChapterId(@Param('chapterId') chapterId: string) {
|
|
@@ -46,39 +53,53 @@ export class ContentController {
|
|
}
|
|
}
|
|
|
|
|
|
@Get('chapter/:chapterId/versions')
|
|
@Get('chapter/:chapterId/versions')
|
|
- @ApiOperation({
|
|
|
|
- summary: '获取章节所有版本',
|
|
|
|
- description: '根据章节ID获取所有版本的内容'
|
|
|
|
|
|
+ @ApiOperation({
|
|
|
|
+ summary: '获取章节所有版本',
|
|
|
|
+ description: '根据章节ID获取所有版本的内容',
|
|
|
|
+ })
|
|
|
|
+ @ApiParam({
|
|
|
|
+ name: 'chapterId',
|
|
|
|
+ description: '章节ID',
|
|
|
|
+ example: 'book_1_20240101120000_abc123',
|
|
})
|
|
})
|
|
- @ApiParam({ name: 'chapterId', description: '章节ID', example: 'book_1_20240101120000_abc123' })
|
|
|
|
@ApiResponse({ status: 200, description: '获取成功' })
|
|
@ApiResponse({ status: 200, description: '获取成功' })
|
|
findVersionsByChapterId(@Param('chapterId') chapterId: string) {
|
|
findVersionsByChapterId(@Param('chapterId') chapterId: string) {
|
|
return this.contentService.findVersionsByChapterId(chapterId);
|
|
return this.contentService.findVersionsByChapterId(chapterId);
|
|
}
|
|
}
|
|
|
|
|
|
@Get('chapter/:chapterId/version/:version')
|
|
@Get('chapter/:chapterId/version/:version')
|
|
- @ApiOperation({
|
|
|
|
- summary: '获取指定版本内容',
|
|
|
|
- description: '根据章节ID和版本号获取指定版本的内容'
|
|
|
|
|
|
+ @ApiOperation({
|
|
|
|
+ summary: '获取指定版本内容',
|
|
|
|
+ description: '根据章节ID和版本号获取指定版本的内容',
|
|
|
|
+ })
|
|
|
|
+ @ApiParam({
|
|
|
|
+ name: 'chapterId',
|
|
|
|
+ description: '章节ID',
|
|
|
|
+ example: 'book_1_20240101120000_abc123',
|
|
})
|
|
})
|
|
- @ApiParam({ name: 'chapterId', description: '章节ID', example: 'book_1_20240101120000_abc123' })
|
|
|
|
@ApiParam({ name: 'version', description: '版本号', example: 1 })
|
|
@ApiParam({ name: 'version', description: '版本号', example: 1 })
|
|
@ApiResponse({ status: 200, description: '获取成功' })
|
|
@ApiResponse({ status: 200, description: '获取成功' })
|
|
@ApiResponse({ status: 404, description: '内容不存在' })
|
|
@ApiResponse({ status: 404, description: '内容不存在' })
|
|
- findByChapterIdAndVersion(@Param('chapterId') chapterId: string, @Param('version') version: string) {
|
|
|
|
|
|
+ findByChapterIdAndVersion(
|
|
|
|
+ @Param('chapterId') chapterId: string,
|
|
|
|
+ @Param('version') version: string,
|
|
|
|
+ ) {
|
|
return this.contentService.findByChapterIdAndVersion(chapterId, +version);
|
|
return this.contentService.findByChapterIdAndVersion(chapterId, +version);
|
|
}
|
|
}
|
|
|
|
|
|
@Patch(':id/status/:status')
|
|
@Patch(':id/status/:status')
|
|
- @ApiOperation({
|
|
|
|
- summary: '更新内容状态',
|
|
|
|
- description: '更新内容的发布状态'
|
|
|
|
|
|
+ @ApiOperation({
|
|
|
|
+ summary: '更新内容状态',
|
|
|
|
+ description: '更新内容的发布状态',
|
|
})
|
|
})
|
|
@ApiParam({ name: 'id', description: '内容ID', example: 1 })
|
|
@ApiParam({ name: 'id', description: '内容ID', example: 1 })
|
|
@ApiParam({ name: 'status', description: '内容状态', example: 'published' })
|
|
@ApiParam({ name: 'status', description: '内容状态', example: 'published' })
|
|
@ApiResponse({ status: 200, description: '状态更新成功' })
|
|
@ApiResponse({ status: 200, description: '状态更新成功' })
|
|
@ApiResponse({ status: 404, description: '内容不存在' })
|
|
@ApiResponse({ status: 404, description: '内容不存在' })
|
|
- updateStatus(@Param('id') id: string, @Param('status') status: ContentStatus) {
|
|
|
|
|
|
+ updateStatus(
|
|
|
|
+ @Param('id') id: string,
|
|
|
|
+ @Param('status') status: ContentStatus,
|
|
|
|
+ ) {
|
|
return this.contentService.updateStatus(+id, status);
|
|
return this.contentService.updateStatus(+id, status);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -95,9 +116,9 @@ export class ContentController {
|
|
}
|
|
}
|
|
|
|
|
|
@Patch(':id')
|
|
@Patch(':id')
|
|
- @ApiOperation({
|
|
|
|
- summary: '更新内容',
|
|
|
|
- description: '根据ID更新内容,会创建新版本而不是修改现有版本'
|
|
|
|
|
|
+ @ApiOperation({
|
|
|
|
+ summary: '更新内容',
|
|
|
|
+ description: '根据ID更新内容,会创建新版本而不是修改现有版本',
|
|
})
|
|
})
|
|
@ApiParam({ name: 'id', description: '内容ID', example: 1 })
|
|
@ApiParam({ name: 'id', description: '内容ID', example: 1 })
|
|
@ApiResponse({ status: 200, description: '更新成功' })
|
|
@ApiResponse({ status: 200, description: '更新成功' })
|