52 lines
1.8 KiB
TypeScript
52 lines
1.8 KiB
TypeScript
import { Body, Controller, Get, Param, Post, Query, 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 { CreateInventoryStructureDto } from './dto/create-inventory-structure.dto';
|
|
import { InventoryStructureService } from './inventory-structure.service';
|
|
import { SimpleInventoryStructureService } from './simple-inventory-structure.service';
|
|
|
|
@Controller('inventory-structure')
|
|
export class InventoryStructureController {
|
|
constructor(
|
|
private readonly inventoryStructure: InventoryStructureService,
|
|
private readonly simpleInventoryStructure: SimpleInventoryStructureService,
|
|
) {}
|
|
|
|
@Get()
|
|
@RequirePermissions('assets.read')
|
|
options() {
|
|
return this.inventoryStructure.options();
|
|
}
|
|
|
|
@Get('parents/:kind')
|
|
@RequirePermissions('assets.read')
|
|
parents(
|
|
@Param('kind') kind: string,
|
|
@Query('search') search?: string,
|
|
) {
|
|
return this.inventoryStructure.parents(kind, search);
|
|
}
|
|
|
|
@Post('simple')
|
|
@RequirePermissions('assets.create')
|
|
createSimple(
|
|
@Body() dto: CreateInventoryStructureDto,
|
|
@CurrentAuth() principal: AuthPrincipal,
|
|
@Req() request: RequestWithContext,
|
|
) {
|
|
return this.simpleInventoryStructure.create(dto, principal, request);
|
|
}
|
|
|
|
// Compatibilidad temporal con el alta anterior. La WEB F7 utiliza /simple.
|
|
@Post()
|
|
@RequirePermissions('assets.create')
|
|
create(
|
|
@Body() dto: CreateInventoryStructureDto,
|
|
@CurrentAuth() principal: AuthPrincipal,
|
|
@Req() request: RequestWithContext,
|
|
) {
|
|
return this.inventoryStructure.create(dto, principal, request);
|
|
}
|
|
}
|