44 lines
1.2 KiB
TypeScript
44 lines
1.2 KiB
TypeScript
import {
|
|
Controller,
|
|
Get,
|
|
Param,
|
|
ParseIntPipe,
|
|
ParseUUIDPipe,
|
|
Query,
|
|
} from '@nestjs/common';
|
|
import { RequirePermissions } from '../authorization/decorators/require-permissions.decorator';
|
|
import { AssetHistoryService } from './asset-history.service';
|
|
import {
|
|
AssetVersionPageQueryDto,
|
|
ListAssetVersionsQueryDto,
|
|
} from './dto/list-asset-versions-query.dto';
|
|
|
|
@Controller()
|
|
export class AssetHistoryController {
|
|
constructor(private readonly history: AssetHistoryService) {}
|
|
|
|
@Get('asset-versions')
|
|
@RequirePermissions('assets.read_history')
|
|
list(@Query() query: ListAssetVersionsQueryDto) {
|
|
return this.history.list(query);
|
|
}
|
|
|
|
@Get('assets/:id/versions')
|
|
@RequirePermissions('assets.read_history')
|
|
listForAsset(
|
|
@Param('id', new ParseUUIDPipe({ version: '4' })) id: string,
|
|
@Query() query: AssetVersionPageQueryDto,
|
|
) {
|
|
return this.history.listForAsset(id, query);
|
|
}
|
|
|
|
@Get('assets/:id/versions/:versionNumber')
|
|
@RequirePermissions('assets.read_history')
|
|
getVersion(
|
|
@Param('id', new ParseUUIDPipe({ version: '4' })) id: string,
|
|
@Param('versionNumber', new ParseIntPipe()) versionNumber: number,
|
|
) {
|
|
return this.history.getVersion(id, versionNumber);
|
|
}
|
|
}
|