From c742fa114d9c18180d3e617914aa30b346150ed3 Mon Sep 17 00:00:00 2001 From: Emilio Date: Tue, 9 Sep 2025 11:01:57 -0600 Subject: [PATCH] Se agregaron cambios en la parte de carrera --- src/excel/excel.controller.ts | 14 ++++++++------ src/movimiento/movimiento.service.ts | 29 +++++++++++++++++++++++++++- src/usuarios/usuarios.service.ts | 6 ++++++ 3 files changed, 42 insertions(+), 7 deletions(-) diff --git a/src/excel/excel.controller.ts b/src/excel/excel.controller.ts index 52c937c..e3c510e 100644 --- a/src/excel/excel.controller.ts +++ b/src/excel/excel.controller.ts @@ -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( diff --git a/src/movimiento/movimiento.service.ts b/src/movimiento/movimiento.service.ts index 337632c..7211e31 100644 --- a/src/movimiento/movimiento.service.ts +++ b/src/movimiento/movimiento.service.ts @@ -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', diff --git a/src/usuarios/usuarios.service.ts b/src/usuarios/usuarios.service.ts index a81e786..f360626 100644 --- a/src/usuarios/usuarios.service.ts +++ b/src/usuarios/usuarios.service.ts @@ -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',