Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 | import { Controller, Get, Post, Put, Body, Param, Req, UseGuards } from '@nestjs/common'; import { HelpdeskTicketService } from '../services/helpdesk-ticket.service'; import { HelpdeskRoutingService } from '../services/helpdesk-routing.service'; import { HelpdeskSlaService } from '../services/helpdesk-sla.service'; import { FieldServiceService } from '../services/field-service.service'; import { JwtAuthGuard } from '../../../platform/auth/jwt-auth.guard'; import { ApiTags, ApiOperation } from '@nestjs/swagger'; @ApiTags('Helpdesk') @Controller('api/v1/helpdesk') @UseGuards(JwtAuthGuard) export class HelpdeskController { constructor( private readonly ticketSvc: HelpdeskTicketService, private readonly routingSvc: HelpdeskRoutingService, private readonly slaSvc: HelpdeskSlaService, private readonly fsmSvc: FieldServiceService ) {} @Post('tickets') @ApiOperation({ summary: 'Create ticket for employee or customer' }) async createTicket(@Req() req: any, @Body() body: any) { const tenantId = req.user?.tenantId || 'SYSTEM'; const requesterId = req.user?.employeeId || req.user?.sub || 'SYSTEM'; return this.ticketSvc.createTicket(tenantId, body, requesterId, body.requesterType || 'Employee'); } @Get('tickets/:id') @ApiOperation({ summary: 'Retrieve specific ticket details' }) async getTicket(@Req() req: any, @Param('id') id: string) { const tenantId = req.user?.tenantId || 'SYSTEM'; return this.ticketSvc.getTicketById(tenantId, id, false); } @Post('tickets/:id/comments') @ApiOperation({ summary: 'Add message reply or internal note to ticket thread' }) async addComment(@Req() req: any, @Param('id') id: string, @Body() body: any) { const tenantId = req.user?.tenantId || 'SYSTEM'; const authorId = req.user?.employeeId || req.user?.sub || 'SYSTEM'; const authorName = req.user?.name || 'Agent'; return this.ticketSvc.addComment( tenantId, id, authorId, authorName, body.authorType || 'Agent', body.content, body.isInternalNote || false ); } @Post('tickets/:id/merge') @ApiOperation({ summary: 'Merge source ticket into target ticket' }) async mergeTickets(@Req() req: any, @Param('id') id: string, @Body() body: { targetTicketId: string }) { const tenantId = req.user?.tenantId || 'SYSTEM'; const userId = req.user?.employeeId || req.user?.sub || 'SYSTEM'; return this.ticketSvc.mergeTickets(tenantId, id, body.targetTicketId, userId); } @Post('tickets/:id/split') @ApiOperation({ summary: 'Split ticket into new child ticket' }) async splitTicket(@Req() req: any, @Param('id') id: string, @Body() body: { subject: string; description: string }) { const tenantId = req.user?.tenantId || 'SYSTEM'; const userId = req.user?.employeeId || req.user?.sub || 'SYSTEM'; return this.ticketSvc.splitTicket(tenantId, id, body.subject, body.description, userId); } @Put('tickets/:id/resolve') @ApiOperation({ summary: 'Mark ticket as resolved with comments' }) async resolveTicket(@Req() req: any, @Param('id') id: string, @Body() body: { resolutionText: string }) { const tenantId = req.user?.tenantId || 'SYSTEM'; return this.ticketSvc.resolveTicket(tenantId, id, body.resolutionText); } @Post('sla/policies') @ApiOperation({ summary: 'Create new SLA Priority target policy' }) async createSlaPolicy(@Req() req: any, @Body() body: any) { const tenantId = req.user?.tenantId || 'SYSTEM'; return this.slaSvc.createPolicy(tenantId, body); } @Post('sla/evaluate') @ApiOperation({ summary: 'Trigger SLA target warning and breach evaluations' }) async evaluateSlas(@Req() req: any) { const tenantId = req.user?.tenantId || 'SYSTEM'; return this.slaSvc.checkBreaches(tenantId); } } |