Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 | import { Controller, Get, Query, UseGuards, Request, Param, } from '@nestjs/common'; import { DashboardService } from './dashboard.service'; import { PermissionGuard } from '../../../../platform/permissions/permission.guard'; import { RequirePermission } from '../../../../platform/permissions/permission.decorator'; import { ApiTags, ApiOperation, ApiResponse } from '@nestjs/swagger'; @Controller('attendance-dashboard') @UseGuards(PermissionGuard) @ApiTags('Dashboard') export class DashboardController { constructor(private readonly dashboardService: DashboardService) {} @Get('admin') @RequirePermission('attendance_dashboard', 'admin') @ApiOperation({ summary: 'Get admin metrics operation' }) @ApiResponse({ status: 200, description: 'Operation successful' }) getAdminMetrics(@Request() req: any, @Query('date') date: string) { return this.dashboardService.getAdminDashboardMetrics( req.user.tenantId, date, ); } @Get('employee/me') @RequirePermission('attendance_dashboard', 'employee') @ApiOperation({ summary: 'Get my metrics operation' }) @ApiResponse({ status: 200, description: 'Operation successful' }) getMyMetrics(@Request() req: any, @Query('month') month: string) { const currentMonth = month || new Date().toISOString().substring(0, 7); // YYYY-MM return this.dashboardService.getEmployeeDashboardMetrics( req.user.tenantId, req.user.employeeId, currentMonth, ); } @Get('employee/:employeeId') @RequirePermission('attendance_dashboard', 'admin') @ApiOperation({ summary: 'Get employee metrics operation' }) @ApiResponse({ status: 200, description: 'Operation successful' }) getEmployeeMetrics( @Request() req: any, @Param('employeeId') employeeId: string, @Query('month') month: string, ) { const currentMonth = month || new Date().toISOString().substring(0, 7); return this.dashboardService.getEmployeeDashboardMetrics( req.user.tenantId, employeeId, currentMonth, ); } } |