marca y modelo arreglado
This commit is contained in:
@@ -27,13 +27,13 @@ export class EquiposDto {
|
||||
@IsOptional()
|
||||
id_institucion?: string;
|
||||
|
||||
// @IsInt()
|
||||
// @IsOptional()
|
||||
// id_marca?: number;
|
||||
@IsNumberString()
|
||||
@IsOptional()
|
||||
id_marca?: string;
|
||||
|
||||
// @IsInt()
|
||||
// @IsOptional()
|
||||
// id_modelo?: number;
|
||||
@IsNumberString()
|
||||
@IsOptional()
|
||||
id_modelo?: string;
|
||||
|
||||
@IsNumberString()
|
||||
@IsOptional()
|
||||
|
||||
@@ -1,4 +1,10 @@
|
||||
import { IsInt, IsNotEmpty, IsOptional, IsString, MaxLength } from 'class-validator';
|
||||
import {
|
||||
IsInt,
|
||||
IsNotEmpty,
|
||||
IsOptional,
|
||||
IsString,
|
||||
MaxLength,
|
||||
} from 'class-validator';
|
||||
|
||||
export class UpdateEquipoDto {
|
||||
@IsInt()
|
||||
@@ -29,14 +35,6 @@ export class UpdateEquipoDto {
|
||||
@IsOptional()
|
||||
id_status?: number;
|
||||
|
||||
@IsString()
|
||||
@IsOptional()
|
||||
marca?: string;
|
||||
|
||||
@IsString()
|
||||
@IsOptional()
|
||||
modelo?: string;
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
@MaxLength(250)
|
||||
|
||||
@@ -13,14 +13,6 @@ export class EquipoOutputDto {
|
||||
@Expose()
|
||||
equipo;
|
||||
|
||||
@Expose()
|
||||
// @Type(() => MarcaOutputDto)
|
||||
marca;
|
||||
|
||||
@Expose()
|
||||
// @Type(() => ModeloOutputDto)
|
||||
modelo;
|
||||
|
||||
@Expose()
|
||||
numero_inventario;
|
||||
|
||||
@@ -31,6 +23,14 @@ export class EquipoOutputDto {
|
||||
@Type(() => CarritoMinOutputDto)
|
||||
carrito;
|
||||
|
||||
@Expose()
|
||||
@Type(() => MarcaOutputDto)
|
||||
marca;
|
||||
|
||||
@Expose()
|
||||
@Type(() => ModeloOutputDto)
|
||||
modelo;
|
||||
|
||||
@Expose()
|
||||
@Type(() => EquipoProgramaOutputDto)
|
||||
programas;
|
||||
|
||||
@@ -23,12 +23,6 @@ export class Equipo {
|
||||
@Column({ type: String, nullable: false, length: 4 })
|
||||
equipo: string;
|
||||
|
||||
@Column({ type: String, nullable: false, length: 30 })
|
||||
marca: string;
|
||||
|
||||
@Column({ type: String, nullable: false, length: 30 })
|
||||
modelo: string;
|
||||
|
||||
@Column({ type: String, nullable: false, length: 30 })
|
||||
numero_inventario: string;
|
||||
|
||||
@@ -42,13 +36,13 @@ export class Equipo {
|
||||
@JoinColumn({ name: 'id_carrito' })
|
||||
carrito: Carrito;
|
||||
|
||||
// @ManyToOne(() => Marca, (marca) => marca.equipos, { eager: true })
|
||||
// @JoinColumn({ name: 'id_marca' })
|
||||
// marca: Marca;
|
||||
@ManyToOne(() => Marca, (marca) => marca.equipos, { eager: true })
|
||||
@JoinColumn({ name: 'id_marca' })
|
||||
marca: Marca;
|
||||
|
||||
// @ManyToOne(() => Modelo, (modelo) => modelo.equipos, { eager: true })
|
||||
// @JoinColumn({ name: 'id_modelo' })
|
||||
// modelo: Modelo;
|
||||
@ManyToOne(() => Modelo, (modelo) => modelo.equipos, { eager: true })
|
||||
@JoinColumn({ name: 'id_modelo' })
|
||||
modelo: Modelo;
|
||||
|
||||
@ManyToOne(() => Status, (status) => status.equipos, { eager: true })
|
||||
@JoinColumn({ name: 'id_status' })
|
||||
|
||||
@@ -82,18 +82,18 @@ export class EquipoController {
|
||||
type: 'string',
|
||||
required: false,
|
||||
})
|
||||
// @ApiQuery({
|
||||
// description: 'Id de la marca que se quiere usar como filtro.',
|
||||
// name: 'id_marca',
|
||||
// type: 'string',
|
||||
// required: false,
|
||||
// })
|
||||
// @ApiQuery({
|
||||
// description: 'Id del modelo que se quiere usar como filtro.',
|
||||
// name: 'id_modelo',
|
||||
// type: 'string',
|
||||
// required: false,
|
||||
// })
|
||||
@ApiQuery({
|
||||
description: 'Id de la marca que se quiere usar como filtro.',
|
||||
name: 'id_marca',
|
||||
type: 'string',
|
||||
required: false,
|
||||
})
|
||||
@ApiQuery({
|
||||
description: 'Id del modelo que se quiere usar como filtro.',
|
||||
name: 'id_modelo',
|
||||
type: 'string',
|
||||
required: false,
|
||||
})
|
||||
@ApiQuery({
|
||||
description: 'Id del módulo que se quiere usar como filtro.',
|
||||
name: 'id_modulo',
|
||||
@@ -147,8 +147,6 @@ export class EquipoController {
|
||||
// _id_modelo: '',
|
||||
_id_operador: 1,
|
||||
_id_status: 1,
|
||||
_marca: '',
|
||||
_modelo: '',
|
||||
_motivo: '',
|
||||
},
|
||||
},
|
||||
|
||||
@@ -10,8 +10,8 @@ import { Repository } from 'typeorm';
|
||||
import { Carrito } from '../carrito/entity/carrito.entity';
|
||||
import { Equipo } from './entity/equipo.entity';
|
||||
import { Institucion } from '../institucion/entity/institucion.entity';
|
||||
// import { Marca } from '../marca/entity/marca.entity';
|
||||
// import { Modelo } from '../modelo/entity/modelo.entity';
|
||||
import { Marca } from '../marca/entity/marca.entity';
|
||||
import { Modelo } from '../modelo/entity/modelo.entity';
|
||||
import { Modulo } from '../modulo/entity/modulo.entity';
|
||||
import { Operador } from '../operador/entity/operador.entity';
|
||||
import { Programa } from '../institucion-programa/entity/programa.entity';
|
||||
@@ -55,8 +55,8 @@ export class EquipoService {
|
||||
equipo: string,
|
||||
numero_inventario: string,
|
||||
numero_serie: string,
|
||||
marca: string, // Marca,
|
||||
modelo: string, // Modelo,
|
||||
marca: Marca,
|
||||
modelo: Modelo,
|
||||
) {
|
||||
const activo = await this.statusService.findById(1);
|
||||
const equipoNuevo = await this.repository.save(
|
||||
@@ -96,12 +96,12 @@ export class EquipoService {
|
||||
const institucion = filtros.id_institucion
|
||||
? await this.institucionService.findById(parseInt(filtros.id_institucion))
|
||||
: null;
|
||||
// const marca = filtros.id_marca
|
||||
// ? await this.marcaService.findById(parseInt(filtros.id_marca))
|
||||
// : null;
|
||||
// const modelo = filtros.id_modelo
|
||||
// ? await this.modeloService.findById(parseInt(filtros.id_modelo))
|
||||
// : null;
|
||||
const marca = filtros.id_marca
|
||||
? await this.marcaService.findById(parseInt(filtros.id_marca), 'e')
|
||||
: null;
|
||||
const modelo = filtros.id_modelo
|
||||
? await this.modeloService.findById(parseInt(filtros.id_modelo), 'e')
|
||||
: null;
|
||||
const modulo = filtros.id_modulo
|
||||
? await this.moduloService.findById(parseInt(filtros.id_modulo))
|
||||
: null;
|
||||
@@ -126,6 +126,8 @@ export class EquipoService {
|
||||
const query = this.repository
|
||||
.createQueryBuilder('e')
|
||||
.innerJoinAndSelect('e.carrito', 'c')
|
||||
.innerJoinAndSelect('e.marca', 'ma')
|
||||
.innerJoinAndSelect('e.modelo', 'mo')
|
||||
.innerJoinAndSelect('e.programas', 'ps')
|
||||
.innerJoinAndSelect('e.status', 's')
|
||||
.innerJoinAndSelect('e.tiposEntradas', 'tes')
|
||||
@@ -154,14 +156,14 @@ export class EquipoService {
|
||||
query.andWhere('m.id_institucion = :id_institucion', {
|
||||
id_institucion: institucion.id_institucion,
|
||||
});
|
||||
// if (marca)
|
||||
// query.andWhere('m.id_marca = :id_marca', {
|
||||
// id_marca: marca.id_marca,
|
||||
// });
|
||||
// if (modelo)
|
||||
// query.andWhere('m.id_modelo = :id_modelo', {
|
||||
// id_modelo: modelo.id_modelo,
|
||||
// });
|
||||
if (marca)
|
||||
query.andWhere('ma.id_marca = :id_marca', {
|
||||
id_marca: marca.id_marca,
|
||||
});
|
||||
if (modelo)
|
||||
query.andWhere('mo.id_modelo = :id_modelo', {
|
||||
id_modelo: modelo.id_modelo,
|
||||
});
|
||||
if (modulo)
|
||||
query.andWhere('m.id_modulo = :id_modulo', {
|
||||
id_modulo: modulo.id_modulo,
|
||||
|
||||
Reference in New Issue
Block a user