qr genereta
This commit is contained in:
+43
-22
@@ -1,36 +1,57 @@
|
||||
import { Body, Controller, Delete, Get, Param, ParseIntPipe, Patch, Post } from '@nestjs/common';
|
||||
import {
|
||||
Body,
|
||||
Controller,
|
||||
Delete,
|
||||
Get,
|
||||
Param,
|
||||
ParseIntPipe,
|
||||
Patch,
|
||||
Post,
|
||||
Query,
|
||||
} from '@nestjs/common';
|
||||
import { QrService } from './qr.service';
|
||||
import { Qr } from './qr.entity';
|
||||
import { CreateQrDto } from './dto/create-qr.dto';
|
||||
import { UpdateQrDto } from './dto/update.qr.dto';
|
||||
import { ApiOperation, ApiQuery } from '@nestjs/swagger';
|
||||
|
||||
@Controller('qr')
|
||||
export class QrController {
|
||||
constructor(private qrService: QrService) {}
|
||||
|
||||
constructor(private qrService: QrService) {}
|
||||
@Get('generate')
|
||||
@ApiOperation({ summary: 'Genera un código QR a partir de un texto' })
|
||||
@ApiQuery({
|
||||
name: 'text',
|
||||
required: true,
|
||||
description: 'Texto a codificar en el QR',
|
||||
})
|
||||
async generateQRCode(@Query('text') text: string): Promise<string> {
|
||||
return this.qrService.generateQRCode(text);
|
||||
}
|
||||
|
||||
@Get()
|
||||
getQrs(): Promise<Qr[]> {
|
||||
return this.qrService.getQrs();
|
||||
}
|
||||
@Get()
|
||||
getQrs(): Promise<Qr[]> {
|
||||
return this.qrService.getQrs();
|
||||
}
|
||||
|
||||
@Get(':id')
|
||||
getQr(@Param('id', ParseIntPipe) id: number) {
|
||||
return this.qrService.getQr(id);
|
||||
}
|
||||
@Get(':id')
|
||||
getQr(@Param('id', ParseIntPipe) id: number) {
|
||||
return this.qrService.getQr(id);
|
||||
}
|
||||
|
||||
@Post() //en el body ValidationPipe
|
||||
createQr(@Body() newQr: CreateQrDto) {
|
||||
return this.qrService.createQr(newQr)
|
||||
}
|
||||
@Post() //en el body ValidationPipe
|
||||
createQr(@Body() newQr: CreateQrDto) {
|
||||
return this.qrService.createQr(newQr);
|
||||
}
|
||||
|
||||
@Delete(':id')
|
||||
deleteQr(@Param('id', ParseIntPipe) id:number) {
|
||||
return this.qrService.deleteQr(id);
|
||||
}
|
||||
@Delete(':id')
|
||||
deleteQr(@Param('id', ParseIntPipe) id: number) {
|
||||
return this.qrService.deleteQr(id);
|
||||
}
|
||||
|
||||
@Patch(':id')
|
||||
updateQr(@Param('id', ParseIntPipe) id: number, @Body() qr: UpdateQrDto) {
|
||||
return this.qrService.updateQr(id, qr)
|
||||
}
|
||||
@Patch(':id')
|
||||
updateQr(@Param('id', ParseIntPipe) id: number, @Body() qr: UpdateQrDto) {
|
||||
return this.qrService.updateQr(id, qr);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user