new ep actualizar area
This commit is contained in:
@@ -1,27 +1,35 @@
|
|||||||
import { IsInt, IsNotEmpty, IsOptional, IsString } from "class-validator";
|
import { IsBoolean, IsInt, IsNotEmpty, IsOptional, IsString } from "class-validator";
|
||||||
|
|
||||||
export class CreateEquipoDto {
|
export class CreateEquipoDto {
|
||||||
@IsInt()
|
@IsInt()
|
||||||
@IsNotEmpty()
|
@IsNotEmpty()
|
||||||
id_area_ubicacion: number;
|
id_area_ubicacion: number;
|
||||||
|
|
||||||
@IsInt()
|
@IsInt()
|
||||||
@IsOptional()
|
@IsOptional()
|
||||||
id_equipo: number;
|
id_equipo: number;
|
||||||
|
|
||||||
@IsInt()
|
@IsInt()
|
||||||
@IsNotEmpty()
|
@IsNotEmpty()
|
||||||
id_plataforma: number;
|
id_plataforma: number;
|
||||||
|
|
||||||
@IsString()
|
@IsString()
|
||||||
@IsOptional()
|
@IsOptional()
|
||||||
ip: string;
|
ip: string;
|
||||||
|
|
||||||
@IsString()
|
@IsString()
|
||||||
@IsNotEmpty()
|
@IsNotEmpty()
|
||||||
nombre_equipo: string;
|
nombre_equipo: string;
|
||||||
|
|
||||||
@IsString()
|
@IsString()
|
||||||
@IsNotEmpty()
|
@IsNotEmpty()
|
||||||
ubicacion: string;
|
ubicacion: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export class UpdateAreaEquiposDto {
|
||||||
|
@IsInt()
|
||||||
|
id_area_ubicacion: number;
|
||||||
|
|
||||||
|
@IsBoolean()
|
||||||
|
activo: boolean;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { Body, Controller, Get, Param, Patch, Post } from '@nestjs/common';
|
import { Body, Controller, Get, Param, Patch, Post } from '@nestjs/common';
|
||||||
import { EquipoService } from './equipo.service';
|
import { EquipoService } from './equipo.service';
|
||||||
import { Equipo } from './entities/equipo.entity';
|
import { Equipo } from './entities/equipo.entity';
|
||||||
import { CreateEquipoDto } from './dto/create-equipo.dto';
|
import { CreateEquipoDto, UpdateAreaEquiposDto } from './dto/create-equipo.dto';
|
||||||
|
|
||||||
@Controller('equipo')
|
@Controller('equipo')
|
||||||
export class EquipoController {
|
export class EquipoController {
|
||||||
@@ -51,5 +51,18 @@ export class EquipoController {
|
|||||||
toggleActivo(@Param('id') id: number) {
|
toggleActivo(@Param('id') id: number) {
|
||||||
return this.equipoService.toggleActivo(+id);
|
return this.equipoService.toggleActivo(+id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Patch('actualizar-area')
|
||||||
|
actualizarPorArea(
|
||||||
|
@Body() updateAreaEquiposDto: UpdateAreaEquiposDto,
|
||||||
|
) {
|
||||||
|
const { id_area_ubicacion, activo } = updateAreaEquiposDto;
|
||||||
|
|
||||||
|
return this.equipoService.actualizarEquiposPorArea(
|
||||||
|
id_area_ubicacion,
|
||||||
|
activo,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
//IO
|
//IO
|
||||||
|
|||||||
@@ -204,5 +204,21 @@ export class EquipoService {
|
|||||||
activo: nuevoActivo,
|
activo: nuevoActivo,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async actualizarEquiposPorArea(
|
||||||
|
id_area_ubicacion: number,
|
||||||
|
activo: boolean,
|
||||||
|
) {
|
||||||
|
const result = await this.equipoRepository.update(
|
||||||
|
{ id_area_ubicacion },
|
||||||
|
{ activo },
|
||||||
|
);
|
||||||
|
|
||||||
|
return {
|
||||||
|
message: 'Equipos actualizados correctamente',
|
||||||
|
affected: result.affected,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
//IO
|
//IO
|
||||||
|
|||||||
Reference in New Issue
Block a user