institucion-tipo-entrada
This commit is contained in:
parent
8538dc6df4
commit
a395dd2744
@ -27,7 +27,6 @@ import { OperadorModule } from './operador/operador.module';
|
|||||||
import { PrestamoModule } from './prestamo/prestamo.module';
|
import { PrestamoModule } from './prestamo/prestamo.module';
|
||||||
import { ProgramaModule } from './programa/programa.module';
|
import { ProgramaModule } from './programa/programa.module';
|
||||||
import { StatusModule } from './status/status.module';
|
import { StatusModule } from './status/status.module';
|
||||||
import { TipoEntradaModule } from './tipo-entrada/tipo-entrada.module';
|
|
||||||
import { TipoUsuarioModule } from './tipo-usuario/tipo-usuario.module';
|
import { TipoUsuarioModule } from './tipo-usuario/tipo-usuario.module';
|
||||||
import { UploadFileModule } from './upload-file/upload-file.module';
|
import { UploadFileModule } from './upload-file/upload-file.module';
|
||||||
import { UsuarioModule } from './usuario/usuario.module';
|
import { UsuarioModule } from './usuario/usuario.module';
|
||||||
@ -57,7 +56,7 @@ import { Prestamo } from './prestamo/entity/prestamo.entity';
|
|||||||
import { Programa } from './programa/entity/programa.entity';
|
import { Programa } from './programa/entity/programa.entity';
|
||||||
import { Status } from './status/entity/status.entity';
|
import { Status } from './status/entity/status.entity';
|
||||||
import { TipoCarrito } from './institucion-tipo-carrito/entity/tipo-carrito.entity';
|
import { TipoCarrito } from './institucion-tipo-carrito/entity/tipo-carrito.entity';
|
||||||
import { TipoEntrada } from './tipo-entrada/entity/tipo-entrada.entity';
|
import { TipoEntrada } from './institucion-tipo-entrada/entity/tipo-entrada.entity';
|
||||||
import { TipoUsuario } from './tipo-usuario/entity/tipo-usuario.entity';
|
import { TipoUsuario } from './tipo-usuario/entity/tipo-usuario.entity';
|
||||||
import { Usuario } from './usuario/entity/usuario.entity';
|
import { Usuario } from './usuario/entity/usuario.entity';
|
||||||
import { SoapClientModule } from './soap-client/soap-client.module';
|
import { SoapClientModule } from './soap-client/soap-client.module';
|
||||||
@ -133,7 +132,6 @@ import { SoapClientModule } from './soap-client/soap-client.module';
|
|||||||
PrestamoModule,
|
PrestamoModule,
|
||||||
ProgramaModule,
|
ProgramaModule,
|
||||||
StatusModule,
|
StatusModule,
|
||||||
TipoEntradaModule,
|
|
||||||
TipoUsuarioModule,
|
TipoUsuarioModule,
|
||||||
UploadFileModule,
|
UploadFileModule,
|
||||||
UsuarioModule,
|
UsuarioModule,
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { Entity, JoinColumn, ManyToOne, PrimaryGeneratedColumn } from 'typeorm';
|
import { Entity, JoinColumn, ManyToOne, PrimaryGeneratedColumn } from 'typeorm';
|
||||||
import { Equipo } from './equipo.entity';
|
import { Equipo } from './equipo.entity';
|
||||||
import { TipoEntrada } from '../../tipo-entrada/entity/tipo-entrada.entity';
|
import { TipoEntrada } from '../../institucion-tipo-entrada/entity/tipo-entrada.entity';
|
||||||
|
|
||||||
@Entity()
|
@Entity()
|
||||||
export class EquipoTipoEntrada {
|
export class EquipoTipoEntrada {
|
||||||
|
@ -15,7 +15,7 @@ export class InstitucionDiaController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Get('dias')
|
@Get('dias')
|
||||||
institucionesDias(@Query() query: IdInstitucionDto) {
|
dias(@Query() query: IdInstitucionDto) {
|
||||||
return this.institucionDiaService.findAllByIdInstitucion(
|
return this.institucionDiaService.findAllByIdInstitucion(
|
||||||
parseInt(query.id_institucion),
|
parseInt(query.id_institucion),
|
||||||
);
|
);
|
||||||
|
@ -23,7 +23,7 @@ export class InstitucionInfraccionController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Get('infracciones')
|
@Get('infracciones')
|
||||||
institucionInfracciones(@Query() query: IdInstitucionDto) {
|
infracciones(@Query() query: IdInstitucionDto) {
|
||||||
return this.institucionInfraccionService.findAllByIdInstitucion(
|
return this.institucionInfraccionService.findAllByIdInstitucion(
|
||||||
parseInt(query.id_institucion),
|
parseInt(query.id_institucion),
|
||||||
);
|
);
|
||||||
|
@ -25,15 +25,15 @@ export class InstitucionTipoCarritoController {
|
|||||||
return this.institucionTipoCarritoService.findAll();
|
return this.institucionTipoCarritoService.findAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Get('tipos_carritos')
|
@Get('tipos-carrito')
|
||||||
institucionTiposCarritos(@Query() query: IdInstitucionDto) {
|
tiposCarrito(@Query() query: IdInstitucionDto) {
|
||||||
return this.institucionTipoCarritoService.findAllByIdInstitucion(
|
return this.institucionTipoCarritoService.findAllByIdInstitucion(
|
||||||
parseInt(query.id_institucion),
|
parseInt(query.id_institucion),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Get('tipos_carritos_mostar')
|
@Get('tipos-carrito-mostar')
|
||||||
institucionTiposCarritosMostrar(@Query() query: IdInstitucionDto) {
|
tiposCarritoMostrar(@Query() query: IdInstitucionDto) {
|
||||||
return this.institucionTipoCarritoService.findAllByIdInstitucionMostar(
|
return this.institucionTipoCarritoService.findAllByIdInstitucionMostar(
|
||||||
parseInt(query.id_institucion),
|
parseInt(query.id_institucion),
|
||||||
);
|
);
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { IsString } from 'class-validator';
|
import { IsString } from 'class-validator';
|
||||||
|
|
||||||
export class TipoEntradaCreateDto {
|
export class InstitucionTipoEntradaCreateDto {
|
||||||
@IsString()
|
@IsString()
|
||||||
tipo_entrada: string;
|
tipo_entrada: string;
|
||||||
}
|
}
|
@ -6,7 +6,7 @@ import {
|
|||||||
PrimaryGeneratedColumn,
|
PrimaryGeneratedColumn,
|
||||||
} from 'typeorm';
|
} from 'typeorm';
|
||||||
import { Institucion } from '../../institucion/entity/institucion.entity';
|
import { Institucion } from '../../institucion/entity/institucion.entity';
|
||||||
import { TipoEntrada } from '../../tipo-entrada/entity/tipo-entrada.entity';
|
import { TipoEntrada } from './tipo-entrada.entity';
|
||||||
|
|
||||||
@Entity()
|
@Entity()
|
||||||
export class InstitucionTipoEntrada {
|
export class InstitucionTipoEntrada {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { Column, Entity, OneToMany, PrimaryGeneratedColumn } from 'typeorm';
|
import { Column, Entity, OneToMany, PrimaryGeneratedColumn } from 'typeorm';
|
||||||
import { EquipoTipoEntrada } from '../../equipo/entity/equipo-tipo-entrada.entity';
|
import { EquipoTipoEntrada } from '../../equipo/entity/equipo-tipo-entrada.entity';
|
||||||
import { InstitucionTipoEntrada } from '../../institucion-tipo-entrada/entity/institucion-tipo-entrada.entity';
|
import { InstitucionTipoEntrada } from './institucion-tipo-entrada.entity';
|
||||||
|
|
||||||
@Entity()
|
@Entity()
|
||||||
export class TipoEntrada {
|
export class TipoEntrada {
|
@ -1,4 +1,35 @@
|
|||||||
import { Controller } from '@nestjs/common';
|
import { Body, Controller, Get, Post, Query } from '@nestjs/common';
|
||||||
|
import { ApiTags } from '@nestjs/swagger';
|
||||||
|
import { InstitucionTipoEntradaService } from './institucion-tipo-entrada.service';
|
||||||
|
import { IdInstitucionDto } from 'src/dto/id-institucion.dto';
|
||||||
|
import { InstitucionTipoEntradaCreateDto } from './dto/institucion-tipo-entrada-create.dto';
|
||||||
|
|
||||||
@Controller('institucion-tipo-entrada')
|
@Controller('institucion-tipo-entrada')
|
||||||
export class InstitucionTipoEntradaController {}
|
@ApiTags('institucion-tipo-entrada')
|
||||||
|
export class InstitucionTipoEntradaController {
|
||||||
|
constructor(private tipoEntradaService: InstitucionTipoEntradaService) {}
|
||||||
|
|
||||||
|
@Post()
|
||||||
|
create(@Body() body: InstitucionTipoEntradaCreateDto) {
|
||||||
|
return this.tipoEntradaService.create(body.tipo_entrada);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Get()
|
||||||
|
get() {
|
||||||
|
return this.tipoEntradaService.findAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Get('tipos-entrada')
|
||||||
|
tiposEntrada(@Query() query: IdInstitucionDto) {
|
||||||
|
return this.tipoEntradaService.findAllByIdInstitucion(
|
||||||
|
parseInt(query.id_institucion),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Get('tipos-entrada-mostrar')
|
||||||
|
tipoEntradaMostrar(@Query() query: IdInstitucionDto) {
|
||||||
|
return this.tipoEntradaService.findAllByIdInstitucionMostrar(
|
||||||
|
parseInt(query.id_institucion),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -2,10 +2,15 @@ import { Module } from '@nestjs/common';
|
|||||||
import { TypeOrmModule } from '@nestjs/typeorm';
|
import { TypeOrmModule } from '@nestjs/typeorm';
|
||||||
import { InstitucionTipoEntradaController } from './institucion-tipo-entrada.controller';
|
import { InstitucionTipoEntradaController } from './institucion-tipo-entrada.controller';
|
||||||
import { InstitucionTipoEntradaService } from './institucion-tipo-entrada.service';
|
import { InstitucionTipoEntradaService } from './institucion-tipo-entrada.service';
|
||||||
|
import { InstitucionModule } from '../institucion/institucion.module';
|
||||||
import { InstitucionTipoEntrada } from './entity/institucion-tipo-entrada.entity';
|
import { InstitucionTipoEntrada } from './entity/institucion-tipo-entrada.entity';
|
||||||
|
import { TipoEntrada } from './entity/tipo-entrada.entity';
|
||||||
|
|
||||||
@Module({
|
@Module({
|
||||||
imports: [TypeOrmModule.forFeature([InstitucionTipoEntrada])],
|
imports: [
|
||||||
|
TypeOrmModule.forFeature([InstitucionTipoEntrada, TipoEntrada]),
|
||||||
|
InstitucionModule,
|
||||||
|
],
|
||||||
controllers: [InstitucionTipoEntradaController],
|
controllers: [InstitucionTipoEntradaController],
|
||||||
providers: [InstitucionTipoEntradaService],
|
providers: [InstitucionTipoEntradaService],
|
||||||
})
|
})
|
||||||
|
@ -1,12 +1,54 @@
|
|||||||
import { Injectable } from '@nestjs/common';
|
import { ConflictException, Injectable } from '@nestjs/common';
|
||||||
import { InjectRepository } from '@nestjs/typeorm';
|
import { InjectRepository } from '@nestjs/typeorm';
|
||||||
import { Repository } from 'typeorm';
|
import { Repository } from 'typeorm';
|
||||||
import { InstitucionTipoEntrada } from './entity/institucion-tipo-entrada.entity';
|
import { InstitucionTipoEntrada } from './entity/institucion-tipo-entrada.entity';
|
||||||
|
import { TipoEntrada } from './entity/tipo-entrada.entity';
|
||||||
|
import { InstitucionService } from '../institucion/institucion.service';
|
||||||
|
import { Institucion } from '../institucion/entity/institucion.entity';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class InstitucionTipoEntradaService {
|
export class InstitucionTipoEntradaService {
|
||||||
constructor(
|
constructor(
|
||||||
@InjectRepository(InstitucionTipoEntrada)
|
@InjectRepository(InstitucionTipoEntrada)
|
||||||
private repository: Repository<InstitucionTipoEntrada>,
|
private repositoryInstitucionTipoEntrada: Repository<InstitucionTipoEntrada>,
|
||||||
|
@InjectRepository(TipoEntrada)
|
||||||
|
private repositoryTipoEntrada: Repository<TipoEntrada>,
|
||||||
|
private institucionService: InstitucionService,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
|
async create(tipo_entrada: string) {
|
||||||
|
// corregir
|
||||||
|
return this.repositoryTipoEntrada
|
||||||
|
.findOne({ tipo_entrada })
|
||||||
|
.then((existeTipoEntrada) => {
|
||||||
|
if (existeTipoEntrada)
|
||||||
|
throw new ConflictException('Ya existe este tipo de entrada.');
|
||||||
|
return this.repositoryTipoEntrada.save(
|
||||||
|
this.repositoryTipoEntrada.create({
|
||||||
|
tipo_entrada,
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
})
|
||||||
|
.then(() => ({ message: 'Se creo correctamente la nueva entrada.' }));
|
||||||
|
}
|
||||||
|
|
||||||
|
findAll() {
|
||||||
|
return this.repositoryTipoEntrada.find();
|
||||||
|
}
|
||||||
|
|
||||||
|
findAllByIdInstitucion(id_institucion: number, mostrar = false) {
|
||||||
|
const busqueda: { institucion?: Institucion; mostrar?: boolean } = {};
|
||||||
|
|
||||||
|
if (mostrar) busqueda.mostrar = mostrar;
|
||||||
|
return this.institucionService
|
||||||
|
.findById(id_institucion)
|
||||||
|
.then((institucion) => {
|
||||||
|
busqueda.institucion = institucion;
|
||||||
|
return this.repositoryInstitucionTipoEntrada.find(busqueda);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
findAllByIdInstitucionMostrar(id_institucion: number) {
|
||||||
|
return this.findAllByIdInstitucion(id_institucion, true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,8 +19,8 @@ export class InstitucionController {
|
|||||||
return this.institucionService.findById(parseInt(query.id_institucion));
|
return this.institucionService.findById(parseInt(query.id_institucion));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Get('instituciones-activo')
|
@Get('activas')
|
||||||
institucionesActivo() {
|
activas() {
|
||||||
return this.institucionService.findByAllActivo();
|
return this.institucionService.findByAllActivo();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,18 +0,0 @@
|
|||||||
import { Test, TestingModule } from '@nestjs/testing';
|
|
||||||
import { TipoEntradaController } from './tipo-entrada.controller';
|
|
||||||
|
|
||||||
describe('TipoEntradaController', () => {
|
|
||||||
let controller: TipoEntradaController;
|
|
||||||
|
|
||||||
beforeEach(async () => {
|
|
||||||
const module: TestingModule = await Test.createTestingModule({
|
|
||||||
controllers: [TipoEntradaController],
|
|
||||||
}).compile();
|
|
||||||
|
|
||||||
controller = module.get<TipoEntradaController>(TipoEntradaController);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should be defined', () => {
|
|
||||||
expect(controller).toBeDefined();
|
|
||||||
});
|
|
||||||
});
|
|
@ -1,20 +0,0 @@
|
|||||||
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() {
|
|
||||||
return this.tipoEntradaService.findAll()
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,12 +0,0 @@
|
|||||||
import { Module } from '@nestjs/common';
|
|
||||||
import { TypeOrmModule } from '@nestjs/typeorm';
|
|
||||||
import { TipoEntradaController } from './tipo-entrada.controller';
|
|
||||||
import { TipoEntradaService } from './tipo-entrada.service';
|
|
||||||
import { TipoEntrada } from './entity/tipo-entrada.entity';
|
|
||||||
|
|
||||||
@Module({
|
|
||||||
imports: [TypeOrmModule.forFeature([TipoEntrada])],
|
|
||||||
controllers: [TipoEntradaController],
|
|
||||||
providers: [TipoEntradaService],
|
|
||||||
})
|
|
||||||
export class TipoEntradaModule {}
|
|
@ -1,18 +0,0 @@
|
|||||||
import { Test, TestingModule } from '@nestjs/testing';
|
|
||||||
import { TipoEntradaService } from './tipo-entrada.service';
|
|
||||||
|
|
||||||
describe('TipoEntradaService', () => {
|
|
||||||
let service: TipoEntradaService;
|
|
||||||
|
|
||||||
beforeEach(async () => {
|
|
||||||
const module: TestingModule = await Test.createTestingModule({
|
|
||||||
providers: [TipoEntradaService],
|
|
||||||
}).compile();
|
|
||||||
|
|
||||||
service = module.get<TipoEntradaService>(TipoEntradaService);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should be defined', () => {
|
|
||||||
expect(service).toBeDefined();
|
|
||||||
});
|
|
||||||
});
|
|
@ -1,28 +0,0 @@
|
|||||||
import { Injectable, ConflictException } from '@nestjs/common';
|
|
||||||
import { InjectRepository } from '@nestjs/typeorm';
|
|
||||||
import { Repository } from 'typeorm';
|
|
||||||
import { TipoEntrada } from './entity/tipo-entrada.entity';
|
|
||||||
|
|
||||||
@Injectable()
|
|
||||||
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()
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user