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 {
|
||||
@IsInt()
|
||||
@IsNotEmpty()
|
||||
id_area_ubicacion: number;
|
||||
@IsInt()
|
||||
@IsNotEmpty()
|
||||
id_area_ubicacion: number;
|
||||
|
||||
@IsInt()
|
||||
@IsOptional()
|
||||
id_equipo: number;
|
||||
@IsInt()
|
||||
@IsOptional()
|
||||
id_equipo: number;
|
||||
|
||||
@IsInt()
|
||||
@IsNotEmpty()
|
||||
id_plataforma: number;
|
||||
@IsInt()
|
||||
@IsNotEmpty()
|
||||
id_plataforma: number;
|
||||
|
||||
@IsString()
|
||||
@IsOptional()
|
||||
ip: string;
|
||||
@IsString()
|
||||
@IsOptional()
|
||||
ip: string;
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
nombre_equipo: string;
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
nombre_equipo: string;
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
ubicacion: string;
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
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 { EquipoService } from './equipo.service';
|
||||
import { Equipo } from './entities/equipo.entity';
|
||||
import { CreateEquipoDto } from './dto/create-equipo.dto';
|
||||
import { CreateEquipoDto, UpdateAreaEquiposDto } from './dto/create-equipo.dto';
|
||||
|
||||
@Controller('equipo')
|
||||
export class EquipoController {
|
||||
@@ -51,5 +51,18 @@ export class EquipoController {
|
||||
toggleActivo(@Param('id') id: number) {
|
||||
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
|
||||
|
||||
@@ -204,5 +204,21 @@ export class EquipoService {
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user