diff --git a/src/usuario/usuario.controller.ts b/src/usuario/usuario.controller.ts index f1e7923..61d93a7 100644 --- a/src/usuario/usuario.controller.ts +++ b/src/usuario/usuario.controller.ts @@ -22,15 +22,40 @@ import { UsuarioDto } from './dto/usuario.dto'; export class UsuarioController { constructor(private usuarioService: UsuarioService) {} - /* Pendiente por conexión */ - // @Get('dgae') - // dgae(@Query() query: UsuarioDgaeDto) { - // return this.usuarioService.dgaeDgp(query.usuario); - // } - // @Get('dgp') - // dgp(@Query() query: UsuarioDgpDto) { - // return this.usuarioService.dgaeDgp(query.usuario); - // } + @Get('dgae') + @ApiOperation({ + description: 'Endpoint que retorna información de dgae de un alumno.', + }) + @ApiQuery({ + description: 'Número de cuenta del alumno.', + name: 'usuario', + type: 'string', + }) + @ApiQuery({ + description: 'Id de la carrera institución a la que pertenece el alumno.', + name: 'id_institucion_carrera', + type: 'string', + }) + dgae(@Query() query: UsuarioDgaeDto) { + return this.usuarioService.DGAE( + query.usuario, + parseInt(query.id_institucion_carrera), + ); + } + + @Get('dgp') + @ApiOperation({ + description: 'Endpoint que retorna información de dgp de un profesor.', + }) + @ApiQuery({ + description: 'Número de cuenta del profesor.', + name: 'usuario', + type: 'string', + }) + @ApiQuery({ description: 'RFC del profesor.', name: 'rfc', type: 'string' }) + dgp(@Query() query: UsuarioDgpDto) { + return this.usuarioService.DGP(query.usuario, query.rfc); + } @Post('registrar') @ApiOperation({ diff --git a/src/usuario/usuario.service.ts b/src/usuario/usuario.service.ts index 08a2eb5..86089eb 100644 --- a/src/usuario/usuario.service.ts +++ b/src/usuario/usuario.service.ts @@ -75,31 +75,22 @@ export class UsuarioService {

Pc Puma Solicita

`; } - dgaeDgp(usuario: string) { - // return this.findByUsuario(usuario).then(async (existeUsuario) => { - // if (!existeUsuario) { - // let esAlumno = false; + DGAE(usuario: string, id_institucion_carrera: number) { + return this.findByUsuario(usuario).then(async (existeUsuario) => { + /* Falta conexión a soap */ + if (existeUsuario.password) + throw new ConflictException('Ya fue regisrado este usuario.'); + return existeUsuario; + }); + } - // await this.soapClientService - // .dgp(usuario) - // .then((res) => { - // if (!res) return this.soapClientService.dgp(usuario); - // esAlumno = true; - // return res; - // }) - // .then((res) => { - // if (!res) - // throw new ConflictException('No es un número de cuenta válido.'); - - // // const data = {usuario,id_institucion:200,}; - // // return this.create(usuario,, 5); - // }); - // } - // if (existeUsuario.password) - // throw new ConflictException('Ya fue regisrado este usuario.'); - // return existeUsuario; - // }); - return { message: 'Pendiente' }; + DGP(usuario: string, rfc: string) { + return this.findByUsuario(usuario).then(async (existeUsuario) => { + /* Falta conexión a soap */ + if (existeUsuario.password) + throw new ConflictException('Ya fue regisrado este usuario.'); + return existeUsuario; + }); } async findAll(filtros: {