feat(backend): Aufgaben-Modul (Modul 6)
TasksModule mit CRUD, Status-/Prioritätsfilter und Erledigen-Endpunkt für polymorph verknüpfte Aufgaben.
This commit is contained in:
1 parent
829753ec90
commit
7bba168bd6
9 files changed
+408
-1
No files matched your search
@@ -0,0 +1,59 @@
|
||||
import {
|
||||
Body,
|
||||
Controller,
|
||||
Get,
|
||||
Param,
|
||||
Patch,
|
||||
Post,
|
||||
Query,
|
||||
} from '@nestjs/common';
|
||||
import { ApiBearerAuth, ApiTags } from '@nestjs/swagger';
|
||||
import { Role, TaskPriority, TaskStatus } from '../../generated/prisma';
|
||||
import { Roles } from '../auth/decorators/roles.decorator';
|
||||
import { CurrentUser } from '../auth/decorators/current-user.decorator';
|
||||
import type { AuthenticatedUser } from '../auth/types/authenticated-user';
|
||||
import { CreateTaskDto } from './dto/create-task.dto';
|
||||
import { UpdateTaskDto } from './dto/update-task.dto';
|
||||
import { TasksService } from './tasks.service';
|
||||
|
||||
@ApiTags('tasks')
|
||||
@ApiBearerAuth()
|
||||
@Controller('tasks')
|
||||
export class TasksController {
|
||||
constructor(private readonly tasksService: TasksService) {}
|
||||
|
||||
@Get()
|
||||
findAll(
|
||||
@Query('status') status?: TaskStatus,
|
||||
@Query('priority') priority?: TaskPriority,
|
||||
) {
|
||||
return this.tasksService.findAll({ status, priority });
|
||||
}
|
||||
|
||||
@Get(':id')
|
||||
findOne(@Param('id') id: string) {
|
||||
return this.tasksService.findById(id);
|
||||
}
|
||||
|
||||
@Roles(Role.ADMIN, Role.BEEKEEPER, Role.STAFF)
|
||||
@Post()
|
||||
create(@Body() dto: CreateTaskDto, @CurrentUser() actor: AuthenticatedUser) {
|
||||
return this.tasksService.create(dto, actor.id);
|
||||
}
|
||||
|
||||
@Roles(Role.ADMIN, Role.BEEKEEPER, Role.STAFF)
|
||||
@Patch(':id')
|
||||
update(
|
||||
@Param('id') id: string,
|
||||
@Body() dto: UpdateTaskDto,
|
||||
@CurrentUser() actor: AuthenticatedUser,
|
||||
) {
|
||||
return this.tasksService.update(id, dto, actor.id);
|
||||
}
|
||||
|
||||
@Roles(Role.ADMIN, Role.BEEKEEPER, Role.STAFF)
|
||||
@Post(':id/complete')
|
||||
complete(@Param('id') id: string, @CurrentUser() actor: AuthenticatedUser) {
|
||||
return this.tasksService.complete(id, actor.id);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user