Files
dsc-api/src/modules/task-manager/controllers/attachment.controller.ts
T

42 lines
1.9 KiB
TypeScript

import { Controller, Post, Patch, Delete, Param, Body } from '@nestjs/common';
import { ApiTags, ApiOperation, ApiResponse, ApiParam } from '@nestjs/swagger';
import { AttachmentService } from '../providers/attachment.service';
import { CreateAttachmentDto } from '../dto/attachment/create-attachment.dto';
import { UpdateAttachmentDto } from '../dto/attachment/update-attachment.dto';
import { TMAttachment } from '../entities/attachment.entity';
import { AuthGuards } from '../../../common/decorators/auth-guard.decorator';
import { AdminRoute } from '../../../common/decorators/admin.decorator';
@AuthGuards()
@AdminRoute()
@ApiTags('Task Manager - Attachments')
@Controller('task-manager/attachments')
export class AttachmentController {
constructor(private readonly attachmentService: AttachmentService) {}
@Post()
@ApiOperation({ summary: 'Create a new attachment' })
@ApiResponse({ status: 201, description: 'Attachment created', type: TMAttachment })
@ApiResponse({ status: 404, description: 'Task not found' })
create(@Body() body: CreateAttachmentDto): Promise<TMAttachment> {
return this.attachmentService.create(body);
}
@Patch(':id')
@ApiOperation({ summary: 'Update an attachment' })
@ApiParam({ name: 'id', description: 'Attachment ID' })
@ApiResponse({ status: 200, description: 'Attachment updated', type: TMAttachment })
@ApiResponse({ status: 404, description: 'Attachment or Task not found' })
update(@Param('id') id: string, @Body() body: UpdateAttachmentDto): Promise<TMAttachment> {
return this.attachmentService.update(id, body);
}
@Delete(':id')
@ApiOperation({ summary: 'Delete an attachment' })
@ApiParam({ name: 'id', description: 'Attachment ID' })
@ApiResponse({ status: 200, description: 'Attachment deleted' })
@ApiResponse({ status: 404, description: 'Attachment not found' })
remove(@Param('id') id: string): Promise<void> {
return this.attachmentService.remove(id);
}
}