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:
kevin-asprec
2026-05-04 16:35:33 +08:00
parent d7ab370bb5
commit 29c6b70878
8 changed files with 246 additions and 1 deletions

View 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,
);
}
}