Jerarquía física definitiva, compatibilidades N↔N de clasificaciones, Hallazgos y campos técnicos por familia, navegación WEB/Android y APK F6 0.14.0-debug.
103 lines
3.2 KiB
TypeScript
103 lines
3.2 KiB
TypeScript
import {
|
|
Body,
|
|
Controller,
|
|
Get,
|
|
Param,
|
|
ParseUUIDPipe,
|
|
Patch,
|
|
Post,
|
|
Put,
|
|
Req,
|
|
} from '@nestjs/common';
|
|
import { CurrentAuth } from '../auth/decorators/current-auth.decorator';
|
|
import { RequirePermissions } from '../authorization/decorators/require-permissions.decorator';
|
|
import type { AuthPrincipal, RequestWithContext } from '../common/http/request-context';
|
|
import {
|
|
CreateInventoryFamilyDto,
|
|
ReplaceInventoryFamilyFindingsDto,
|
|
UpdateInventoryFamilyDto,
|
|
} from './dto/inventory-family-admin.dto';
|
|
import {
|
|
CreateInventoryFamilyAttributeDto,
|
|
UpdateInventoryFamilyAttributeDto,
|
|
} from './dto/inventory-family-attribute.dto';
|
|
import { InventoryFamilyCatalogService } from './inventory-family-catalog.service';
|
|
|
|
@Controller('inventory-families')
|
|
export class InventoryFamilyCatalogController {
|
|
constructor(private readonly families: InventoryFamilyCatalogService) {}
|
|
|
|
@Get('admin')
|
|
@RequirePermissions('asset_types.read')
|
|
admin() {
|
|
return this.families.listAdmin();
|
|
}
|
|
|
|
@Post()
|
|
@RequirePermissions('asset_types.manage')
|
|
create(
|
|
@Body() dto: CreateInventoryFamilyDto,
|
|
@CurrentAuth() principal: AuthPrincipal,
|
|
@Req() request: RequestWithContext,
|
|
) {
|
|
return this.families.create(dto,principal,request);
|
|
}
|
|
|
|
@Patch(':familyId')
|
|
@RequirePermissions('asset_types.manage')
|
|
update(
|
|
@Param('familyId',new ParseUUIDPipe({version:'4'})) familyId:string,
|
|
@Body() dto:UpdateInventoryFamilyDto,
|
|
@CurrentAuth() principal:AuthPrincipal,
|
|
@Req() request:RequestWithContext,
|
|
) {
|
|
return this.families.update(familyId,dto,principal,request);
|
|
}
|
|
|
|
@Get(':familyId/attributes')
|
|
@RequirePermissions('asset_types.read')
|
|
attributes(@Param('familyId',new ParseUUIDPipe({version:'4'})) familyId:string) {
|
|
return this.families.attributes(familyId);
|
|
}
|
|
|
|
@Post(':familyId/attributes')
|
|
@RequirePermissions('asset_types.manage')
|
|
createAttribute(
|
|
@Param('familyId',new ParseUUIDPipe({version:'4'})) familyId:string,
|
|
@Body() dto:CreateInventoryFamilyAttributeDto,
|
|
@CurrentAuth() principal:AuthPrincipal,
|
|
@Req() request:RequestWithContext,
|
|
) {
|
|
return this.families.createAttribute(familyId,dto,principal,request);
|
|
}
|
|
|
|
@Patch(':familyId/attributes/:attributeId')
|
|
@RequirePermissions('asset_types.manage')
|
|
updateAttribute(
|
|
@Param('familyId',new ParseUUIDPipe({version:'4'})) familyId:string,
|
|
@Param('attributeId',new ParseUUIDPipe({version:'4'})) attributeId:string,
|
|
@Body() dto:UpdateInventoryFamilyAttributeDto,
|
|
@CurrentAuth() principal:AuthPrincipal,
|
|
@Req() request:RequestWithContext,
|
|
) {
|
|
return this.families.updateAttribute(familyId,attributeId,dto,principal,request);
|
|
}
|
|
|
|
@Put(':familyId/findings')
|
|
@RequirePermissions('finding_catalog.manage')
|
|
replaceFindings(
|
|
@Param('familyId',new ParseUUIDPipe({version:'4'})) familyId:string,
|
|
@Body() dto:ReplaceInventoryFamilyFindingsDto,
|
|
@CurrentAuth() principal:AuthPrincipal,
|
|
@Req() request:RequestWithContext,
|
|
) {
|
|
return this.families.replaceFindings(familyId,dto,principal,request);
|
|
}
|
|
|
|
@Get(':familyId/findings')
|
|
@RequirePermissions('assets.read')
|
|
findings(@Param('familyId', new ParseUUIDPipe({ version: '4' })) familyId: string) {
|
|
return this.families.findings(familyId);
|
|
}
|
|
}
|