added periodo
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
import {
|
||||
IsString,
|
||||
Length,
|
||||
IsDateString,
|
||||
IsOptional,
|
||||
IsBoolean,
|
||||
} from 'class-validator';
|
||||
|
||||
export class CreatePeriodoDto {
|
||||
@IsString()
|
||||
@Length(6, 6)
|
||||
semestre: string;
|
||||
|
||||
@IsDateString()
|
||||
fecha_inicio_servicio: string;
|
||||
|
||||
@IsDateString()
|
||||
fecha_fin_servicio: string;
|
||||
|
||||
@IsOptional()
|
||||
@IsBoolean()
|
||||
activo?: boolean;
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
import { Controller, Get, Param } from '@nestjs/common';
|
||||
import { PeriodoService } from './periodo.service';
|
||||
|
||||
@Controller('periodo')
|
||||
export class PeriodoController {}
|
||||
@@ -0,0 +1,10 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { PeriodoService } from './periodo.service';
|
||||
import { PeriodoController } from './periodo.controller';
|
||||
|
||||
@Module({
|
||||
controllers: [PeriodoController],
|
||||
providers: [PeriodoService],
|
||||
exports: [PeriodoService],
|
||||
})
|
||||
export class PeriodoModule {}
|
||||
@@ -0,0 +1,35 @@
|
||||
import { Injectable, NotFoundException } from '@nestjs/common';
|
||||
import { InjectRepository } from '@nestjs/typeorm';
|
||||
import { Periodo } from 'src/database/AT/entities/periodo.entity';
|
||||
import { Repository } from 'typeorm';
|
||||
|
||||
@Injectable()
|
||||
export class PeriodoService {
|
||||
constructor(
|
||||
@InjectRepository(Periodo)
|
||||
private readonly periodoRepository: Repository<Periodo>,
|
||||
) {}
|
||||
|
||||
async getById(id_periodo: number): Promise<Periodo> {
|
||||
const periodo = await this.periodoRepository.findOne({
|
||||
where: { id_periodo },
|
||||
});
|
||||
|
||||
if (!periodo) {
|
||||
throw new NotFoundException('periodo no encontrado');
|
||||
}
|
||||
return periodo;
|
||||
}
|
||||
|
||||
async getLatestPeriodo(): Promise<Periodo> {
|
||||
const periodo = await this.periodoRepository.findOne({
|
||||
order: { id_periodo: 'DESC' },
|
||||
});
|
||||
|
||||
if (!periodo) {
|
||||
throw new NotFoundException('No hay periodos registrados');
|
||||
}
|
||||
|
||||
return periodo;
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,4 @@
|
||||
import {
|
||||
Injectable,
|
||||
ExecutionContext,
|
||||
UnauthorizedException,
|
||||
} from '@nestjs/common';
|
||||
import { Injectable, ExecutionContext } from '@nestjs/common';
|
||||
import { AuthGuard } from '@nestjs/passport';
|
||||
|
||||
@Injectable()
|
||||
@@ -12,7 +8,7 @@ export class GoogleAuthGuard extends AuthGuard('google') {
|
||||
|
||||
if (err || !user) {
|
||||
return res.redirect(
|
||||
`${process.env.FRONTEND_URL}/oauth-callback?error=${info.message || info}`,
|
||||
`${process.env.FRONTEND_URL}/oauth-callback?error=cancelado`,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user