merge error saavedra dev
This commit is contained in:
commit
10bd6aaaa5
39
catalogos.sql
Normal file
39
catalogos.sql
Normal file
@ -0,0 +1,39 @@
|
||||
INSERT INTO institucion (institucion, logo) VALUES ("FES Acatlán", "url");
|
||||
INSERT INTO institucion (institucion, logo) VALUES ("Facultad de Arquitectura", "url");
|
||||
|
||||
INSERT INTO carrera (carrera, id_institucion) VALUES ("Matemáticas Aplicadas y Computación", 1);
|
||||
INSERT INTO carrera (carrera, id_institucion) VALUES ("Arquitectura", 2);
|
||||
|
||||
INSERT INTO status (status) VALUES ("Activo");
|
||||
INSERT INTO status (status) VALUES ("Apartado");
|
||||
INSERT INTO status (status) VALUES ("En uso");
|
||||
INSERT INTO status (status) VALUES ("Desactivado");
|
||||
INSERT INTO status (status) VALUES ("Cargando");
|
||||
INSERT INTO status (status) VALUES ("Revisar");
|
||||
INSERT INTO status (status) VALUES ("Reparación");
|
||||
INSERT INTO status (status) VALUES ("Mantenimiento");
|
||||
|
||||
INSERT INTO tipo_usuario (tipo_usuario) VALUES ("Sistema");
|
||||
INSERT INTO tipo_usuario (tipo_usuario) VALUES ("Super Admin");
|
||||
INSERT INTO tipo_usuario (tipo_usuario) VALUES ("Admin");
|
||||
INSERT INTO tipo_usuario (tipo_usuario) VALUES ("Operador");
|
||||
INSERT INTO tipo_usuario (tipo_usuario) VALUES ("Profesor");
|
||||
INSERT INTO tipo_usuario (tipo_usuario) VALUES ("Alumno");
|
||||
INSERT INTO tipo_usuario (tipo_usuario) VALUES ("Posgrado");
|
||||
|
||||
INSERT INTO dia (dia) VALUES ("Lunes");
|
||||
INSERT INTO dia (dia) VALUES ("Martes");
|
||||
INSERT INTO dia (dia) VALUES ("Miercoles");
|
||||
INSERT INTO dia (dia) VALUES ("Jueves");
|
||||
INSERT INTO dia (dia) VALUES ("Viernes");
|
||||
|
||||
INSERT INTO institucion_dia (id_institucion, id_dia) VALUES (1, 1);
|
||||
INSERT INTO institucion_dia (id_institucion, id_dia) VALUES (1, 2);
|
||||
INSERT INTO institucion_dia (id_institucion, id_dia) VALUES (1, 3);
|
||||
INSERT INTO institucion_dia (id_institucion, id_dia) VALUES (1, 4);
|
||||
INSERT INTO institucion_dia (id_institucion, id_dia) VALUES (1, 5);
|
||||
INSERT INTO institucion_dia (id_institucion, id_dia) VALUES (2, 1);
|
||||
INSERT INTO institucion_dia (id_institucion, id_dia) VALUES (2, 2);
|
||||
INSERT INTO institucion_dia (id_institucion, id_dia) VALUES (2, 3);
|
||||
INSERT INTO institucion_dia (id_institucion, id_dia) VALUES (2, 4);
|
||||
INSERT INTO institucion_dia (id_institucion, id_dia) VALUES (2, 5);
|
94
package-lock.json
generated
94
package-lock.json
generated
@ -16,6 +16,7 @@
|
||||
"@nestjs/passport": "^8.2.1",
|
||||
"@nestjs/platform-express": "^8.0.0",
|
||||
"@nestjs/schedule": "^1.1.0",
|
||||
"@nestjs/swagger": "^5.2.1",
|
||||
"@nestjs/typeorm": "^8.0.3",
|
||||
"bcrypt": "^5.0.1",
|
||||
"class-transformer": "^0.5.1",
|
||||
@ -29,6 +30,7 @@
|
||||
"reflect-metadata": "^0.1.13",
|
||||
"rimraf": "^3.0.2",
|
||||
"rxjs": "^7.2.0",
|
||||
"swagger-ui-express": "^4.3.0",
|
||||
"typeorm": "^0.2.45"
|
||||
},
|
||||
"devDependencies": {
|
||||
@ -1511,6 +1513,25 @@
|
||||
"@nestjs/common": "^6.0.0 || ^7.0.0 || ^8.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@nestjs/mapped-types": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/@nestjs/mapped-types/-/mapped-types-1.0.1.tgz",
|
||||
"integrity": "sha512-NFvofzSinp00j5rzUd4tf+xi9od6383iY0JP7o0Bnu1fuItAUkWBgc4EKuIQ3D+c2QI3i9pG1kDWAeY27EMGtg==",
|
||||
"peerDependencies": {
|
||||
"@nestjs/common": "^7.0.8 || ^8.0.0",
|
||||
"class-transformer": "^0.2.0 || ^0.3.0 || ^0.4.0 || ^0.5.0",
|
||||
"class-validator": "^0.11.1 || ^0.12.0 || ^0.13.0",
|
||||
"reflect-metadata": "^0.1.12"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"class-transformer": {
|
||||
"optional": true
|
||||
},
|
||||
"class-validator": {
|
||||
"optional": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/@nestjs/passport": {
|
||||
"version": "8.2.1",
|
||||
"resolved": "https://registry.npmjs.org/@nestjs/passport/-/passport-8.2.1.tgz",
|
||||
@ -1633,6 +1654,31 @@
|
||||
"integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/@nestjs/swagger": {
|
||||
"version": "5.2.1",
|
||||
"resolved": "https://registry.npmjs.org/@nestjs/swagger/-/swagger-5.2.1.tgz",
|
||||
"integrity": "sha512-7dNa08WCnTsW/oAk3Ujde+z64JMfNm19DhpXasFR8oJp/9pggYAbYU927HpA+GJsSFJX6adjIRZsCKUqaGWznw==",
|
||||
"dependencies": {
|
||||
"@nestjs/mapped-types": "1.0.1",
|
||||
"lodash": "4.17.21",
|
||||
"path-to-regexp": "3.2.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@nestjs/common": "^8.0.0",
|
||||
"@nestjs/core": "^8.0.0",
|
||||
"fastify-swagger": "*",
|
||||
"reflect-metadata": "^0.1.12",
|
||||
"swagger-ui-express": "*"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"fastify-swagger": {
|
||||
"optional": true
|
||||
},
|
||||
"swagger-ui-express": {
|
||||
"optional": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/@nestjs/testing": {
|
||||
"version": "8.4.3",
|
||||
"resolved": "https://registry.npmjs.org/@nestjs/testing/-/testing-8.4.3.tgz",
|
||||
@ -8493,6 +8539,25 @@
|
||||
"url": "https://github.com/sponsors/ljharb"
|
||||
}
|
||||
},
|
||||
"node_modules/swagger-ui-dist": {
|
||||
"version": "4.10.3",
|
||||
"resolved": "https://registry.npmjs.org/swagger-ui-dist/-/swagger-ui-dist-4.10.3.tgz",
|
||||
"integrity": "sha512-eR4vsd7sYo0Sx7ZKRP5Z04yij7JkNmIlUQfrDQgC+xO5ABYx+waabzN+nDsQTLAJ4Z04bjkRd8xqkJtbxr3G7w=="
|
||||
},
|
||||
"node_modules/swagger-ui-express": {
|
||||
"version": "4.3.0",
|
||||
"resolved": "https://registry.npmjs.org/swagger-ui-express/-/swagger-ui-express-4.3.0.tgz",
|
||||
"integrity": "sha512-jN46SEEe9EoXa3ZgZoKgnSF6z0w3tnM1yqhO4Y+Q4iZVc8JOQB960EZpIAz6rNROrDApVDwcMHR0mhlnc/5Omw==",
|
||||
"dependencies": {
|
||||
"swagger-ui-dist": ">=4.1.3"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= v0.10.32"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"express": ">=4.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/symbol-observable": {
|
||||
"version": "4.0.0",
|
||||
"resolved": "https://registry.npmjs.org/symbol-observable/-/symbol-observable-4.0.0.tgz",
|
||||
@ -10932,6 +10997,12 @@
|
||||
"jsonwebtoken": "8.5.1"
|
||||
}
|
||||
},
|
||||
"@nestjs/mapped-types": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/@nestjs/mapped-types/-/mapped-types-1.0.1.tgz",
|
||||
"integrity": "sha512-NFvofzSinp00j5rzUd4tf+xi9od6383iY0JP7o0Bnu1fuItAUkWBgc4EKuIQ3D+c2QI3i9pG1kDWAeY27EMGtg==",
|
||||
"requires": {}
|
||||
},
|
||||
"@nestjs/passport": {
|
||||
"version": "8.2.1",
|
||||
"resolved": "https://registry.npmjs.org/@nestjs/passport/-/passport-8.2.1.tgz",
|
||||
@ -11016,6 +11087,16 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"@nestjs/swagger": {
|
||||
"version": "5.2.1",
|
||||
"resolved": "https://registry.npmjs.org/@nestjs/swagger/-/swagger-5.2.1.tgz",
|
||||
"integrity": "sha512-7dNa08WCnTsW/oAk3Ujde+z64JMfNm19DhpXasFR8oJp/9pggYAbYU927HpA+GJsSFJX6adjIRZsCKUqaGWznw==",
|
||||
"requires": {
|
||||
"@nestjs/mapped-types": "1.0.1",
|
||||
"lodash": "4.17.21",
|
||||
"path-to-regexp": "3.2.0"
|
||||
}
|
||||
},
|
||||
"@nestjs/testing": {
|
||||
"version": "8.4.3",
|
||||
"resolved": "https://registry.npmjs.org/@nestjs/testing/-/testing-8.4.3.tgz",
|
||||
@ -16286,6 +16367,19 @@
|
||||
"integrity": "sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==",
|
||||
"dev": true
|
||||
},
|
||||
"swagger-ui-dist": {
|
||||
"version": "4.10.3",
|
||||
"resolved": "https://registry.npmjs.org/swagger-ui-dist/-/swagger-ui-dist-4.10.3.tgz",
|
||||
"integrity": "sha512-eR4vsd7sYo0Sx7ZKRP5Z04yij7JkNmIlUQfrDQgC+xO5ABYx+waabzN+nDsQTLAJ4Z04bjkRd8xqkJtbxr3G7w=="
|
||||
},
|
||||
"swagger-ui-express": {
|
||||
"version": "4.3.0",
|
||||
"resolved": "https://registry.npmjs.org/swagger-ui-express/-/swagger-ui-express-4.3.0.tgz",
|
||||
"integrity": "sha512-jN46SEEe9EoXa3ZgZoKgnSF6z0w3tnM1yqhO4Y+Q4iZVc8JOQB960EZpIAz6rNROrDApVDwcMHR0mhlnc/5Omw==",
|
||||
"requires": {
|
||||
"swagger-ui-dist": ">=4.1.3"
|
||||
}
|
||||
},
|
||||
"symbol-observable": {
|
||||
"version": "4.0.0",
|
||||
"resolved": "https://registry.npmjs.org/symbol-observable/-/symbol-observable-4.0.0.tgz",
|
||||
|
@ -28,6 +28,7 @@
|
||||
"@nestjs/passport": "^8.2.1",
|
||||
"@nestjs/platform-express": "^8.0.0",
|
||||
"@nestjs/schedule": "^1.1.0",
|
||||
"@nestjs/swagger": "^5.2.1",
|
||||
"@nestjs/typeorm": "^8.0.3",
|
||||
"bcrypt": "^5.0.1",
|
||||
"class-transformer": "^0.5.1",
|
||||
@ -41,6 +42,7 @@
|
||||
"reflect-metadata": "^0.1.13",
|
||||
"rimraf": "^3.0.2",
|
||||
"rxjs": "^7.2.0",
|
||||
"swagger-ui-express": "^4.3.0",
|
||||
"typeorm": "^0.2.45"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
@ -2,8 +2,10 @@ import { Body, Controller, Post } from '@nestjs/common';
|
||||
import { AuthService } from './auth.service';
|
||||
import { AuthLoginOperadorDto } from './dto/auth-login-operador.dto';
|
||||
import { AuthLoginUsuarioDto } from './dto/auth-login-usuario.dto';
|
||||
import {ApiTags} from '@nestjs/swagger'
|
||||
|
||||
@Controller('auth')
|
||||
@ApiTags('auth')
|
||||
export class AuthController {
|
||||
constructor(private authService: AuthService) {}
|
||||
|
||||
|
@ -1,9 +1,11 @@
|
||||
import { Body, Controller, Delete, Get, Post, Put } from '@nestjs/common';
|
||||
import { Body, Controller, Delete, Get, Param, Post } from '@nestjs/common';
|
||||
import { CarreraProgramaService } from './carrera-programa.service';
|
||||
import { CarreraProgramaCreateDto } from './dto/carrera-programa-create.dto';
|
||||
import { CarreraProgramaUpdateDto } from './dto/carrera-programa-update.dto';
|
||||
import {ApiTags} from '@nestjs/swagger'
|
||||
|
||||
@Controller('carrera-programa')
|
||||
@ApiTags('carrera-programa')
|
||||
export class CarreraProgramaController {
|
||||
constructor(private carreraProgramaService: CarreraProgramaService) {}
|
||||
|
||||
@ -15,17 +17,13 @@ export class CarreraProgramaController {
|
||||
);
|
||||
}
|
||||
|
||||
// terminar delte
|
||||
@Delete()
|
||||
delete() {}
|
||||
@Delete(':id')
|
||||
delete(@Param('id') id_carrera_programa: number) {
|
||||
return this.carreraProgramaService.delete(id_carrera_programa)
|
||||
}
|
||||
|
||||
@Get()
|
||||
get() {
|
||||
return this.carreraProgramaService.findAll();
|
||||
}
|
||||
|
||||
@Put()
|
||||
update(@Body() body: CarreraProgramaUpdateDto) {
|
||||
return this.carreraProgramaService.update(body);
|
||||
}
|
||||
}
|
||||
|
@ -47,25 +47,16 @@ export class CarreraProgramaService {
|
||||
.findOne({ id_carrera_programa })
|
||||
.then((carreraPrograma) => {
|
||||
if (!carreraPrograma)
|
||||
throw new NotFoundException('No existe esta carrera programa');
|
||||
throw new NotFoundException('No existe esta carrera-programa');
|
||||
return carreraPrograma;
|
||||
});
|
||||
}
|
||||
|
||||
// Eliminar update, no tiene sentido tenerlo, me equivoque xd
|
||||
async update(attrs: Partial<CarreraPrograma>) {
|
||||
const carreraPrograma = await this.findById(attrs.id_carrera_programa);
|
||||
|
||||
return this.repository
|
||||
.findOne({ id_carrera_programa: attrs.id_carrera_programa })
|
||||
.then((existeCarreraPrograma) => {
|
||||
if (existeCarreraPrograma)
|
||||
throw new ConflictException('Ya existe esta carrera programa');
|
||||
Object.assign(carreraPrograma, attrs);
|
||||
return this.repository.save(carreraPrograma);
|
||||
})
|
||||
.then(() => ({
|
||||
message: 'Se actualizo correctamente la carrera programa',
|
||||
}));
|
||||
//No estoy seguro de que esto este bien :)
|
||||
delete(id_carrera_programa: number) {
|
||||
this.findById(id_carrera_programa)
|
||||
.then(() => {
|
||||
return this.repository.delete(id_carrera_programa)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@ -1,19 +1,20 @@
|
||||
import { Controller, Get, Query } from '@nestjs/common';
|
||||
import { CarreraService } from './carrera.service';
|
||||
import { CarritoGetDto } from './dto/carrera-get-dto';
|
||||
import {ApiTags} from '@nestjs/swagger'
|
||||
|
||||
@Controller('carrera')
|
||||
@ApiTags('carrera')
|
||||
export class CarreraController {
|
||||
constructor(private carreraService: CarreraService) {}
|
||||
|
||||
@Get()
|
||||
get() {
|
||||
// recibir id_institucion y traer todoas las carreras de esa institiucion
|
||||
return this.carreraService.findAll();
|
||||
}
|
||||
|
||||
@Get('carreras')
|
||||
carreras(@Query() query: CarritoGetDto) {
|
||||
return this.carreraService.findAllByIdInstitucion(Number(query.id_institucion));
|
||||
}
|
||||
|
||||
@Get('carrera')
|
||||
carrera(@Query() query: CarritoGetDto) {
|
||||
return this.carreraService.findById(Number(query.id_carrera));
|
||||
}
|
||||
}
|
||||
|
@ -37,4 +37,10 @@ export class CarreraService {
|
||||
return carrera;
|
||||
});
|
||||
}
|
||||
|
||||
findAllByIdInstitucion(id_institucion: number) {
|
||||
return this.institucionService
|
||||
.findById(id_institucion)
|
||||
.then((institucion) => this.repository.find({ institucion }));
|
||||
}
|
||||
}
|
||||
|
@ -4,4 +4,7 @@ export class CarritoGetDto {
|
||||
// Cambiar IsString por IsNumberString
|
||||
@IsString()
|
||||
id_carrera: string;
|
||||
|
||||
@IsString()
|
||||
id_institucion: String;
|
||||
}
|
||||
|
@ -2,9 +2,12 @@ import { Body, Controller, Get, Post, Put, Query } from '@nestjs/common';
|
||||
import { CarritoService } from './carrito.service';
|
||||
import { CarritoCreateDto } from './dto/carrito-create.dto';
|
||||
import { CarritoUpdateDto } from './dto/carrito-update.dto';
|
||||
import { CarritoGetDto } from './dto/carrtio-get-dto';
|
||||
import { CarritoGetDto } from './dto/carrito-get-dto';
|
||||
import { CarritoDto } from './dto/carrito.dto'
|
||||
import {ApiTags} from '@nestjs/swagger'
|
||||
|
||||
@Controller('carrito')
|
||||
@ApiTags('carrito')
|
||||
export class CarritoController {
|
||||
constructor(private carritoService: CarritoService) {}
|
||||
|
||||
@ -13,7 +16,6 @@ export class CarritoController {
|
||||
return this.carritoService.create(
|
||||
body.id_tipo_carrito,
|
||||
body.id_modulo,
|
||||
body.carrito,
|
||||
);
|
||||
}
|
||||
|
||||
@ -22,20 +24,14 @@ export class CarritoController {
|
||||
return this.carritoService.findAll();
|
||||
}
|
||||
|
||||
// Crear dto que solo espere el campo id_carrito
|
||||
@Get('carrito')
|
||||
carrito(@Query() query: CarritoGetDto) {
|
||||
carrito(@Query() query: CarritoDto) {
|
||||
return this.carritoService.findById(Number(query.id_carrito));
|
||||
}
|
||||
|
||||
@Get('carritos')
|
||||
carritos(@Query() query: CarritoGetDto) {
|
||||
return this.carritoService.findByIdModulo(
|
||||
Number(query.pagina),
|
||||
Number(query.id_modulo),
|
||||
Number(query.id_tipo_carrito),
|
||||
query.activo === 'true',
|
||||
);
|
||||
return this.carritoService.findByIdModulo(query);
|
||||
}
|
||||
|
||||
@Get('carritoInstitucion')
|
||||
|
@ -3,9 +3,11 @@ import {
|
||||
Injectable,
|
||||
NotFoundException,
|
||||
} from '@nestjs/common';
|
||||
import { Repository } from 'typeorm';
|
||||
import { InjectRepository } from '@nestjs/typeorm';
|
||||
import { Repository } from 'typeorm';
|
||||
import { Carrito } from './entity/carrito.entity';
|
||||
import { Modulo } from '../modulo/entity/modulo.entity';
|
||||
import { InstitucionTipoCarrito } from '../institucion-tipo-carrito/entity/institucion-tipo-carrito.entity';
|
||||
import { ModuloService } from '../modulo/modulo.service';
|
||||
import { InstitucionTipoCarritoService } from '../institucion-tipo-carrito/institucion-tipo-carrito.service';
|
||||
|
||||
@ -17,21 +19,26 @@ export class CarritoService {
|
||||
private institucionTipoCarritoService: InstitucionTipoCarritoService,
|
||||
) {}
|
||||
|
||||
// Eliminar carrito (argumento) de este proceso. Buscar cuantos carritos tiene el modulo de ese tipo carrito y automaticamente generar carrito
|
||||
async create(id_tipo_carrito: number, id_modulo: number, carrito: string) {
|
||||
async create(id_tipo_carrito: number, id_modulo: number) {
|
||||
const modulo = await this.moduloService.findById(id_modulo);
|
||||
const tipoCarrito =
|
||||
await this.institucionTipoCarritoService.findByIdTipoCarito(
|
||||
id_tipo_carrito,
|
||||
);
|
||||
let carrito = ""
|
||||
await this.repository.findAndCount({ modulo, tipoCarrito })
|
||||
.then((carritos) => {
|
||||
carrito = `C0${carritos[1] + 1}`
|
||||
})
|
||||
|
||||
const nuevoCarrito = this.repository.create({
|
||||
carrito,
|
||||
modulo,
|
||||
tipoCarrito,
|
||||
modulo,
|
||||
carrito,
|
||||
});
|
||||
|
||||
return this.repository
|
||||
.findOne({ carrito, modulo, tipoCarrito })
|
||||
.findOne({ modulo, tipoCarrito, carrito })
|
||||
.then((existeCarrito) => {
|
||||
if (existeCarrito)
|
||||
throw new ConflictException('Este carrito ya existe en este modulo');
|
||||
@ -54,17 +61,31 @@ export class CarritoService {
|
||||
}
|
||||
|
||||
// Toma de ejemplo la funcion que esta en /src/usuario/usuario.service.ts
|
||||
findByIdModulo(
|
||||
pagina: number,
|
||||
id_modulo: number,
|
||||
id_tipo_carrito: number,
|
||||
activo: boolean,
|
||||
) {
|
||||
return this.repository.findOne(id_modulo).then((modulo) => {
|
||||
if (!modulo)
|
||||
throw new NotFoundException('No existen carritos es este modulo');
|
||||
return modulo;
|
||||
});
|
||||
async findByIdModulo(filtros: {
|
||||
pagina?: string,
|
||||
id_modulo?: string,
|
||||
id_tipo_carrito?: string,
|
||||
activo?: boolean,
|
||||
}) {
|
||||
const busqueda: {
|
||||
modulo?: Modulo;
|
||||
institucionTipoCarrito?: InstitucionTipoCarrito;
|
||||
activo?: boolean;
|
||||
} = {}
|
||||
|
||||
const modulo = filtros.id_modulo
|
||||
? await this.moduloService.findById(Number(filtros.id_modulo))
|
||||
: null;
|
||||
const institucionTipoCarrito = filtros.id_tipo_carrito
|
||||
? await this.institucionTipoCarritoService.findById(Number(filtros.id_tipo_carrito))
|
||||
: null
|
||||
|
||||
if (filtros.activo) busqueda.activo = filtros.activo;
|
||||
if (modulo) busqueda.modulo = modulo;
|
||||
if (institucionTipoCarrito) busqueda.institucionTipoCarrito = institucionTipoCarrito;
|
||||
//falta página
|
||||
|
||||
return this.repository.find(busqueda);
|
||||
}
|
||||
|
||||
// re hacer
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { IsNumber } from 'class-validator';
|
||||
import { IsNumber, IsString } from 'class-validator';
|
||||
|
||||
export class CarritoCreateDto {
|
||||
@IsNumber()
|
||||
@ -8,6 +8,6 @@ export class CarritoCreateDto {
|
||||
id_modulo: number;
|
||||
|
||||
// Cambiar por IsString
|
||||
@IsNumber()
|
||||
@IsString()
|
||||
carrito: string;
|
||||
}
|
||||
|
20
src/carrito/dto/carrito-get-dto.ts
Normal file
20
src/carrito/dto/carrito-get-dto.ts
Normal file
@ -0,0 +1,20 @@
|
||||
import { IsBooleanString, IsNumberString, IsOptional } from 'class-validator';
|
||||
|
||||
export class CarritoGetDto {
|
||||
@IsNumberString()
|
||||
pagina: string;
|
||||
|
||||
@IsNumberString()
|
||||
@IsOptional()
|
||||
id_carrito?: string;
|
||||
|
||||
@IsNumberString()
|
||||
id_tipo_carrito: string;
|
||||
|
||||
@IsNumberString()
|
||||
id_modulo: string;
|
||||
|
||||
@IsBooleanString()
|
||||
@IsOptional()
|
||||
activo?: boolean;
|
||||
}
|
6
src/carrito/dto/carrito.dto.ts
Normal file
6
src/carrito/dto/carrito.dto.ts
Normal file
@ -0,0 +1,6 @@
|
||||
import { IsNumberString, } from 'class-validator';
|
||||
|
||||
export class CarritoDto {
|
||||
@IsNumberString()
|
||||
id_carrito: string;
|
||||
}
|
@ -1,22 +0,0 @@
|
||||
import { IsOptional, IsString } from 'class-validator';
|
||||
|
||||
export class CarritoGetDto {
|
||||
// Cambiar por IsNumberString, en todas
|
||||
@IsString()
|
||||
pagina: string;
|
||||
|
||||
// De aqui para abajo agregar IsOptional y operadro ?
|
||||
@IsString()
|
||||
id_carrito: string;
|
||||
|
||||
@IsString()
|
||||
id_tipo_carrito: string;
|
||||
|
||||
@IsString()
|
||||
id_modulo: string;
|
||||
|
||||
// Cambiat por IsBooleanString
|
||||
@IsString()
|
||||
@IsOptional()
|
||||
activo?: string;
|
||||
}
|
@ -1,8 +1,10 @@
|
||||
import { Controller, Get, Post, Put, Query } from '@nestjs/common';
|
||||
import { EquipoService } from './equipo.service';
|
||||
import { EquipoDto } from './dto/equipo.dto';
|
||||
import {ApiTags} from '@nestjs/swagger'
|
||||
|
||||
@Controller('equipo')
|
||||
@ApiTags('equipo')
|
||||
export class EquipoController {
|
||||
constructor(private equipoService: EquipoService) {}
|
||||
|
||||
|
@ -9,15 +9,7 @@ export class EquipoService {
|
||||
@InjectRepository(Equipo) private repository: Repository<Equipo>,
|
||||
) {}
|
||||
|
||||
async create(
|
||||
equipo: string,
|
||||
numero_inventario: string,
|
||||
numero_serie: string,
|
||||
prestado: boolean,
|
||||
id_carrito: number,
|
||||
id_programa: number,
|
||||
id_status: number,
|
||||
) {}
|
||||
async create() {}
|
||||
|
||||
findAll() {
|
||||
return this.repository.find();
|
||||
|
6
src/hora-excepcion/dto/hora-excepcion-create.dto.ts
Normal file
6
src/hora-excepcion/dto/hora-excepcion-create.dto.ts
Normal file
@ -0,0 +1,6 @@
|
||||
import { IsInt } from 'class-validator';
|
||||
|
||||
export class HoraExcepcionDto {
|
||||
@IsInt()
|
||||
id_institucion_dia: number;
|
||||
}
|
@ -1,15 +1,22 @@
|
||||
import { Controller, Delete, Get, Post, Put } from '@nestjs/common';
|
||||
import { Body, Controller, Delete, Get, Post, Put, Param } from '@nestjs/common';
|
||||
import { HoraExcepcionService } from './hora-excepcion.service';
|
||||
import { HoraExcepcionDto } from './dto/hora-excepcion-create.dto'
|
||||
import {ApiTags} from '@nestjs/swagger'
|
||||
|
||||
@Controller('hora-excepcion')
|
||||
@ApiTags('hora-excepcion')
|
||||
export class HoraExcepcionController {
|
||||
constructor(private horaExcepcionService: HoraExcepcionService) {}
|
||||
|
||||
@Post()
|
||||
create() {}
|
||||
create(@Body() body: HoraExcepcionDto) {
|
||||
return this.horaExcepcionService.create(body.id_institucion_dia)
|
||||
}
|
||||
|
||||
@Delete()
|
||||
delete() {}
|
||||
@Delete(':id')
|
||||
delete(@Param('id') id_hora_excepcion: number) {
|
||||
return this.horaExcepcionService.delete(id_hora_excepcion)
|
||||
}
|
||||
|
||||
@Get()
|
||||
get() {}
|
||||
|
@ -3,10 +3,12 @@ import { TypeOrmModule } from '@nestjs/typeorm';
|
||||
import { HoraExcepcionController } from './hora-excepcion.controller';
|
||||
import { HoraExcepcionService } from './hora-excepcion.service';
|
||||
import { HoraExcepcion } from './entity/hora-excepcion.entity';
|
||||
import { InstitucionDiaModule } from '../institucion-dia/institucion-dia.module'
|
||||
|
||||
@Module({
|
||||
imports: [TypeOrmModule.forFeature([HoraExcepcion])],
|
||||
imports: [TypeOrmModule.forFeature([HoraExcepcion]), InstitucionDiaModule],
|
||||
controllers: [HoraExcepcionController],
|
||||
providers: [HoraExcepcionService],
|
||||
exports: [HoraExcepcionService]
|
||||
})
|
||||
export class HoraExcepcionModule {}
|
||||
|
@ -1,12 +1,43 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { ConflictException, NotFoundException, Injectable } from '@nestjs/common';
|
||||
import { InjectRepository } from '@nestjs/typeorm';
|
||||
import { Repository } from 'typeorm';
|
||||
import { HoraExcepcion } from './entity/hora-excepcion.entity';
|
||||
import { InstitucionDiaService } from '../institucion-dia/institucion-dia.service'
|
||||
|
||||
@Injectable()
|
||||
export class HoraExcepcionService {
|
||||
constructor(
|
||||
@InjectRepository(HoraExcepcion)
|
||||
private repository: Repository<HoraExcepcion>,
|
||||
) {}
|
||||
@InjectRepository(HoraExcepcion) private repository: Repository<HoraExcepcion>,
|
||||
private institucionDiaService: InstitucionDiaService,
|
||||
) { }
|
||||
|
||||
async create(id_institucion_dia: number) {
|
||||
const institucionDia = await this.institucionDiaService.findById(id_institucion_dia)
|
||||
const nuevaHoraExcepcion = this.repository.create({institucionDia});
|
||||
|
||||
return this.repository
|
||||
.findOne({institucionDia})
|
||||
.then((existeHoraExcepcion) => {
|
||||
if (existeHoraExcepcion) throw new ConflictException('Ya existe esta hora excepción')
|
||||
return this.repository.save(nuevaHoraExcepcion)
|
||||
})
|
||||
.then(() => ({message: 'Se creo correctamente la hora excepción'}))
|
||||
}
|
||||
|
||||
findById(id_hora_excepcion: number) {
|
||||
return this.repository
|
||||
.findOne({ id_hora_excepcion })
|
||||
.then((horaExcepcion) => {
|
||||
if (!horaExcepcion)
|
||||
throw new NotFoundException('No existe esta carrera-programa');
|
||||
return horaExcepcion;
|
||||
});
|
||||
}
|
||||
|
||||
delete(id_hora_excepcion: number) {
|
||||
this.findById(id_hora_excepcion)
|
||||
.then(() => {
|
||||
return this.repository.delete(id_hora_excepcion)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@ -2,8 +2,10 @@ import { Body, Controller, Get, Put, Query } from '@nestjs/common';
|
||||
import { InstitucionDiaService } from './institucion-dia.service';
|
||||
import { IdInstitucionDto } from '../dto/id-institucion.dto';
|
||||
import { InstitucionDiaUpdateDto } from './dto/institucion-dia-update.dto';
|
||||
import {ApiTags} from '@nestjs/swagger'
|
||||
|
||||
@Controller('institucion-dia')
|
||||
@ApiTags('institucion-dia')
|
||||
export class InstitucionDiaController {
|
||||
constructor(private institucionDiaService: InstitucionDiaService) {}
|
||||
|
||||
|
@ -10,5 +10,6 @@ import { InstitucionModule } from '../institucion/institucion.module';
|
||||
imports: [TypeOrmModule.forFeature([Dia, InstitucionDia]), InstitucionModule],
|
||||
controllers: [InstitucionDiaController],
|
||||
providers: [InstitucionDiaService],
|
||||
exports: [InstitucionDiaService]
|
||||
})
|
||||
export class InstitucionDiaModule {}
|
||||
|
@ -3,8 +3,10 @@ import { InstitucionInfraccionService } from './institucion-infraccion.service';
|
||||
import { IdInstitucionDto } from '../dto/id-institucion.dto';
|
||||
import { InstitucionInfraccionCreateDto } from './dto/institucion-infraccion-create.dto';
|
||||
import { InstitucionInfraccionUpdateDto } from './dto/institucion-infraccion-update.dto';
|
||||
import {ApiTags} from '@nestjs/swagger'
|
||||
|
||||
@Controller('institucion-infraccion')
|
||||
@ApiTags('institucion-infraccion')
|
||||
export class InstitucionInfraccionController {
|
||||
constructor(
|
||||
private institucionInfraccionService: InstitucionInfraccionService,
|
||||
|
@ -3,8 +3,10 @@ import { InstitucionTipoCarritoService } from './institucion-tipo-carrito.servic
|
||||
import { IdInstitucionDto } from '../dto/id-institucion.dto';
|
||||
import { InstitucionTipoCarritoCreateDto } from './dto/institucion-tipo-carrito-create.dto';
|
||||
import { InstitucionTipoCarritoUpdateDto } from './dto/institucion-tipo-carrito-update.dto';
|
||||
import {ApiTags} from '@nestjs/swagger'
|
||||
|
||||
@Controller('institucion-tipo-carrito')
|
||||
@ApiTags('institucion-tipo-carrito')
|
||||
export class InstitucionTipoCarritoController {
|
||||
constructor(
|
||||
private institucionTipoCarritoService: InstitucionTipoCarritoService,
|
||||
|
@ -2,8 +2,11 @@ import { Body, Controller, Get, Put, Query } from '@nestjs/common';
|
||||
import { InstitucionService } from './institucion.service';
|
||||
import { IdInstitucionDto } from '../dto/id-institucion.dto';
|
||||
import { InstitucionUpdateDto } from './dto/institucion-update.dto';
|
||||
import {ApiTags} from '@nestjs/swagger'
|
||||
|
||||
|
||||
@Controller('institucion')
|
||||
@ApiTags('institucion')
|
||||
export class InstitucionController {
|
||||
constructor(private institucionService: InstitucionService) {}
|
||||
|
||||
|
10
src/main.ts
10
src/main.ts
@ -1,9 +1,19 @@
|
||||
import { NestFactory } from '@nestjs/core';
|
||||
import { SwaggerModule, DocumentBuilder } from '@nestjs/swagger';
|
||||
import { ValidationPipe } from '@nestjs/common';
|
||||
import { AppModule } from './app.module';
|
||||
|
||||
async function bootstrap() {
|
||||
const app = await NestFactory.create(AppModule);
|
||||
|
||||
const config = new DocumentBuilder()
|
||||
.setTitle('pcpuma_unam_api')
|
||||
.setDescription('Api de Pc puma')
|
||||
.setVersion('1.0')
|
||||
.build();
|
||||
const document = SwaggerModule.createDocument(app, config);
|
||||
SwaggerModule.setup('api', app, document);
|
||||
|
||||
app.useGlobalPipes(new ValidationPipe({ whitelist: true }));
|
||||
await app.listen(3000);
|
||||
}
|
||||
|
@ -3,8 +3,11 @@ import { ModuloService } from './modulo.service';
|
||||
import { IdInstitucionDto } from '../dto/id-institucion.dto';
|
||||
import { ModuloCreateDto } from './dto/modulo-create.dto';
|
||||
import { ModuloUpdateDto } from './dto/modulo-update.dto';
|
||||
import {ApiTags} from '@nestjs/swagger'
|
||||
// import { Serealize } from '../interceptors/serialize.interceptor';
|
||||
|
||||
@Controller('modulo')
|
||||
@ApiTags('modulo')
|
||||
export class ModuloController {
|
||||
constructor(private moduloService: ModuloService) {}
|
||||
|
||||
|
@ -1,7 +1,10 @@
|
||||
import { Controller, Get, Query } from '@nestjs/common';
|
||||
import { MotivoService } from './motivo.service';
|
||||
import { MotivoDto } from './dto/motivo.dto';
|
||||
import {ApiTags} from '@nestjs/swagger'
|
||||
|
||||
@Controller('motivo')
|
||||
@ApiTags('motivo')
|
||||
export class MotivoController {
|
||||
constructor(private motivoService: MotivoService) {}
|
||||
|
||||
|
@ -1,7 +1,9 @@
|
||||
import { Controller, Get } from '@nestjs/common';
|
||||
import { MultaService } from './multa.service';
|
||||
import {ApiTags} from '@nestjs/swagger'
|
||||
|
||||
@Controller('multa')
|
||||
@ApiTags('multa')
|
||||
export class MultaController {
|
||||
constructor(private multaService: MultaService) {}
|
||||
|
||||
|
@ -4,7 +4,10 @@ import { OperadorCreateDto } from './dto/operador-create.dto';
|
||||
import { OperadorOperadoresDto } from './dto/operador-operadores.dto';
|
||||
import { OperadorUpdateDto } from './dto/operador-update.dto';
|
||||
import { OperadorDto } from './dto/operador.dto';
|
||||
import {ApiTags} from '@nestjs/swagger'
|
||||
|
||||
@Controller('operador')
|
||||
@ApiTags('operador')
|
||||
export class OperadorController {
|
||||
constructor(private operadorService: OperadorService) {}
|
||||
|
||||
|
@ -1,7 +1,9 @@
|
||||
import { Controller, Get, Post, Put } from '@nestjs/common';
|
||||
import { PrestamoService } from './prestamo.service';
|
||||
import {ApiTags} from '@nestjs/swagger'
|
||||
|
||||
@Controller('prestamo')
|
||||
@ApiTags('prestamo')
|
||||
export class PrestamoController {
|
||||
constructor(private prestamoService: PrestamoService) {}
|
||||
|
||||
|
@ -2,8 +2,10 @@ import { Body, Controller, Get, Post, Query } from '@nestjs/common';
|
||||
import { ProgramaService } from './programa.service';
|
||||
import { ProgramaCreateDto } from './dto/programa-create.dto';
|
||||
import { ProgramaDto } from './dto/programa.dto'
|
||||
import {ApiTags} from '@nestjs/swagger'
|
||||
|
||||
@Controller('programa')
|
||||
@ApiTags('programa')
|
||||
export class ProgramaController {
|
||||
constructor(private programaService: ProgramaService) {}
|
||||
|
||||
|
@ -1,7 +1,10 @@
|
||||
import { Controller, Get } from '@nestjs/common';
|
||||
import { StatusService } from './status.service';
|
||||
import {ApiTags} from '@nestjs/swagger'
|
||||
|
||||
|
||||
@Controller('status')
|
||||
@ApiTags('status')
|
||||
export class StatusController {
|
||||
constructor(private statusService: StatusService) {}
|
||||
|
||||
|
6
src/tipo-entrada/dto/tipo-entrada-create.dto.ts
Normal file
6
src/tipo-entrada/dto/tipo-entrada-create.dto.ts
Normal file
@ -0,0 +1,6 @@
|
||||
import { IsString } from 'class-validator';
|
||||
|
||||
export class TipoEntradaCreateDto {
|
||||
@IsString()
|
||||
tipo_entrada: string;
|
||||
}
|
@ -1,10 +1,20 @@
|
||||
import { Controller, Get } from '@nestjs/common';
|
||||
import { Body, Controller, Get, Post } from '@nestjs/common';
|
||||
import { TipoEntradaService } from './tipo-entrada.service';
|
||||
import { TipoEntradaCreateDto } from './dto/tipo-entrada-create.dto'
|
||||
import { ApiTags } from '@nestjs/swagger'
|
||||
|
||||
@Controller('tipo-entrada')
|
||||
@ApiTags('tipo-entrada')
|
||||
export class TipoEntradaController {
|
||||
constructor(private tipoEntradaService: TipoEntradaService) {}
|
||||
|
||||
@Post()
|
||||
create(@Body() body: TipoEntradaCreateDto) {
|
||||
return this.tipoEntradaService.create(body.tipo_entrada)
|
||||
}
|
||||
|
||||
@Get()
|
||||
get() {}
|
||||
get() {
|
||||
return this.tipoEntradaService.findAll()
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { Injectable, ConflictException } from '@nestjs/common';
|
||||
import { InjectRepository } from '@nestjs/typeorm';
|
||||
import { Repository } from 'typeorm';
|
||||
import { TipoEntrada } from './entity/tipo-entrada.entity';
|
||||
@ -7,5 +7,22 @@ import { TipoEntrada } from './entity/tipo-entrada.entity';
|
||||
export class TipoEntradaService {
|
||||
constructor(
|
||||
@InjectRepository(TipoEntrada) private repository: Repository<TipoEntrada>,
|
||||
) {}
|
||||
) { }
|
||||
|
||||
async create(tipo_entrada: string) {
|
||||
const nuevoTipoEntrada = this.repository.create({
|
||||
tipo_entrada
|
||||
})
|
||||
|
||||
return this.repository.findOne({ tipo_entrada })
|
||||
.then((existeTipoEntrada) => {
|
||||
if(existeTipoEntrada) throw new ConflictException('Ya existe este tipo de entrada')
|
||||
return this.repository.save(nuevoTipoEntrada)
|
||||
})
|
||||
.then(()=> ({message: 'Se creo correctamente la nueva entrada'}))
|
||||
}
|
||||
|
||||
findAll() {
|
||||
return this.repository.find()
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,10 @@
|
||||
import { Body, Controller, Get, Post } from '@nestjs/common';
|
||||
import { TipoUsuarioService } from './tipo-usuario.service';
|
||||
import { TipoUsuarioUpdateDto } from './dto/tipo-usuario-update.dto';
|
||||
import {ApiTags} from '@nestjs/swagger'
|
||||
|
||||
@Controller('tipo-usuario')
|
||||
@ApiTags('tipo-usuario')
|
||||
export class TipoUsuarioController {
|
||||
constructor(private tipoUsuarioService: TipoUsuarioService) {}
|
||||
|
||||
|
@ -10,8 +10,10 @@ import {
|
||||
import { FileInterceptor } from '@nestjs/platform-express';
|
||||
import { UploadFileService } from './upload-file.service';
|
||||
import { IdInstitucionDto } from '../dto/id-institucion.dto';
|
||||
import {ApiTags} from '@nestjs/swagger'
|
||||
|
||||
@Controller('upload-file')
|
||||
@ApiTags('upload-file')
|
||||
export class UploadFileController {
|
||||
constructor(private uploadFileService: UploadFileService) {}
|
||||
|
||||
|
@ -14,8 +14,11 @@ import { UsuarioUpdateDto } from './dto/usuario-update.dto';
|
||||
import { UsuarioUsuariosDto } from './dto/usuario-usuarios.dto';
|
||||
import { UsuarioDto } from './dto/usuario.dto';
|
||||
import { AuthGuard } from '@nestjs/passport';
|
||||
import {ApiTags} from '@nestjs/swagger'
|
||||
|
||||
|
||||
@Controller('usuario')
|
||||
@ApiTags('usuario')
|
||||
export class UsuarioController {
|
||||
constructor(private usuarioService: UsuarioService) {}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user