Added route Get task by ID
This commit is contained in:
parent
489184b841
commit
a0d87692ea
@ -84,6 +84,20 @@ export class TasksController {
|
|||||||
return this.tasksService.findOneById(id);
|
return this.tasksService.findOneById(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ApiOperation({ summary: 'Get tasks by project ID' })
|
||||||
|
@ApiParam({ name: 'projectId', type: 'number' })
|
||||||
|
@ApiResponse({
|
||||||
|
status: 200,
|
||||||
|
description: 'List of tasks for the specified project',
|
||||||
|
type: Task,
|
||||||
|
isArray: true,
|
||||||
|
})
|
||||||
|
@Get('project/:projectId')
|
||||||
|
async findByProject(@Param('projectId') projectId: number): Promise<Task[]> {
|
||||||
|
return this.tasksService.findByProjectId(projectId);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@ApiOperation({ summary: 'Update task' })
|
@ApiOperation({ summary: 'Update task' })
|
||||||
@ApiParam({ name: 'id', type: 'number' })
|
@ApiParam({ name: 'id', type: 'number' })
|
||||||
@ApiBody({
|
@ApiBody({
|
||||||
|
|||||||
@ -42,6 +42,13 @@ export class TasksService {
|
|||||||
return this.tasksRepository.findOne({ where: { id } });
|
return this.tasksRepository.findOne({ where: { id } });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async findByProjectId(projectId: number): Promise<Task[]> {
|
||||||
|
return this.tasksRepository.find({
|
||||||
|
where: { project: { id: projectId } },
|
||||||
|
relations: ['assigned_user'], // Загружаем связанные данные о назначенном пользователе
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
async update(id: number, data: { title?: string; status?: string; deadline?: Date; assignedUserId?: number }) {
|
async update(id: number, data: { title?: string; status?: string; deadline?: Date; assignedUserId?: number }) {
|
||||||
const task = await this.findOneById(id);
|
const task = await this.findOneById(id);
|
||||||
if (!task) throw new NotFoundException('Task not found');
|
if (!task) throw new NotFoundException('Task not found');
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user