parent
3e676226b1
commit
dc5d700a45
|
@ -1,4 +1,13 @@
|
|||
import { Body, Controller, Get, Param, Post, Res } from '@nestjs/common';
|
||||
import {
|
||||
Body,
|
||||
Controller,
|
||||
ForbiddenException,
|
||||
Get,
|
||||
Param,
|
||||
Post,
|
||||
Res,
|
||||
UnprocessableEntityException,
|
||||
} from '@nestjs/common';
|
||||
import { Response } from 'express';
|
||||
import { ApiTags } from '@nestjs/swagger';
|
||||
import { Public } from 'src/core/guards';
|
||||
|
@ -59,13 +68,12 @@ export class GateController {
|
|||
res.status(200);
|
||||
return gateResponses[0];
|
||||
}
|
||||
|
||||
if (failedGates.includes(data.uuid)) {
|
||||
res.status(403);
|
||||
return gateResponses[2];
|
||||
throw new ForbiddenException(gateResponses[2]);
|
||||
}
|
||||
|
||||
const response = Math.floor(Math.random() * 3);
|
||||
const responseValue = gateResponses[response];
|
||||
const responseValue = gateResponses[0];
|
||||
|
||||
res.status(responseValue.statusCode);
|
||||
return responseValue;
|
||||
|
|
|
@ -29,6 +29,7 @@ import { Response } from 'express';
|
|||
import { QueueTimeFormula } from '../../domain/usecases/formula/queue-time.formula';
|
||||
|
||||
import * as moment from 'moment';
|
||||
import { validate as isValidUUID } from 'uuid';
|
||||
|
||||
@ApiTags(`Queue`)
|
||||
@Controller(`v1/${MODULE_NAME.QUEUE}`)
|
||||
|
@ -69,7 +70,8 @@ export class QueueController {
|
|||
|
||||
@Post('print-ticket/:id')
|
||||
async printTicket(@Param('id') id: string): Promise<QueueTicketModel[]> {
|
||||
if (!id) throw new UnprocessableEntityException('Order id is required');
|
||||
if (!isValidUUID(id))
|
||||
throw new UnprocessableEntityException('Order id must be ticket uuid');
|
||||
return await this.orchestrator.printTicket(id);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue