feat: added task phase APIs

This commit is contained in:
2026-07-01 12:53:42 +03:30
parent 89d85e6d24
commit bf98b8b9ce
6 changed files with 226 additions and 36 deletions
@@ -0,0 +1,56 @@
import { Controller, Get, Post, Patch, Delete, Param, Body, Query } from "@nestjs/common";
import { ApiTags, ApiOperation, ApiResponse, ApiParam, ApiQuery } from "@nestjs/swagger";
import { TaskPhaseService } from "../providers/task-phase.service";
import { CreateTaskPhaseDto } from "../dto/task-phase/create-task-phase.dto";
import { UpdateTaskPhaseDto } from "../dto/task-phase/update-task-phase.dto";
import { TMTaskPhase } from "../entities/task-phase.entity";
@ApiTags("Task Manager - Task Phases")
@Controller("task-manager/task-phases")
export class TaskPhaseController {
constructor(private readonly taskPhaseService: TaskPhaseService) {}
@Get()
@ApiOperation({ summary: "Get all task phases, optionally filtered by project" })
@ApiQuery({ name: "projectId", required: false, description: "Filter task phases by project ID" })
@ApiResponse({ status: 200, description: "List of task phases", type: [TMTaskPhase] })
findAll(@Query("projectId") projectId?: string): Promise<TMTaskPhase[]> {
if (projectId) return this.taskPhaseService.findByProject(projectId);
return this.taskPhaseService.findAll();
}
@Get(":id")
@ApiOperation({ summary: "Get a task phase by ID" })
@ApiParam({ name: "id", description: "TaskPhase ID" })
@ApiResponse({ status: 200, description: "TaskPhase found", type: TMTaskPhase })
@ApiResponse({ status: 404, description: "TaskPhase not found" })
findOne(@Param("id") id: string): Promise<TMTaskPhase> {
return this.taskPhaseService.findOne(id);
}
@Post()
@ApiOperation({ summary: "Create a new task phase" })
@ApiResponse({ status: 201, description: "TaskPhase created", type: TMTaskPhase })
@ApiResponse({ status: 404, description: "Project not found" })
create(@Body() body: CreateTaskPhaseDto): Promise<TMTaskPhase> {
return this.taskPhaseService.create(body);
}
@Patch(":id")
@ApiOperation({ summary: "Update a task phase" })
@ApiParam({ name: "id", description: "TaskPhase ID" })
@ApiResponse({ status: 200, description: "TaskPhase updated", type: TMTaskPhase })
@ApiResponse({ status: 404, description: "TaskPhase or Project not found" })
update(@Param("id") id: string, @Body() body: UpdateTaskPhaseDto): Promise<TMTaskPhase> {
return this.taskPhaseService.update(id, body);
}
@Delete(":id")
@ApiOperation({ summary: "Delete a task phase" })
@ApiParam({ name: "id", description: "TaskPhase ID" })
@ApiResponse({ status: 200, description: "TaskPhase deleted" })
@ApiResponse({ status: 404, description: "TaskPhase not found" })
remove(@Param("id") id: string): Promise<void> {
return this.taskPhaseService.remove(id);
}
}