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