merge Axel

This commit is contained in:
2026-05-28 14:02:16 -05:00
parent a1028b1cd8
commit 4db486a8c6
2 changed files with 54 additions and 54 deletions
+17 -17
View File
@@ -20,7 +20,7 @@ export class PeriodoController {
@UseGuards(JwtAuthGuard, RolesGuard)
@Roles(Role.ADMINISTRADOR, Role.SUPER_ADMINISTRADOR)
@Post()
create(@Body() data: CreatePeriodoDto) {
create(@Body() data: CreatePeriodoDto) {
return this.periodoService.create(data);
}
@@ -39,21 +39,21 @@ export class PeriodoController {
}
@UseGuards(JwtAuthGuard, RolesGuard)
@Roles(Role.ADMINISTRADOR, Role.SUPER_ADMINISTRADOR)
@Get('compare')
compare(
@Query('p1') p1: number,
@Query('p2') p2: number,
) {
return this.periodoService.comparePeriodos(p1, p2);
}
@Roles(Role.ADMINISTRADOR, Role.SUPER_ADMINISTRADOR)
@Get('compare')
compare(
@Query('p1') p1: number,
@Query('p2') p2: number,
) {
return this.periodoService.comparePeriodos(p1, p2);
}
@Get('range')
getRange(
@Query('p1') p1: number,
@Query('p2') p2: number,
) {
return this.periodoService.getPeriodosEnRango(p1, p2);
}
@Get('range')
getRange(
@Query('p1') p1: number,
@Query('p2') p2: number,
) {
return this.periodoService.getPeriodosEnRango(p1, p2);
}
}
+37 -37
View File
@@ -16,7 +16,7 @@ export class PeriodoService {
}
async findAll() {
return this.periodoRepository.find({order:{'id_periodo':"DESC"}});
return this.periodoRepository.find({ order: { 'id_periodo': "DESC" } });
}
async getPeriodoActivo(): Promise<Periodo> {
@@ -71,48 +71,48 @@ export class PeriodoService {
}
async comparePeriodos(id1: number, id2: number) {
const periodo1 = await this.periodoRepository.findOne({
where: { id_periodo: id1 },
});
const periodo1 = await this.periodoRepository.findOne({
where: { id_periodo: id1 },
});
const periodo2 = await this.periodoRepository.findOne({
where: { id_periodo: id2 },
});
const periodo2 = await this.periodoRepository.findOne({
where: { id_periodo: id2 },
});
if (!periodo1 || !periodo2) {
throw new NotFoundException('Uno de los periodos no existe');
if (!periodo1 || !periodo2) {
throw new NotFoundException('Uno de los periodos no existe');
}
return {
periodo1: {
id: periodo1.id_periodo,
nombre: periodo1.semestre,
fecha_inicio: periodo1.fecha_inicio_servicio,
fecha_fin: periodo1.fecha_fin_servicio,
},
periodo2: {
id: periodo2.id_periodo,
nombre: periodo2.semestre,
fecha_inicio: periodo2.fecha_inicio_servicio,
fecha_fin: periodo2.fecha_fin_servicio,
},
};
}
return {
periodo1: {
id: periodo1.id_periodo,
nombre: periodo1.semestre,
fecha_inicio: periodo1.fecha_inicio_servicio,
fecha_fin: periodo1.fecha_fin_servicio,
},
periodo2: {
id: periodo2.id_periodo,
nombre: periodo2.semestre,
fecha_inicio: periodo2.fecha_inicio_servicio,
fecha_fin: periodo2.fecha_fin_servicio,
},
};
}
async getPeriodosEnRango(id1: number, id2: number) {
const min = Math.min(id1, id2);
const max = Math.max(id1, id2);
async getPeriodosEnRango(id1: number, id2: number) {
const min = Math.min(id1, id2);
const max = Math.max(id1, id2);
return this.periodoRepository.find({
where: {
id_periodo: Between(min, max),
},
order: {
id_periodo: 'ASC',
},
});
}
return this.periodoRepository.find({
where: {
id_periodo: Between(min, max),
},
order: {
id_periodo: 'ASC',
},
});
}
}