mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-27 00:52:50 +00:00
Gates the previously open support-agent, procurement, compliance, facilities, list-users and trade-access controllers, separates customer from staff routes across bookings, contracts, companies, billing, warehouses, files and train scheduling, and moves billing, overview, reports and the settings controllers onto their own keys instead of the blanket admin key. Drops the demo-permissions module and the untested notification test route.
35 lines
1.4 KiB
TypeScript
35 lines
1.4 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 { BookingStaff } from '../../common/booking-guards';
|
|
import { FREIGHT_PERMS } from '../../seed/freight-permissions.registry';
|
|
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')
|
|
@BookingStaff(FREIGHT_PERMS.reports.view)
|
|
@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);
|
|
}
|
|
}
|