db corregida
This commit is contained in:
+20
-14
@@ -2,44 +2,49 @@ import { Module } from '@nestjs/common';
|
||||
import { ConfigModule, ConfigService } from '@nestjs/config';
|
||||
import { TypeOrmModule } from '@nestjs/typeorm';
|
||||
|
||||
import { AuthModule } from './auth/auth.module';
|
||||
import { BcryptModule } from './bcrypt/bcrypt.module';
|
||||
import { CarreraModule } from './carrera/carrera.module';
|
||||
import { CarreraProgramaModule } from './carrera-programa/carrera-programa.module';
|
||||
import { CarritoModule } from './carrito/carrito.module';
|
||||
import { CronModule } from './cron/cron.module';
|
||||
import { EquipoModule } from './equipo/equipo.module';
|
||||
import { HoraExcepcionModule } from './hora-excepcion/hora-excepcion.module';
|
||||
import { InstitucionModule } from './institucion/institucion.module';
|
||||
import { InstitucionCarreraModule } from './institucion-carrera/institucion-carrera.module';
|
||||
import { InstitucionDiaModule } from './institucion-dia/institucion-dia.module';
|
||||
import { InstitucionInfraccionModule } from './institucion-infraccion/institucion-infraccion.module';
|
||||
import { InstitucionTipoCarritoModule } from './institucion-tipo-carrito/institucion-tipo-carrito.module';
|
||||
import { ModuloModule } from './modulo/modulo.module';
|
||||
import { MotivoModule } from './motivo/motivo.module';
|
||||
import { MultaModule } from './multa/multa.module';
|
||||
import { NodemailerModule } from './nodemailer/nodemailer.module';
|
||||
import { OperadorModule } from './operador/operador.module';
|
||||
import { PrestamoModule } from './prestamo/prestamo.module';
|
||||
import { ProgramaModule } from './programa/programa.module';
|
||||
import { StatusModule } from './status/status.module';
|
||||
import { TipoUsuarioModule } from './tipo-usuario/tipo-usuario.module';
|
||||
import { UsuarioModule } from './usuario/usuario.module';
|
||||
import { CarreraModule } from './carrera/carrera.module';
|
||||
import { TipoEntradaModule } from './tipo-entrada/tipo-entrada.module';
|
||||
import { CarreraProgramaModule } from './carrera-programa/carrera-programa.module';
|
||||
import { TipoUsuarioModule } from './tipo-usuario/tipo-usuario.module';
|
||||
import { UploadFileModule } from './upload-file/upload-file.module';
|
||||
import { UsuarioModule } from './usuario/usuario.module';
|
||||
|
||||
import { AuthModule } from './auth/auth.module';
|
||||
import { BcryptModule } from './bcrypt/bcrypt.module';
|
||||
import { Carrera } from './carrera/entity/carrera.entity';
|
||||
import { CarreraPrograma } from './carrera-programa/entity/carrera-programa.entity';
|
||||
import { Carrito } from './carrito/entity/carrito.entity';
|
||||
import { CronModule } from './cron/cron.module';
|
||||
import { Dia } from './institucion-dia/entity/dia.entity';
|
||||
import { Equipo } from './equipo/entity/equipo.entity';
|
||||
import { EquipoTipoEntrada } from './equipo/entity/equipo-tipo-entrada.entity';
|
||||
import { HoraExcepcion } from './hora-excepcion/entity/hora-excepcion.entity';
|
||||
import { Infraccion } from './institucion-infraccion/entity/infraccion.entity';
|
||||
import { Institucion } from './institucion/entity/institucion.entity';
|
||||
import { InstitucionCarrera } from './institucion-carrera/entity/institucion-carrera.entity';
|
||||
import { InstitucionDia } from './institucion-dia/entity/institucion-dia.entity';
|
||||
import { InstitucionInfraccion } from './institucion-infraccion/entity/institucion-infraccion.entity';
|
||||
import { InstitucionTipoCarrito } from './institucion-tipo-carrito/entity/institucion-tipo-carrito.entity';
|
||||
import { Modulo } from './modulo/entity/modulo.entity';
|
||||
import { Motivo } from './motivo/entity/motivo.entity';
|
||||
import { Multa } from './multa/entity/multa.entity';
|
||||
import { Nivel } from './institucion-carrera/entity/nivel.entity';
|
||||
import { Operador } from './operador/entity/operador.entity';
|
||||
import { Prestamo } from './prestamo/entity/prestamo.entity';
|
||||
import { Programa } from './programa/entity/programa.entity';
|
||||
@@ -47,9 +52,7 @@ import { Status } from './status/entity/status.entity';
|
||||
import { TipoCarrito } from './institucion-tipo-carrito/entity/tipo-carrito.entity';
|
||||
import { TipoEntrada } from './tipo-entrada/entity/tipo-entrada.entity';
|
||||
import { TipoUsuario } from './tipo-usuario/entity/tipo-usuario.entity';
|
||||
import { UploadFileModule } from './upload-file/upload-file.module';
|
||||
import { Usuario } from './usuario/entity/usuario.entity';
|
||||
import { NodemailerModule } from './nodemailer/nodemailer.module';
|
||||
|
||||
@Module({
|
||||
imports: [
|
||||
@@ -75,12 +78,14 @@ import { NodemailerModule } from './nodemailer/nodemailer.module';
|
||||
HoraExcepcion,
|
||||
Infraccion,
|
||||
Institucion,
|
||||
InstitucionCarrera,
|
||||
InstitucionDia,
|
||||
InstitucionInfraccion,
|
||||
InstitucionTipoCarrito,
|
||||
Modulo,
|
||||
Motivo,
|
||||
Multa,
|
||||
Nivel,
|
||||
Operador,
|
||||
Prestamo,
|
||||
Programa,
|
||||
@@ -94,29 +99,30 @@ import { NodemailerModule } from './nodemailer/nodemailer.module';
|
||||
},
|
||||
}),
|
||||
AuthModule,
|
||||
BcryptModule,
|
||||
CarreraModule,
|
||||
CarreraProgramaModule,
|
||||
CarritoModule,
|
||||
CronModule,
|
||||
EquipoModule,
|
||||
HoraExcepcionModule,
|
||||
InstitucionModule,
|
||||
InstitucionCarreraModule,
|
||||
InstitucionDiaModule,
|
||||
InstitucionInfraccionModule,
|
||||
InstitucionTipoCarritoModule,
|
||||
ModuloModule,
|
||||
MotivoModule,
|
||||
MultaModule,
|
||||
NodemailerModule,
|
||||
OperadorModule,
|
||||
PrestamoModule,
|
||||
ProgramaModule,
|
||||
StatusModule,
|
||||
TipoEntradaModule,
|
||||
TipoUsuarioModule,
|
||||
UsuarioModule,
|
||||
InstitucionTipoCarritoModule,
|
||||
BcryptModule,
|
||||
UploadFileModule,
|
||||
CronModule,
|
||||
NodemailerModule,
|
||||
UsuarioModule,
|
||||
],
|
||||
})
|
||||
export class AppModule {}
|
||||
|
||||
@@ -4,12 +4,14 @@ import { CarreraProgramaController } from './carrera-programa.controller';
|
||||
import { CarreraProgramaService } from './carrera-programa.service';
|
||||
import { CarreraPrograma } from './entity/carrera-programa.entity';
|
||||
import { CarreraModule } from '../carrera/carrera.module';
|
||||
import { InstitucionCarreraModule } from '../institucion-carrera/institucion-carrera.module';
|
||||
import { ProgramaModule } from '../programa/programa.module';
|
||||
|
||||
@Module({
|
||||
imports: [
|
||||
TypeOrmModule.forFeature([CarreraPrograma]),
|
||||
CarreraModule,
|
||||
InstitucionCarreraModule,
|
||||
TypeOrmModule.forFeature([CarreraPrograma]),
|
||||
ProgramaModule,
|
||||
],
|
||||
controllers: [CarreraProgramaController],
|
||||
|
||||
@@ -7,6 +7,7 @@ import { InjectRepository } from '@nestjs/typeorm';
|
||||
import { Repository } from 'typeorm';
|
||||
import { CarreraPrograma } from './entity/carrera-programa.entity';
|
||||
import { CarreraService } from '../carrera/carrera.service';
|
||||
import { InstitucionCarreraService } from '../institucion-carrera/institucion-carrera.service';
|
||||
import { ProgramaService } from '../programa/programa.service';
|
||||
|
||||
@Injectable()
|
||||
@@ -15,11 +16,14 @@ export class CarreraProgramaService {
|
||||
@InjectRepository(CarreraPrograma)
|
||||
private repository: Repository<CarreraPrograma>,
|
||||
private carreraService: CarreraService,
|
||||
private institucionCarreraService: InstitucionCarreraService,
|
||||
private programaService: ProgramaService,
|
||||
) {}
|
||||
|
||||
async create(id_carrera: number, id_programa: number) {
|
||||
const carrera = await this.carreraService.findById(id_carrera);
|
||||
async create(id_institucion_carrera: number, id_programa: number) {
|
||||
const carrera = await this.institucionCarreraService.findById(
|
||||
id_institucion_carrera,
|
||||
);
|
||||
const programa = await this.programaService.findById(id_programa);
|
||||
const nuevoCarreraPrograma = this.repository.create({
|
||||
carrera,
|
||||
@@ -54,9 +58,8 @@ export class CarreraProgramaService {
|
||||
|
||||
//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)
|
||||
})
|
||||
this.findById(id_carrera_programa).then(() => {
|
||||
return this.repository.delete(id_carrera_programa);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Entity, PrimaryGeneratedColumn, ManyToOne, JoinColumn } from 'typeorm';
|
||||
import { Carrera } from '../../carrera/entity/carrera.entity';
|
||||
import { InstitucionCarrera } from '../../institucion-carrera/entity/institucion-carrera.entity';
|
||||
import { Programa } from '../../programa/entity/programa.entity';
|
||||
|
||||
@Entity()
|
||||
@@ -7,9 +7,12 @@ export class CarreraPrograma {
|
||||
@PrimaryGeneratedColumn()
|
||||
id_carrera_programa: number;
|
||||
|
||||
@ManyToOne(() => Carrera, (carrera) => carrera.carreraProgramas)
|
||||
@JoinColumn({ name: 'id_carrera' })
|
||||
carrera: Carrera;
|
||||
@ManyToOne(
|
||||
() => InstitucionCarrera,
|
||||
(institucionCarrera) => institucionCarrera.programas,
|
||||
)
|
||||
@JoinColumn({ name: 'id_institucion_carrera' })
|
||||
carrera: InstitucionCarrera;
|
||||
|
||||
@ManyToOne(() => Programa, (programa) => programa.carrerasPrograma)
|
||||
@JoinColumn({ name: 'id_programa' })
|
||||
|
||||
@@ -1,20 +1,15 @@
|
||||
import { Controller, Get, Query } from '@nestjs/common';
|
||||
import { CarreraService } from './carrera.service';
|
||||
import { CarritoGetDto } from './dto/carrera-get-dto';
|
||||
import {ApiTags} from '@nestjs/swagger'
|
||||
|
||||
import { ApiTags } from '@nestjs/swagger';
|
||||
|
||||
@Controller('carrera')
|
||||
@ApiTags('carrera')
|
||||
export class CarreraController {
|
||||
constructor(private carreraService: CarreraService) {}
|
||||
|
||||
@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));
|
||||
@Get()
|
||||
get() {
|
||||
return this.carreraService.findAll();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,10 +3,9 @@ import { TypeOrmModule } from '@nestjs/typeorm';
|
||||
import { CarreraController } from './carrera.controller';
|
||||
import { CarreraService } from './carrera.service';
|
||||
import { Carrera } from './entity/carrera.entity';
|
||||
import { InstitucionModule } from '../institucion/institucion.module';
|
||||
|
||||
@Module({
|
||||
imports: [InstitucionModule, TypeOrmModule.forFeature([Carrera])],
|
||||
imports: [TypeOrmModule.forFeature([Carrera])],
|
||||
controllers: [CarreraController],
|
||||
providers: [CarreraService],
|
||||
exports: [CarreraService],
|
||||
|
||||
@@ -2,23 +2,13 @@ import { Injectable, NotFoundException } from '@nestjs/common';
|
||||
import { InjectRepository } from '@nestjs/typeorm';
|
||||
import { Repository } from 'typeorm';
|
||||
import { Carrera } from './entity/carrera.entity';
|
||||
import { InstitucionService } from '../institucion/institucion.service';
|
||||
|
||||
@Injectable()
|
||||
export class CarreraService {
|
||||
constructor(
|
||||
@InjectRepository(Carrera) private repository: Repository<Carrera>,
|
||||
private institucionService: InstitucionService,
|
||||
) {}
|
||||
|
||||
create(id_institucion: number, carrera: string) {
|
||||
return this.institucionService
|
||||
.findById(id_institucion)
|
||||
.then((institucion) =>
|
||||
this.repository.save(this.repository.create({ carrera, institucion })),
|
||||
);
|
||||
}
|
||||
|
||||
findAll() {
|
||||
return this.repository.find();
|
||||
}
|
||||
@@ -37,10 +27,4 @@ export class CarreraService {
|
||||
return carrera;
|
||||
});
|
||||
}
|
||||
|
||||
findAllByIdInstitucion(id_institucion: number) {
|
||||
return this.institucionService
|
||||
.findById(id_institucion)
|
||||
.then((institucion) => this.repository.find({ institucion }));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
import { IsString } from 'class-validator';
|
||||
|
||||
export class CarritoGetDto {
|
||||
// Cambiar IsString por IsNumberString
|
||||
@IsString()
|
||||
id_carrera: string;
|
||||
|
||||
@IsString()
|
||||
id_institucion: String;
|
||||
}
|
||||
@@ -1,14 +1,5 @@
|
||||
import {
|
||||
Column,
|
||||
Entity,
|
||||
JoinColumn,
|
||||
ManyToOne,
|
||||
OneToMany,
|
||||
PrimaryGeneratedColumn,
|
||||
} from 'typeorm';
|
||||
import { CarreraPrograma } from '../../carrera-programa/entity/carrera-programa.entity';
|
||||
import { Institucion } from '../../institucion/entity/institucion.entity';
|
||||
import { Usuario } from '../../usuario/entity/usuario.entity';
|
||||
import { Column, Entity, OneToMany, PrimaryGeneratedColumn } from 'typeorm';
|
||||
import { InstitucionCarrera } from '../../institucion-carrera/entity/institucion-carrera.entity';
|
||||
|
||||
@Entity()
|
||||
export class Carrera {
|
||||
@@ -18,16 +9,12 @@ export class Carrera {
|
||||
@Column({ type: String, nullable: false, length: 150 })
|
||||
carrera: string;
|
||||
|
||||
@ManyToOne(() => Institucion, (institucion) => institucion.carreras)
|
||||
@JoinColumn({ name: 'id_institucion' })
|
||||
institucion: Institucion;
|
||||
@Column({ type: String, nullable: false, length: 3 })
|
||||
clave: string;
|
||||
|
||||
@OneToMany(
|
||||
() => CarreraPrograma,
|
||||
(carreraPrograma) => carreraPrograma.carrera,
|
||||
() => InstitucionCarrera,
|
||||
(institucionCarrera) => institucionCarrera.carrera,
|
||||
)
|
||||
carreraProgramas: CarreraPrograma[];
|
||||
|
||||
@OneToMany(() => Usuario, (usuario) => usuario.carrera)
|
||||
usuarios: Usuario[];
|
||||
instituciones: InstitucionCarrera[];
|
||||
}
|
||||
|
||||
@@ -21,6 +21,12 @@ export class Carrito {
|
||||
@Column({ type: String, nullable: false, length: 4 })
|
||||
carrito: string;
|
||||
|
||||
@Column({ type: String, nullable: false, length: 30 })
|
||||
marca: string;
|
||||
|
||||
@Column({ type: String, nullable: false, length: 30 })
|
||||
modelo: string;
|
||||
|
||||
@ManyToOne(() => Modulo, (modulo) => modulo.carritos)
|
||||
@JoinColumn({ name: 'id_modulo' })
|
||||
modulo: Modulo;
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
import { IsNumberString } from 'class-validator';
|
||||
|
||||
export class InstitucionCarreraDto {
|
||||
@IsNumberString()
|
||||
id_institucion: string;
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
import {
|
||||
Entity,
|
||||
JoinColumn,
|
||||
ManyToOne,
|
||||
OneToMany,
|
||||
PrimaryGeneratedColumn,
|
||||
} from 'typeorm';
|
||||
import { Carrera } from '../../carrera/entity/carrera.entity';
|
||||
import { CarreraPrograma } from '../../carrera-programa/entity/carrera-programa.entity';
|
||||
import { Institucion } from '../../institucion/entity/institucion.entity';
|
||||
import { Nivel } from './nivel.entity';
|
||||
import { Usuario } from '../../usuario/entity/usuario.entity';
|
||||
|
||||
@Entity()
|
||||
export class InstitucionCarrera {
|
||||
@PrimaryGeneratedColumn()
|
||||
id_institucion_carrera: number;
|
||||
|
||||
@ManyToOne(() => Carrera, (carrera) => carrera.instituciones)
|
||||
@JoinColumn({ name: 'id_carrera' })
|
||||
carrera: Carrera;
|
||||
|
||||
@ManyToOne(() => Institucion, (institucion) => institucion.carreras)
|
||||
@JoinColumn({ name: 'id_institucion' })
|
||||
institucion: Institucion;
|
||||
|
||||
@ManyToOne(() => Nivel, (nivel) => nivel.institucionesCarreras)
|
||||
@JoinColumn({ name: 'id_nivel' })
|
||||
nivel: Nivel;
|
||||
|
||||
@OneToMany(
|
||||
() => CarreraPrograma,
|
||||
(carreraPrograma) => carreraPrograma.carrera,
|
||||
)
|
||||
programas: CarreraPrograma[];
|
||||
|
||||
@OneToMany(() => Usuario, (usuario) => usuario.carrera)
|
||||
usuarios: Usuario[];
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
import { Column, Entity, OneToMany, PrimaryGeneratedColumn } from 'typeorm';
|
||||
import { InstitucionCarrera } from './institucion-carrera.entity';
|
||||
|
||||
@Entity()
|
||||
export class Nivel {
|
||||
@PrimaryGeneratedColumn()
|
||||
id_nivel: number;
|
||||
|
||||
@Column({ type: String, nullable: false, default: false, length: 1 })
|
||||
clave: string;
|
||||
|
||||
@Column({ type: String, nullable: false, length: 40 })
|
||||
nivel: string;
|
||||
|
||||
@OneToMany(
|
||||
() => InstitucionCarrera,
|
||||
(institucionCarrera) => institucionCarrera.nivel,
|
||||
)
|
||||
institucionesCarreras: InstitucionCarrera[];
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
import { Test, TestingModule } from '@nestjs/testing';
|
||||
import { InstitucionCarreraController } from './institucion-carrera.controller';
|
||||
|
||||
describe('InstitucionCarreraController', () => {
|
||||
let controller: InstitucionCarreraController;
|
||||
|
||||
beforeEach(async () => {
|
||||
const module: TestingModule = await Test.createTestingModule({
|
||||
controllers: [InstitucionCarreraController],
|
||||
}).compile();
|
||||
|
||||
controller = module.get<InstitucionCarreraController>(InstitucionCarreraController);
|
||||
});
|
||||
|
||||
it('should be defined', () => {
|
||||
expect(controller).toBeDefined();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,15 @@
|
||||
import { Controller, Get, Query } from '@nestjs/common';
|
||||
import { InstitucionCarreraService } from './institucion-carrera.service';
|
||||
import { InstitucionCarreraDto } from './dto/institucion-carrera.dto';
|
||||
|
||||
@Controller('institucion-carrera')
|
||||
export class InstitucionCarreraController {
|
||||
constructor(private institucionCarreraService: InstitucionCarreraService) {}
|
||||
|
||||
@Get()
|
||||
get(@Query() query: InstitucionCarreraDto) {
|
||||
return this.institucionCarreraService.findAllByIdInstitucion(
|
||||
Number(query.id_institucion),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { TypeOrmModule } from '@nestjs/typeorm';
|
||||
import { InstitucionCarreraController } from './institucion-carrera.controller';
|
||||
import { InstitucionCarreraService } from './institucion-carrera.service';
|
||||
import { InstitucionCarrera } from './entity/institucion-carrera.entity';
|
||||
import { Nivel } from './entity/nivel.entity';
|
||||
import { InstitucionModule } from 'src/institucion/institucion.module';
|
||||
|
||||
@Module({
|
||||
imports: [
|
||||
InstitucionModule,
|
||||
TypeOrmModule.forFeature([InstitucionCarrera, Nivel]),
|
||||
],
|
||||
controllers: [InstitucionCarreraController],
|
||||
providers: [InstitucionCarreraService],
|
||||
exports: [InstitucionCarreraService],
|
||||
})
|
||||
export class InstitucionCarreraModule {}
|
||||
@@ -0,0 +1,18 @@
|
||||
import { Test, TestingModule } from '@nestjs/testing';
|
||||
import { InstitucionCarreraService } from './institucion-carrera.service';
|
||||
|
||||
describe('InstitucionCarreraService', () => {
|
||||
let service: InstitucionCarreraService;
|
||||
|
||||
beforeEach(async () => {
|
||||
const module: TestingModule = await Test.createTestingModule({
|
||||
providers: [InstitucionCarreraService],
|
||||
}).compile();
|
||||
|
||||
service = module.get<InstitucionCarreraService>(InstitucionCarreraService);
|
||||
});
|
||||
|
||||
it('should be defined', () => {
|
||||
expect(service).toBeDefined();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,30 @@
|
||||
import { Injectable, NotFoundException } from '@nestjs/common';
|
||||
import { InjectRepository } from '@nestjs/typeorm';
|
||||
import { Repository } from 'typeorm';
|
||||
import { InstitucionCarrera } from './entity/institucion-carrera.entity';
|
||||
import { InstitucionService } from '../institucion/institucion.service';
|
||||
|
||||
@Injectable()
|
||||
export class InstitucionCarreraService {
|
||||
constructor(
|
||||
@InjectRepository(InstitucionCarrera)
|
||||
private repository: Repository<InstitucionCarrera>,
|
||||
private institucionService: InstitucionService,
|
||||
) {}
|
||||
|
||||
findAllByIdInstitucion(id_institucion: number) {
|
||||
return this.institucionService
|
||||
.findById(id_institucion)
|
||||
.then((institucion) => this.repository.find({ institucion }));
|
||||
}
|
||||
|
||||
findById(id_institucion_carrera: number) {
|
||||
return this.repository
|
||||
.findOne({ id_institucion_carrera })
|
||||
.then((institucionCarrera) => {
|
||||
if (!institucionCarrera)
|
||||
throw new NotFoundException('No existe esta institución carrera.');
|
||||
return institucionCarrera;
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Column, Entity, OneToMany, PrimaryGeneratedColumn } from 'typeorm';
|
||||
import { Carrera } from '../../carrera/entity/carrera.entity';
|
||||
import { InstitucionCarrera } from '../../institucion-carrera/entity/institucion-carrera.entity';
|
||||
import { InstitucionDia } from '../../institucion-dia/entity/institucion-dia.entity';
|
||||
import { InstitucionInfraccion } from '../../institucion-infraccion/entity/institucion-infraccion.entity';
|
||||
import { InstitucionTipoCarrito } from '../../institucion-tipo-carrito/entity/institucion-tipo-carrito.entity';
|
||||
@@ -18,9 +18,15 @@ export class Institucion {
|
||||
@Column({ type: String, nullable: false, length: 150 })
|
||||
institucion: string;
|
||||
|
||||
@Column({ type: String, nullable: false, length: 50 })
|
||||
@Column({ type: String, nullable: true, length: 60 })
|
||||
logo: string;
|
||||
|
||||
@Column({ type: String, nullable: true, length: 40 })
|
||||
responsable: string;
|
||||
|
||||
@Column({ type: String, nullable: true, length: 10 })
|
||||
telefono: string;
|
||||
|
||||
@Column({ type: Number, nullable: false, default: 15 })
|
||||
tiempo_entrega: number;
|
||||
|
||||
@@ -30,8 +36,11 @@ export class Institucion {
|
||||
@Column({ type: Number, nullable: false, default: 10 })
|
||||
tiempo_recoger: number;
|
||||
|
||||
@OneToMany(() => Carrera, (carrera) => carrera.institucion)
|
||||
carreras: Carrera[];
|
||||
@Column({ type: String, nullable: true, length: 60 })
|
||||
ubicacion: string;
|
||||
|
||||
@OneToMany(() => InstitucionCarrera, (carrera) => carrera.institucion)
|
||||
carreras: InstitucionCarrera[];
|
||||
|
||||
@OneToMany(
|
||||
() => InstitucionDia,
|
||||
|
||||
@@ -71,10 +71,10 @@ export class UploadFileService {
|
||||
.findByCarrera(usuarios[i].carrera, false)
|
||||
.then((carrera) => {
|
||||
if (!carrera)
|
||||
return this.carreraService.create(
|
||||
institucion.id_institucion,
|
||||
usuarios[i].carrera,
|
||||
);
|
||||
// return this.carreraService.create(
|
||||
// institucion.id_institucion,
|
||||
// usuarios[i].carrera,
|
||||
// );
|
||||
return carrera;
|
||||
})
|
||||
: null;
|
||||
@@ -109,7 +109,7 @@ export class UploadFileService {
|
||||
};
|
||||
|
||||
if (carrera) data.carrera = carrera;
|
||||
await this.usuarioService.update(data).then((usuarioUpdated) => {});
|
||||
// await this.usuarioService.update(data).then((usuarioUpdated) => {});
|
||||
} else
|
||||
await this.usuarioService
|
||||
.create(
|
||||
|
||||
@@ -6,7 +6,7 @@ import {
|
||||
OneToMany,
|
||||
PrimaryGeneratedColumn,
|
||||
} from 'typeorm';
|
||||
import { Carrera } from '../../carrera/entity/carrera.entity';
|
||||
import { InstitucionCarrera } from '../../institucion-carrera/entity/institucion-carrera.entity';
|
||||
import { Institucion } from '../../institucion/entity/institucion.entity';
|
||||
import { Prestamo } from '../../prestamo/entity/prestamo.entity';
|
||||
import { TipoUsuario } from '../../tipo-usuario/entity/tipo-usuario.entity';
|
||||
@@ -34,9 +34,9 @@ export class Usuario {
|
||||
@Column({ type: String, nullable: false, length: 10 })
|
||||
usuario: string;
|
||||
|
||||
@ManyToOne(() => Carrera, (carrera) => carrera.usuarios)
|
||||
@JoinColumn({ name: 'id_carrera' })
|
||||
carrera: Carrera;
|
||||
@ManyToOne(() => InstitucionCarrera, (institucionCarrera) => institucionCarrera.usuarios)
|
||||
@JoinColumn({ name: 'id_institucion_carrera' })
|
||||
carrera: InstitucionCarrera;
|
||||
|
||||
@ManyToOne(() => Institucion, (institucion) => institucion.usuarios)
|
||||
@JoinColumn({ name: 'id_institucion' })
|
||||
|
||||
@@ -8,6 +8,7 @@ import { BcryptModule } from '../bcrypt/bcrypt.module';
|
||||
import { CarreraModule } from '../carrera/carrera.module';
|
||||
import { NodemailerModule } from '../nodemailer/nodemailer.module';
|
||||
import { InstitucionModule } from '../institucion/institucion.module';
|
||||
import { InstitucionCarreraModule } from 'src/institucion-carrera/institucion-carrera.module';
|
||||
import { TipoUsuarioModule } from '../tipo-usuario/tipo-usuario.module';
|
||||
|
||||
@Module({
|
||||
@@ -15,6 +16,7 @@ import { TipoUsuarioModule } from '../tipo-usuario/tipo-usuario.module';
|
||||
BcryptModule,
|
||||
CarreraModule,
|
||||
InstitucionModule,
|
||||
InstitucionCarreraModule,
|
||||
NodemailerModule,
|
||||
PassportModule.register({ defaultStrategy: 'jwt' }),
|
||||
TipoUsuarioModule,
|
||||
|
||||
@@ -6,11 +6,13 @@ import {
|
||||
import { InjectRepository } from '@nestjs/typeorm';
|
||||
import { Repository } from 'typeorm';
|
||||
import { Carrera } from '../carrera/entity/carrera.entity';
|
||||
import { InstitucionCarrera } from '../institucion-carrera/entity/institucion-carrera.entity';
|
||||
import { Institucion } from '../institucion/entity/institucion.entity';
|
||||
import { TipoUsuario } from '../tipo-usuario/entity/tipo-usuario.entity';
|
||||
import { Usuario } from './entity/usuario.entity';
|
||||
import { BcryptService } from '../bcrypt/bcrypt.service';
|
||||
import { CarreraService } from '../carrera/carrera.service';
|
||||
import { InstitucionCarreraService } from '../institucion-carrera/institucion-carrera.service';
|
||||
import { InstitucionService } from '../institucion/institucion.service';
|
||||
import { NodemailerService } from '../nodemailer/nodemailer.service';
|
||||
import { TipoUsuarioService } from '../tipo-usuario/tipo-usuario.service';
|
||||
@@ -22,6 +24,7 @@ export class UsuarioService {
|
||||
private bcryptService: BcryptService,
|
||||
private carreraService: CarreraService,
|
||||
private institucionService: InstitucionService,
|
||||
private InstitucionCarreraService: InstitucionCarreraService,
|
||||
private nodemailerService: NodemailerService,
|
||||
private tipoUsuarioService: TipoUsuarioService,
|
||||
) {}
|
||||
@@ -30,15 +33,15 @@ export class UsuarioService {
|
||||
usuario: string,
|
||||
id_institucion: number,
|
||||
id_tipo_usuario: number,
|
||||
id_carrera?: number,
|
||||
id_institucion_carrera?: number,
|
||||
) {
|
||||
const carrera = id_carrera
|
||||
? await this.carreraService.findById(id_carrera)
|
||||
const carrera = id_institucion_carrera
|
||||
? await this.InstitucionCarreraService.findById(id_institucion_carrera)
|
||||
: null;
|
||||
const institucion = await this.institucionService.findById(id_institucion);
|
||||
const tipoUsuario = await this.tipoUsuarioService.findById(id_tipo_usuario);
|
||||
const data: {
|
||||
carrera?: Carrera;
|
||||
carrera?: InstitucionCarrera;
|
||||
institucion: Institucion;
|
||||
tipoUsuario: TipoUsuario;
|
||||
} = { institucion, tipoUsuario };
|
||||
@@ -51,7 +54,7 @@ export class UsuarioService {
|
||||
return this.repository.save(this.repository.create(data));
|
||||
})
|
||||
.then((usuario) => ({
|
||||
message: `Se creo correctamente el usuairo ${usuario.usuario}`,
|
||||
message: `Se creo correctamente el usuario ${usuario.usuario}`,
|
||||
}));
|
||||
}
|
||||
|
||||
@@ -85,7 +88,7 @@ export class UsuarioService {
|
||||
usuario?: string;
|
||||
}) {
|
||||
const busqueda: {
|
||||
carrera?: Carrera;
|
||||
// carrera?: Carrera;
|
||||
institucion?: Institucion;
|
||||
tipoUsuario?: TipoUsuario;
|
||||
usuario?: string;
|
||||
@@ -104,7 +107,7 @@ export class UsuarioService {
|
||||
if (filtros.usuario) busqueda.usuario = filtros.usuario;
|
||||
if (institucion) busqueda.institucion = institucion;
|
||||
if (tipoUsuario) busqueda.tipoUsuario = tipoUsuario;
|
||||
if (carrera) busqueda.carrera = carrera;
|
||||
// if (carrera) busqueda.carrera = carrera;
|
||||
/* falta página, paginado */
|
||||
return this.repository.find(busqueda);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user