All files / src/domains/projects/controllers resource.controller.ts

0% Statements 0/13
0% Branches 0/16
0% Functions 0/3
0% Lines 0/11

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                                                                   
import { Controller, Get, Post, Param, Query, Body, Req } from '@nestjs/common';
import { ResourcePlanningService } from '../services/resource-planning.service';
import { ApiTags, ApiOperation, ApiResponse } from '@nestjs/swagger';
 
@Controller('api/v1/resources')
@ApiTags('Resource')
export class ResourceController {
  constructor(private readonly resourceService: ResourcePlanningService) {}
 
  @Post('allocate')
  @ApiOperation({ summary: 'Allocate operation' })
  @ApiResponse({ status: 201, description: 'Operation successful' })
  async allocate(@Req() req: any, @Body() data: any): Promise<any> {
    const tenantId = req.user?.tenantId || 'dummy-tenant-id';
    return this.resourceService.allocate(tenantId, data);
  }
 
  @Get('workload/:employeeId')
  @ApiOperation({ summary: 'Get workload operation' })
  @ApiResponse({ status: 200, description: 'Operation successful' })
  async getWorkload(
    @Req() req: any,
    @Param('employeeId') employeeId: string,
    @Query('date') date: string,
  ): Promise<any> {
    const tenantId = req.user?.tenantId || 'dummy-tenant-id';
    return this.resourceService.getEmployeeWorkload(
      tenantId,
      employeeId,
      new Date(date),
    );
  }
}