Compare commits
2 Commits
489184b841
...
3216fd00f6
| Author | SHA1 | Date | |
|---|---|---|---|
| 3216fd00f6 | |||
|
|
a0d87692ea |
@ -84,6 +84,20 @@ export class TasksController {
|
||||
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' })
|
||||
@ApiParam({ name: 'id', type: 'number' })
|
||||
@ApiBody({
|
||||
|
||||
@ -42,6 +42,13 @@ export class TasksService {
|
||||
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 }) {
|
||||
const task = await this.findOneById(id);
|
||||
if (!task) throw new NotFoundException('Task not found');
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user