- AppModule 注册 3 个 BullMQ Workers (AiAnalysis/DocumentImport/Notification) - Users 模块新增 GET/PATCH /users/me/profile 端点: - GET 读取 UserProfile (learningIdentity, learningDirection, bio, currentGoal) - PATCH upsert UserProfile - GET /users/me 返回 profile + preferences (include join) - 新增 RolesGuard + @Roles() 装饰器 (UserRole enum) - QueueModule/QueueService 改进 - 各模块 controller/repository/service 完善 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
43 lines
1.7 KiB
TypeScript
43 lines
1.7 KiB
TypeScript
import { Controller, Get, Post, Patch, Delete, Body, Param, Query } from '@nestjs/common';
|
|
import { ApiTags, ApiOperation, ApiResponse } from '@nestjs/swagger';
|
|
import { KnowledgeBaseService } from './knowledge-base.service';
|
|
import { CurrentUser } from '../../common/decorators/current-user.decorator';
|
|
import { PaginationDto } from '../../common/dto/pagination.dto';
|
|
import type { UserPayload } from '../../common/types';
|
|
|
|
@ApiTags('knowledge-base')
|
|
@Controller('knowledge-bases')
|
|
export class KnowledgeBaseController {
|
|
constructor(private readonly service: KnowledgeBaseService) {}
|
|
|
|
@Post()
|
|
@ApiOperation({ summary: '创建知识库' })
|
|
async create(@CurrentUser() user: UserPayload, @Body() dto: any) {
|
|
return this.service.create(String(user?.id || 'anonymous'), dto);
|
|
}
|
|
|
|
@Get()
|
|
@ApiOperation({ summary: '获取知识库列表' })
|
|
async findAll(@CurrentUser() user: UserPayload, @Query() pagination: PaginationDto) {
|
|
return this.service.findAll(String(user?.id || 'anonymous'), pagination);
|
|
}
|
|
|
|
@Get(':id')
|
|
@ApiOperation({ summary: '获取知识库详情' })
|
|
async findOne(@CurrentUser() user: UserPayload, @Param('id') id: string) {
|
|
return this.service.findOne(String(user?.id || 'anonymous'), id);
|
|
}
|
|
|
|
@Patch(':id')
|
|
@ApiOperation({ summary: '更新知识库' })
|
|
async update(@CurrentUser() user: UserPayload, @Param('id') id: string, @Body() dto: any) {
|
|
return this.service.update(String(user?.id || 'anonymous'), id, dto);
|
|
}
|
|
|
|
@Delete(':id')
|
|
@ApiOperation({ summary: '删除知识库' })
|
|
async remove(@CurrentUser() user: UserPayload, @Param('id') id: string) {
|
|
return this.service.remove(String(user?.id || 'anonymous'), id);
|
|
}
|
|
}
|