mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-27 00:52:50 +00:00
34 lines
1.3 KiB
TypeScript
34 lines
1.3 KiB
TypeScript
import { Controller, Get, Param, Query } from '@nestjs/common';
|
|
import { ApiBearerAuth, ApiOkResponse, ApiOperation, ApiTags } from '@nestjs/swagger';
|
|
import { CurrentUser } from '@edr/api-common';
|
|
import type { TCurrentUser } from '@tria-plc/api-common/modules/auth/types/current-user.type';
|
|
|
|
import { BookingView } from '../../common/booking-guards';
|
|
import { UserTradeAccessService } from '../user-trade-access/user-trade-access.service';
|
|
import { ReportQueryDto } from './dto/report-query.dto';
|
|
import { ReportResultDto } from './dto/report-result.dto';
|
|
import { ReportsService } from './reports.service';
|
|
|
|
@ApiTags('Reports')
|
|
@ApiBearerAuth()
|
|
@Controller('reports')
|
|
export class ReportsController {
|
|
constructor(
|
|
private readonly reportsService: ReportsService,
|
|
private readonly userTradeAccessService: UserTradeAccessService,
|
|
) {}
|
|
|
|
@Get(':key')
|
|
@BookingView()
|
|
@ApiOperation({ summary: 'Run a canned report by key with optional filters' })
|
|
@ApiOkResponse({ type: ReportResultDto })
|
|
async run(
|
|
@Param('key') key: string,
|
|
@Query() query: ReportQueryDto,
|
|
@CurrentUser() user: TCurrentUser,
|
|
): Promise<ReportResultDto> {
|
|
const allowed = await this.userTradeAccessService.resolveAllowedDirections(user);
|
|
return this.reportsService.run(key, query, allowed);
|
|
}
|
|
}
|