Se agregaron cambios en la parte de carrera

This commit is contained in:
2025-09-09 11:01:57 -06:00
parent 6e12e580e1
commit c742fa114d
3 changed files with 42 additions and 7 deletions
+8 -6
View File
@@ -1,5 +1,5 @@
// src/excel/excel.controller.ts
import { Controller, Post, Get, UseGuards, Request, Res, UploadedFile, UseInterceptors, HttpStatus, Param, ParseIntPipe, Body, BadRequestException, Delete } from '@nestjs/common';
import { Controller, Post, Get, UseGuards, Request, Res, UploadedFile, UseInterceptors, HttpStatus, Param, ParseIntPipe, Body, BadRequestException, Delete, Query } from '@nestjs/common';
import { AuthGuard } from '@nestjs/passport';
import { ApiBearerAuth } from '@nestjs/swagger';
import { FileInterceptor } from '@nestjs/platform-express';
@@ -316,11 +316,13 @@ export class ExcelController {
//Agregarlo en su propio controller
@Get('movimientos')
async getMovimientos(@Request() req) {
const movimientos = await this.movimientoService.findAll(req.user.origen);
return movimientos;
}
async getMovimientos(
@Query('origen') origen: string,
@Query('page') page: number,
@Query('limit') limit: number,
) {
return this.movimientoService.findAll(origen, page, limit);
}
@Post('activar-servicios/:id_movimiento')
async activarServicios(
+28 -1
View File
@@ -94,7 +94,34 @@ export class MovimientoService {
await this.movRepo.save(movimiento);
}
async findAll(origen: string): Promise<{ move: any[]; button: boolean }> {
async findAll(
origen: string,
page: number = 1,
limit: number = 10,
): Promise<{ move: any[]; button: boolean; total?: number; lastPage?: number }> {
if (origen === 'LOAD') {
const [movimientos, total] = await this.movRepo.findAndCount({
where: {
origen: { origen: 'LOAD' },
status: 'SUCCESS',
reporte: 'CARGA MASIVA DE USUARIOS',
},
skip: (page - 1) * limit,
take: limit,
order: { fecha_mov: 'DESC' }, // opcional
});
// si quieres incluir también mov y mov2 en la misma paginación:
// const todosLosMovimientos = [...movimientos, ...mov, ...mov2]; (y luego slice)
return {
move: movimientos,
button: false,
total,
lastPage: Math.ceil(total / limit),
};
}
const statusFieldMap = {
AT: 'ATStatus',
RED: 'RedStatus',
+6
View File
@@ -491,6 +491,11 @@ export class UsuariosService {
let carrera;
if(usuario.carrera!=undefined){
carrera = await queryRunner.manager.findOne(Carrera, { where: { carrera: usuario.carrera } });
if (!carrera) {
carrera= await queryRunner.manager.findOne(Carrera, {where:{carrera: ""}})
}
console.log(carrera)
}else{
carrera= await queryRunner.manager.findOne(Carrera, {where:{carrera: ""}})
if(!carrera){
@@ -521,6 +526,7 @@ export class UsuariosService {
const savedUser = await queryRunner.manager.save(nuevo);
const userCarrera = queryRunner.manager.create(CarreraUsuario, { carrera, usuario: savedUser });
await queryRunner.manager.save(userCarrera);
const FieldMap = [
'Diplomado', 'Extra Largo', 'Servicio Social', 'Idiomas R (UNAM)', 'Idiomas Sabatino',