2026-05-25 14:32:20 -03:00
|
|
|
import { Body, Controller, Get, Post, Query } from '@nestjs/common';
|
2026-05-28 13:37:53 -03:00
|
|
|
import { ApiBody, ApiOperation, ApiQuery, ApiTags } from '@nestjs/swagger';
|
2026-05-25 14:32:20 -03:00
|
|
|
import { AgentPresenceService } from './agent-presence.service';
|
|
|
|
|
|
2026-05-28 13:37:53 -03:00
|
|
|
@ApiTags('Presenca do agente')
|
2026-05-25 14:32:20 -03:00
|
|
|
@Controller('agent/presence')
|
|
|
|
|
export class AgentPresenceController {
|
|
|
|
|
constructor(private readonly agentPresenceService: AgentPresenceService) {}
|
|
|
|
|
|
2026-05-28 13:37:53 -03:00
|
|
|
@ApiOperation({
|
|
|
|
|
summary: 'Lista presenca dos agentes',
|
|
|
|
|
description: 'Retorna o estado atual dos agentes para acompanhamento operacional, incluindo disponibilidade e pausas.',
|
|
|
|
|
})
|
2026-05-25 14:32:20 -03:00
|
|
|
@Get()
|
|
|
|
|
listPresence() {
|
|
|
|
|
return this.agentPresenceService.listPresence();
|
|
|
|
|
}
|
|
|
|
|
|
2026-05-28 13:37:53 -03:00
|
|
|
@ApiOperation({
|
|
|
|
|
summary: 'Consulta presenca do agente logado',
|
|
|
|
|
description: 'Retorna o status de presenca de um usuario especifico.',
|
|
|
|
|
})
|
|
|
|
|
@ApiQuery({ name: 'userId', required: true, description: 'ID do usuario.' })
|
2026-05-25 14:32:20 -03:00
|
|
|
@Get('me')
|
|
|
|
|
getPresence(@Query('userId') userId: string) {
|
|
|
|
|
return this.agentPresenceService.getPresence(Number(userId));
|
|
|
|
|
}
|
|
|
|
|
|
2026-05-28 13:37:53 -03:00
|
|
|
@ApiOperation({
|
|
|
|
|
summary: 'Coloca agente em pausa',
|
|
|
|
|
description: 'Marca o agente como pausado para que ele nao receba novos atendimentos enquanto estiver indisponivel.',
|
|
|
|
|
})
|
|
|
|
|
@ApiBody({ schema: { type: 'object', required: ['userId'], properties: { userId: { type: 'number', example: 10 } } } })
|
2026-05-25 14:32:20 -03:00
|
|
|
@Post('pause')
|
|
|
|
|
pause(@Body() body: { userId: number }) {
|
|
|
|
|
return this.agentPresenceService.pause(Number(body.userId));
|
|
|
|
|
}
|
|
|
|
|
|
2026-05-28 13:37:53 -03:00
|
|
|
@ApiOperation({
|
|
|
|
|
summary: 'Retoma disponibilidade do agente',
|
|
|
|
|
description: 'Remove a pausa do agente e marca o usuario como disponivel novamente.',
|
|
|
|
|
})
|
|
|
|
|
@ApiBody({ schema: { type: 'object', required: ['userId'], properties: { userId: { type: 'number', example: 10 } } } })
|
2026-05-25 14:32:20 -03:00
|
|
|
@Post('resume')
|
|
|
|
|
resume(@Body() body: { userId: number }) {
|
|
|
|
|
return this.agentPresenceService.resume(Number(body.userId));
|
|
|
|
|
}
|
|
|
|
|
|
2026-05-28 13:37:53 -03:00
|
|
|
@ApiOperation({
|
|
|
|
|
summary: 'Marca agente como offline',
|
|
|
|
|
description: 'Atualiza a presenca do agente para offline, usado em saida do painel ou encerramento de expediente.',
|
|
|
|
|
})
|
|
|
|
|
@ApiBody({ schema: { type: 'object', required: ['userId'], properties: { userId: { type: 'number', example: 10 } } } })
|
2026-05-25 14:32:20 -03:00
|
|
|
@Post('offline')
|
|
|
|
|
offline(@Body() body: { userId: number }) {
|
|
|
|
|
return this.agentPresenceService.offline(Number(body.userId));
|
|
|
|
|
}
|
|
|
|
|
}
|