feat: add ticket comments, file attachments, mention notifications
- Comment module with CRUD and file upload via multer - @mention parsing with user notification - Assignment notification on ticket update - Notification service enhanced with ticketId linking - ServeStaticModule for uploaded files
This commit is contained in:
52
src/comment/comment.controller.ts
Normal file
52
src/comment/comment.controller.ts
Normal file
@@ -0,0 +1,52 @@
|
||||
import {
|
||||
Controller,
|
||||
Get,
|
||||
Post,
|
||||
Param,
|
||||
Body,
|
||||
UseGuards,
|
||||
UseInterceptors,
|
||||
UploadedFiles,
|
||||
} from '@nestjs/common';
|
||||
import { AuthGuard } from '@nestjs/passport';
|
||||
import { FileFieldsInterceptor } from '@nestjs/platform-express';
|
||||
import { CommentService } from './comment.service';
|
||||
import { CreateCommentDto } from './dto/create-comment.dto';
|
||||
import { Roles } from '../common/decorators/roles.decorator';
|
||||
import { RolesGuard } from '../common/guards/roles.guard';
|
||||
import { TenantGuard } from '../common/guards/tenant.guard';
|
||||
import { CurrentUser, CurrentUserPayload } from '../common/decorators/current-user.decorator';
|
||||
import { multerOptions } from '../common/multer/multer.config';
|
||||
|
||||
@Controller('tickets/:ticketId/comments')
|
||||
@UseGuards(AuthGuard('jwt'), TenantGuard, RolesGuard)
|
||||
export class CommentController {
|
||||
constructor(private readonly commentService: CommentService) {}
|
||||
|
||||
@Get()
|
||||
@Roles('technician')
|
||||
async findAll(
|
||||
@CurrentUser() user: CurrentUserPayload,
|
||||
@Param('ticketId') ticketId: string,
|
||||
) {
|
||||
return this.commentService.findAll(user.tenantId, ticketId);
|
||||
}
|
||||
|
||||
@Post()
|
||||
@Roles('technician')
|
||||
@UseInterceptors(FileFieldsInterceptor([{ name: 'files', maxCount: 3 }], multerOptions))
|
||||
async create(
|
||||
@CurrentUser() user: CurrentUserPayload,
|
||||
@Param('ticketId') ticketId: string,
|
||||
@Body() dto: CreateCommentDto,
|
||||
@UploadedFiles() files?: { files?: Express.Multer.File[] },
|
||||
) {
|
||||
return this.commentService.create(
|
||||
user.tenantId,
|
||||
ticketId,
|
||||
user.sub,
|
||||
dto.content,
|
||||
files?.files,
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user