28 lines
803 B
TypeScript
28 lines
803 B
TypeScript
import { Controller, Get, Query, UseGuards } from '@nestjs/common';
|
|||
|
|
import { JwtAuthGuard } from '../auth/jwt-auth.guard';
|
||
|
|
import { CurrentUser } from '../auth/current-user.decorator';
|
||
|
|
import { ReportsQueryDto } from './dto';
|
||
|
|
import { ReportsService } from './reports.service';
|
||
|
|
|
||
|
|
@Controller('reports')
|
||
|
|
@UseGuards(JwtAuthGuard)
|
||
|
|
export class ReportsController {
|
||
|
|
constructor(private readonly reportsService: ReportsService) {}
|
||
|
|
|
||
|
|
@Get('dashboard')
|
||
|
|
dashboard(
|
||
|
|
@CurrentUser()
|
||
|
|
user: { userId: string; organizationId: string; role: string },
|
||
|
|
@Query() query: ReportsQueryDto,
|
||
|
|
) {
|
||
|
|
return this.reportsService.dashboard(
|
||
|
|
{
|
||
|
|
userId: user.userId,
|
||
|
|
organizationId: user.organizationId,
|
||
|
|
role: user.role,
|
||
|
|
},
|
||
|
|
{ from: query.from, to: query.to },
|
||
|
|
);
|
||
|
|
}
|
||
|
|
}
|