Avances pero hay algunos errores
This commit is contained in:
parent
6d64637423
commit
c7747af37d
@ -1,4 +1,4 @@
|
||||
import { Body, Controller, Delete, Get, Param, 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';
|
||||
|
@ -78,6 +78,7 @@ export class CarritoService {
|
||||
if (modulo) busqueda.modulo = modulo;
|
||||
if (institucionTipoCarrito) busqueda.institucionTipoCarrito = institucionTipoCarrito;
|
||||
//falta página
|
||||
|
||||
return this.repository.find(busqueda);
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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: number;
|
||||
}
|
@ -1,15 +1,21 @@
|
||||
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'
|
||||
|
||||
|
||||
@Controller('hora-excepcion')
|
||||
export class HoraExcepcionController {
|
||||
constructor(private horaExcepcionService: HoraExcepcionService) {}
|
||||
|
||||
@Post()
|
||||
create() {}
|
||||
create(@Body() body: HoraExcepcionDto) {
|
||||
return this.horaExcepcionService.create(body.id_institucion)
|
||||
}
|
||||
|
||||
@Delete()
|
||||
delete() {}
|
||||
@Delete(':id')
|
||||
delete(@Param('id') id_hora_excepcion: number) {
|
||||
return this.horaExcepcionService.delete(id_hora_excepcion)
|
||||
}
|
||||
|
||||
@Get()
|
||||
get() {}
|
||||
|
@ -1,12 +1,45 @@
|
||||
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 { InstitucionService } from '../institucion/institucion.service';
|
||||
|
||||
|
||||
@Injectable()
|
||||
export class HoraExcepcionService {
|
||||
constructor(
|
||||
@InjectRepository(HoraExcepcion)
|
||||
private repository: Repository<HoraExcepcion>,
|
||||
private institucionService: InstitucionService
|
||||
) {}
|
||||
|
||||
async create(id_institucion: number) {
|
||||
const institucion = await this.institucionService.findById(id_institucion)
|
||||
const nuevaHoraExcepcion = this.repository.create({institucion});
|
||||
|
||||
return this.repository
|
||||
.findOne({institucion})
|
||||
.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)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user