qr
This commit is contained in:
@@ -21,9 +21,7 @@ import { diskStorage } from 'multer';
|
|||||||
import { extname } from 'path';
|
import { extname } from 'path';
|
||||||
import { CuestionarioApiDocumentation } from './docs/cuestionario.documentation';
|
import { CuestionarioApiDocumentation } from './docs/cuestionario.documentation';
|
||||||
import { CreateEventoWithCuestionarioDto } from './dto/create-evento-cuestionario.dto';
|
import { CreateEventoWithCuestionarioDto } from './dto/create-evento-cuestionario.dto';
|
||||||
import * as ExcelJS from 'exceljs';
|
|
||||||
import { TipoPreguntaEnum } from 'src/tipo_pregunta/entities/tipo_pregunta.entity';
|
|
||||||
import { TiposValidacion } from 'src/pregunta/entities/pregunta.entity';
|
|
||||||
|
|
||||||
@Controller('cuestionario')
|
@Controller('cuestionario')
|
||||||
@CuestionarioApiDocumentation.ApiController
|
@CuestionarioApiDocumentation.ApiController
|
||||||
@@ -70,7 +68,7 @@ export class CuestionarioController {
|
|||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Post('carga-masiva')
|
@Post('carga-masiva')
|
||||||
@UseInterceptors(FileInterceptor('file'))
|
@UseInterceptors(FileInterceptor('file'))
|
||||||
async cargaMasiva(@UploadedFile() file: Express.Multer.File) {
|
async cargaMasiva(@UploadedFile() file: Express.Multer.File) {
|
||||||
if (!file) {
|
if (!file) {
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import { InjectRepository } from '@nestjs/typeorm';
|
|||||||
import { Repository } from 'typeorm';
|
import { Repository } from 'typeorm';
|
||||||
import { Asistencia } from 'src/asistencia/entities/asistencia.entity';
|
import { Asistencia } from 'src/asistencia/entities/asistencia.entity';
|
||||||
import { Cuestionario } from 'src/cuestionario/entities/cuestionario.entity';
|
import { Cuestionario } from 'src/cuestionario/entities/cuestionario.entity';
|
||||||
|
import { Evento } from 'src/evento/entities/evento.entity';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class QrTokenService {
|
export class QrTokenService {
|
||||||
@@ -15,6 +16,8 @@ export class QrTokenService {
|
|||||||
private readonly asistenciaRepository: Repository<Asistencia>,
|
private readonly asistenciaRepository: Repository<Asistencia>,
|
||||||
@InjectRepository(Cuestionario)
|
@InjectRepository(Cuestionario)
|
||||||
private readonly cuestionarioRepository: Repository<Cuestionario>,
|
private readonly cuestionarioRepository: Repository<Cuestionario>,
|
||||||
|
@InjectRepository(Evento)
|
||||||
|
private readonly eventoREpo: Repository<Evento>,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -44,14 +47,17 @@ export class QrTokenService {
|
|||||||
|
|
||||||
const fecha_fin = await this.cuestionarioRepository.findOne({
|
const fecha_fin = await this.cuestionarioRepository.findOne({
|
||||||
where: { id_cuestionario },
|
where: { id_cuestionario },
|
||||||
select: ['fecha_fin'],
|
});
|
||||||
|
const fecha_fin2 = await this.eventoREpo.findOne({
|
||||||
|
where: { id_evento },
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!fecha_fin) {
|
if (!fecha_fin2) {
|
||||||
throw new UnauthorizedException('Cuestionario no encontrado');
|
throw new UnauthorizedException('Cuestionario no encontrado');
|
||||||
}
|
}
|
||||||
// Convert fecha_fin to seconds from now for expiresIn
|
// Convert fecha_fin to seconds from now for expiresIn
|
||||||
const expiresInSeconds = Math.floor((fecha_fin?.fecha_fin.getTime() - Date.now()) / 1000);
|
const expiresInSeconds = Math.floor((fecha_fin2?.fecha_fin.getTime() - Date.now()) / 1000);
|
||||||
|
|
||||||
return this.jwtService.sign(payload, {
|
return this.jwtService.sign(payload, {
|
||||||
secret,
|
secret,
|
||||||
|
|||||||
Reference in New Issue
Block a user