feat(backend): Durchsichten-Modul (Modul 5)
InspectionsModule mit CRUD, Colony-Historie-Endpunkt und Folgeaufgaben-Erstellung aus einer Durchsicht heraus.
This commit is contained in:
1 parent
49ce23147c
commit
9b59e4bb35
10 files changed
+489
-1
No files matched your search
@@ -0,0 +1,45 @@
|
||||
import { Body, Controller, Get, Param, Post } from '@nestjs/common';
|
||||
import { ApiBearerAuth, ApiTags } from '@nestjs/swagger';
|
||||
import { Role } 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 { CreateInspectionDto } from './dto/create-inspection.dto';
|
||||
import { CreateTaskFromInspectionDto } from './dto/create-task-from-inspection.dto';
|
||||
import { InspectionsService } from './inspections.service';
|
||||
|
||||
@ApiTags('inspections')
|
||||
@ApiBearerAuth()
|
||||
@Controller('inspections')
|
||||
export class InspectionsController {
|
||||
constructor(private readonly inspectionsService: InspectionsService) {}
|
||||
|
||||
@Get()
|
||||
findAll() {
|
||||
return this.inspectionsService.findAll();
|
||||
}
|
||||
|
||||
@Get(':id')
|
||||
findOne(@Param('id') id: string) {
|
||||
return this.inspectionsService.findById(id);
|
||||
}
|
||||
|
||||
@Roles(Role.ADMIN, Role.BEEKEEPER, Role.STAFF)
|
||||
@Post()
|
||||
create(
|
||||
@Body() dto: CreateInspectionDto,
|
||||
@CurrentUser() actor: AuthenticatedUser,
|
||||
) {
|
||||
return this.inspectionsService.create(dto, actor.id);
|
||||
}
|
||||
|
||||
@Roles(Role.ADMIN, Role.BEEKEEPER, Role.STAFF)
|
||||
@Post(':id/create-task')
|
||||
createTask(
|
||||
@Param('id') id: string,
|
||||
@Body() dto: CreateTaskFromInspectionDto,
|
||||
@CurrentUser() actor: AuthenticatedUser,
|
||||
) {
|
||||
return this.inspectionsService.createTaskFromInspection(id, dto, actor.id);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user