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
@@ -1,58 +1,58 @@
import { Controller, Get, Post, Patch, Delete, Param, Body, Query } from "@nestjs/common";
import { ApiTags, ApiOperation, ApiResponse, ApiParam, ApiQuery } from "@nestjs/swagger";
import { ProjectService } from "../providers/project.service";
import { CreateProjectDto } from "../dto/project/create-project.dto";
import { UpdateProjectDto } from "../dto/project/update-project.dto";
import { TMProject } from "../entities/project.entity";
import { Controller, Get, Post, Patch, Delete, Param, Body, Query } from '@nestjs/common';
import { ApiTags, ApiOperation, ApiResponse, ApiParam, ApiQuery } from '@nestjs/swagger';
import { ProjectService } from '../providers/project.service';
import { CreateProjectDto } from '../dto/project/create-project.dto';
import { UpdateProjectDto } from '../dto/project/update-project.dto';
import { TMProject } from '../entities/project.entity';
@ApiTags("Task Manager - Projects")
@Controller("task-manager/projects")
@ApiTags('Task Manager - Projects')
@Controller('task-manager/projects')
export class ProjectController {
constructor(private readonly projectService: ProjectService) {}
@Get()
@ApiOperation({ summary: "Get all projects, optionally filtered by workspace" })
@ApiQuery({ name: "workspaceId", required: false, description: "Filter projects by workspace ID" })
@ApiResponse({ status: 200, description: "List of projects", type: [TMProject] })
findAll(@Query("workspaceId") workspaceId?: string): Promise<TMProject[]> {
@ApiOperation({ summary: 'Get all projects, optionally filtered by workspace' })
@ApiQuery({ name: 'workspaceId', required: false, description: 'Filter projects by workspace ID' })
@ApiResponse({ status: 200, description: 'List of projects', type: [TMProject] })
findAll(@Query('workspaceId') workspaceId?: string): Promise<TMProject[]> {
if (workspaceId) return this.projectService.findByWorkspace(workspaceId);
return this.projectService.findAll();
}
@Get(":id")
@ApiOperation({ summary: "Get a project by ID" })
@ApiParam({ name: "id", description: "Project ID" })
@ApiResponse({ status: 200, description: "Project found", type: TMProject })
@ApiResponse({ status: 404, description: "Project not found" })
findOne(@Param("id") id: string): Promise<TMProject> {
@Get(':id')
@ApiOperation({ summary: 'Get a project by ID' })
@ApiParam({ name: 'id', description: 'Project ID' })
@ApiResponse({ status: 200, description: 'Project found', type: TMProject })
@ApiResponse({ status: 404, description: 'Project not found' })
findOne(@Param('id') id: string): Promise<TMProject> {
return this.projectService.findOne(id);
}
@Post()
@ApiOperation({ summary: "Create a new project" })
@ApiResponse({ status: 201, description: "Project created", type: TMProject })
@ApiResponse({ status: 400, description: "One or more users are not members of the workspace" })
@ApiResponse({ status: 404, description: "Workspace not found" })
@ApiOperation({ summary: 'Create a new project' })
@ApiResponse({ status: 201, description: 'Project created', type: TMProject })
@ApiResponse({ status: 400, description: 'One or more users are not members of the workspace' })
@ApiResponse({ status: 404, description: 'Workspace not found' })
create(@Body() body: CreateProjectDto): Promise<TMProject> {
return this.projectService.create(body);
}
@Patch(":id")
@ApiOperation({ summary: "Update a project" })
@ApiParam({ name: "id", description: "Project ID" })
@ApiResponse({ status: 200, description: "Project updated", type: TMProject })
@ApiResponse({ status: 400, description: "One or more users are not members of the workspace" })
@ApiResponse({ status: 404, description: "Project not found" })
update(@Param("id") id: string, @Body() body: UpdateProjectDto): Promise<TMProject> {
@Patch(':id')
@ApiOperation({ summary: 'Update a project' })
@ApiParam({ name: 'id', description: 'Project ID' })
@ApiResponse({ status: 200, description: 'Project updated', type: TMProject })
@ApiResponse({ status: 400, description: 'One or more users are not members of the workspace' })
@ApiResponse({ status: 404, description: 'Project not found' })
update(@Param('id') id: string, @Body() body: UpdateProjectDto): Promise<TMProject> {
return this.projectService.update(id, body);
}
@Delete(":id")
@ApiOperation({ summary: "Delete a project" })
@ApiParam({ name: "id", description: "Project ID" })
@ApiResponse({ status: 200, description: "Project deleted" })
@ApiResponse({ status: 404, description: "Project not found" })
remove(@Param("id") id: string): Promise<TMProject> {
@Delete(':id')
@ApiOperation({ summary: 'Delete a project' })
@ApiParam({ name: 'id', description: 'Project ID' })
@ApiResponse({ status: 200, description: 'Project deleted' })
@ApiResponse({ status: 404, description: 'Project not found' })
remove(@Param('id') id: string): Promise<TMProject> {
return this.projectService.remove(id);
}
}
}