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

0% Statements 0/19
0% Branches 0/28
0% Functions 0/5
0% Lines 0/17

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                                                                                                           
import { Controller, Get, Post, Put, Param, Body, Req } from '@nestjs/common';
import { TaskService } from '../services/task.service';
import { ApiTags, ApiOperation, ApiResponse } from '@nestjs/swagger';
 
@Controller('api/v1/tasks')
@ApiTags('Task')
export class TaskController {
  constructor(private readonly taskService: TaskService) {}
 
  @Post()
  @ApiOperation({ summary: 'Create operation' })
  @ApiResponse({ status: 201, description: 'Operation successful' })
  async create(@Req() req: any, @Body() data: any): Promise<any> {
    const tenantId = req.user?.tenantId || 'dummy-tenant-id';
    return this.taskService.create(tenantId, data);
  }
 
  @Get('project/:projectId')
  @ApiOperation({ summary: 'Find all by project operation' })
  @ApiResponse({ status: 200, description: 'Operation successful' })
  async findAllByProject(
    @Req() req: any,
    @Param('projectId') projectId: string,
  ): Promise<any> {
    const tenantId = req.user?.tenantId || 'dummy-tenant-id';
    return this.taskService.findAllByProject(tenantId, projectId);
  }
 
  @Put(':id/status')
  @ApiOperation({ summary: 'Update status operation' })
  @ApiResponse({ status: 200, description: 'Operation successful' })
  async updateStatus(
    @Req() req: any,
    @Param('id') id: string,
    @Body('status') status: string,
  ): Promise<any> {
    const tenantId = req.user?.tenantId || 'dummy-tenant-id';
    return this.taskService.transitionStatus(tenantId, id, status);
  }
 
  @Post('dependency')
  @ApiOperation({ summary: 'Add dependency operation' })
  @ApiResponse({ status: 201, description: 'Operation successful' })
  async addDependency(@Req() req: any, @Body() data: any): Promise<any> {
    const tenantId = req.user?.tenantId || 'dummy-tenant-id';
    return this.taskService.addDependency(
      tenantId,
      data.predecessorId,
      data.successorId,
      data.type,
    );
  }
}