chore: import DH V2 D5.6.4 production baseline
This commit is contained in:
@@ -0,0 +1,193 @@
|
||||
import {
|
||||
Body,
|
||||
Controller,
|
||||
Get,
|
||||
Param,
|
||||
ParseUUIDPipe,
|
||||
Patch,
|
||||
Post,
|
||||
Query,
|
||||
Req,
|
||||
} from '@nestjs/common';
|
||||
import { RequirePermissions } from '../authorization/decorators/require-permissions.decorator';
|
||||
import { CurrentAuth } from '../auth/decorators/current-auth.decorator';
|
||||
import type {
|
||||
AuthPrincipal,
|
||||
RequestWithContext,
|
||||
} from '../common/http/request-context';
|
||||
import { AssetsService } from './assets.service';
|
||||
import { ChangeAssetStatusDto } from './dto/change-asset-status.dto';
|
||||
import { ChangeAssetOperationalStatusDto } from './dto/change-asset-operational-status.dto';
|
||||
import { CreateAssetDto } from './dto/create-asset.dto';
|
||||
import { CreateFieldDiscoveryDto } from './dto/create-field-discovery.dto';
|
||||
import { ListFieldDiscoveriesQueryDto } from './dto/list-field-discoveries-query.dto';
|
||||
import { MatchFieldDiscoveryDto, RejectFieldDiscoveryDto, ReviewFieldDiscoveryDto } from './dto/review-field-discovery.dto';
|
||||
import { ListAssetsQueryDto } from './dto/list-assets-query.dto';
|
||||
import { ListAssetTreeQueryDto } from './dto/list-asset-tree-query.dto';
|
||||
import { ListAssetTreeChildrenQueryDto } from './dto/list-asset-tree-children-query.dto';
|
||||
import { ParentOptionsQueryDto } from './dto/parent-options-query.dto';
|
||||
import { UpdateAssetDto } from './dto/update-asset.dto';
|
||||
import { ChangeAssetContextDto } from './dto/change-asset-context.dto';
|
||||
|
||||
@Controller('assets')
|
||||
export class AssetsController {
|
||||
constructor(private readonly assets: AssetsService) {}
|
||||
|
||||
@Get()
|
||||
@RequirePermissions('assets.read')
|
||||
list(@Query() query: ListAssetsQueryDto) {
|
||||
return this.assets.list(query);
|
||||
}
|
||||
|
||||
@Get('field-discoveries')
|
||||
@RequirePermissions('assets.read')
|
||||
listFieldDiscoveries(@Query() query: ListFieldDiscoveriesQueryDto) {
|
||||
return this.assets.listFieldDiscoveries(query);
|
||||
}
|
||||
|
||||
@Post('field-discoveries')
|
||||
@RequirePermissions('assets.create')
|
||||
createFieldDiscovery(
|
||||
@Body() dto: CreateFieldDiscoveryDto,
|
||||
@CurrentAuth() principal: AuthPrincipal,
|
||||
@Req() request: RequestWithContext,
|
||||
) {
|
||||
return this.assets.createFieldDiscovery(dto, principal, request);
|
||||
}
|
||||
|
||||
@Post('field-discoveries/:id/approve')
|
||||
@RequirePermissions('assets.change_status')
|
||||
approveFieldDiscovery(
|
||||
@Param('id', new ParseUUIDPipe({ version: '4' })) id: string,
|
||||
@Body() dto: ReviewFieldDiscoveryDto,
|
||||
@CurrentAuth() principal: AuthPrincipal,
|
||||
@Req() request: RequestWithContext,
|
||||
) {
|
||||
return this.assets.approveFieldDiscovery(id, dto, principal, request);
|
||||
}
|
||||
|
||||
@Post('field-discoveries/:id/reject')
|
||||
@RequirePermissions('assets.change_status')
|
||||
rejectFieldDiscovery(
|
||||
@Param('id', new ParseUUIDPipe({ version: '4' })) id: string,
|
||||
@Body() dto: RejectFieldDiscoveryDto,
|
||||
@CurrentAuth() principal: AuthPrincipal,
|
||||
@Req() request: RequestWithContext,
|
||||
) {
|
||||
return this.assets.rejectFieldDiscovery(id, dto, principal, request);
|
||||
}
|
||||
|
||||
@Post('field-discoveries/:id/match')
|
||||
@RequirePermissions('assets.change_status')
|
||||
matchFieldDiscovery(
|
||||
@Param('id', new ParseUUIDPipe({ version: '4' })) id: string,
|
||||
@Body() dto: MatchFieldDiscoveryDto,
|
||||
@CurrentAuth() principal: AuthPrincipal,
|
||||
@Req() request: RequestWithContext,
|
||||
) {
|
||||
return this.assets.matchFieldDiscovery(id, dto, principal, request);
|
||||
}
|
||||
|
||||
@Get('tree')
|
||||
@RequirePermissions('assets.read')
|
||||
tree(@Query() query: ListAssetTreeQueryDto) {
|
||||
return this.assets.tree(query);
|
||||
}
|
||||
|
||||
@Get('tree-children')
|
||||
@RequirePermissions('assets.read')
|
||||
treeChildren(@Query() query: ListAssetTreeChildrenQueryDto) {
|
||||
return this.assets.treeChildren(query);
|
||||
}
|
||||
|
||||
@Get('parent-options')
|
||||
@RequirePermissions('assets.read')
|
||||
parentOptions(@Query() query: ParentOptionsQueryDto) {
|
||||
return this.assets.parentOptions(query);
|
||||
}
|
||||
|
||||
@Post()
|
||||
@RequirePermissions('assets.create')
|
||||
create(
|
||||
@Body() dto: CreateAssetDto,
|
||||
@CurrentAuth() principal: AuthPrincipal,
|
||||
@Req() request: RequestWithContext,
|
||||
) {
|
||||
return this.assets.create(dto, principal, request);
|
||||
}
|
||||
|
||||
@Get(':id/lineage')
|
||||
@RequirePermissions('assets.read')
|
||||
lineage(@Param('id', new ParseUUIDPipe({ version: '4' })) id: string) {
|
||||
return this.assets.lineage(id);
|
||||
}
|
||||
|
||||
@Get(':id/dossier')
|
||||
@RequirePermissions(
|
||||
'assets.read',
|
||||
'inspections.read',
|
||||
'inspection_acts.read',
|
||||
'inspection_findings.read',
|
||||
'inspection_evidence.read',
|
||||
'inspection_communications.read',
|
||||
)
|
||||
dossier(@Param('id', new ParseUUIDPipe({ version: '4' })) id: string) {
|
||||
return this.assets.dossier(id);
|
||||
}
|
||||
|
||||
@Get(':id/context-history')
|
||||
@RequirePermissions('assets.read_history')
|
||||
contextHistory(@Param('id', new ParseUUIDPipe({ version: '4' })) id: string) {
|
||||
return this.assets.contextHistory(id);
|
||||
}
|
||||
|
||||
@Post(':id/context')
|
||||
@RequirePermissions('assets.manage_context')
|
||||
changeContext(
|
||||
@Param('id', new ParseUUIDPipe({ version: '4' })) id: string,
|
||||
@Body() dto: ChangeAssetContextDto,
|
||||
@CurrentAuth() principal: AuthPrincipal,
|
||||
@Req() request: RequestWithContext,
|
||||
) {
|
||||
return this.assets.changeContext(id, dto, principal, request);
|
||||
}
|
||||
|
||||
@Get(':id')
|
||||
@RequirePermissions('assets.read')
|
||||
getById(@Param('id', new ParseUUIDPipe({ version: '4' })) id: string) {
|
||||
return this.assets.getById(id);
|
||||
}
|
||||
|
||||
@Patch(':id')
|
||||
@RequirePermissions('assets.update')
|
||||
update(
|
||||
@Param('id', new ParseUUIDPipe({ version: '4' })) id: string,
|
||||
@Body() dto: UpdateAssetDto,
|
||||
@CurrentAuth() principal: AuthPrincipal,
|
||||
@Req() request: RequestWithContext,
|
||||
) {
|
||||
return this.assets.update(id, dto, principal, request);
|
||||
}
|
||||
|
||||
@Patch(':id/operational-status')
|
||||
@RequirePermissions('assets.change_operational_status')
|
||||
changeOperationalStatus(
|
||||
@Param('id', new ParseUUIDPipe({ version: '4' })) id: string,
|
||||
@Body() dto: ChangeAssetOperationalStatusDto,
|
||||
@CurrentAuth() principal: AuthPrincipal,
|
||||
@Req() request: RequestWithContext,
|
||||
) {
|
||||
return this.assets.changeOperationalStatus(id, dto, principal, request);
|
||||
}
|
||||
|
||||
@Patch(':id/information-status')
|
||||
@RequirePermissions('assets.change_status')
|
||||
changeStatus(
|
||||
@Param('id', new ParseUUIDPipe({ version: '4' })) id: string,
|
||||
@Body() dto: ChangeAssetStatusDto,
|
||||
@CurrentAuth() principal: AuthPrincipal,
|
||||
@Req() request: RequestWithContext,
|
||||
) {
|
||||
return this.assets.changeStatus(id, dto, principal, request);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user