refactor: refactored project
This commit is contained in:
@@ -5,13 +5,18 @@ import { CreateProjectDto } from "../dto/project/create-project.dto";
|
||||
import { UpdateProjectDto } from "../dto/project/update-project.dto";
|
||||
import { PaginationDto } from "../../../common/DTO/pagination.dto";
|
||||
import { TMProject } from "../entities/project.entity";
|
||||
import { AdminRoute } from "../../../common/decorators/admin.decorator";
|
||||
import { PermissionsDec } from "../../../common/decorators/permission.decorator";
|
||||
import { PermissionEnum } from "../../users/enums/permission.enum";
|
||||
|
||||
@AdminRoute()
|
||||
@ApiTags("Task Manager - Projects")
|
||||
@Controller("task-manager/projects")
|
||||
export class ProjectController {
|
||||
constructor(private readonly projectService: ProjectService) {}
|
||||
|
||||
@Get()
|
||||
@PermissionsDec(PermissionEnum.PROJECT)
|
||||
@ApiOperation({ summary: "Get all projects, optionally filtered by workspace" })
|
||||
@ApiQuery({ name: "workspaceId", required: false, description: "Filter projects by workspace ID" })
|
||||
@ApiResponse({ status: 200, description: "Paginated list of projects" })
|
||||
@@ -28,15 +33,17 @@ export class ProjectController {
|
||||
}
|
||||
|
||||
@Get(":id")
|
||||
@PermissionsDec(PermissionEnum.PROJECT)
|
||||
@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);
|
||||
return this.projectService.findOneOrFail(id);
|
||||
}
|
||||
|
||||
@Post()
|
||||
@PermissionsDec(PermissionEnum.PROJECT)
|
||||
@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" })
|
||||
@@ -46,6 +53,7 @@ export class ProjectController {
|
||||
}
|
||||
|
||||
@Patch(":id")
|
||||
@PermissionsDec(PermissionEnum.PROJECT)
|
||||
@ApiOperation({ summary: "Update a project" })
|
||||
@ApiParam({ name: "id", description: "Project ID" })
|
||||
@ApiResponse({ status: 200, description: "Project updated", type: TMProject })
|
||||
@@ -56,6 +64,7 @@ export class ProjectController {
|
||||
}
|
||||
|
||||
@Delete(":id")
|
||||
@PermissionsDec(PermissionEnum.PROJECT)
|
||||
@ApiOperation({ summary: "Delete a project" })
|
||||
@ApiParam({ name: "id", description: "Project ID" })
|
||||
@ApiResponse({ status: 200, description: "Project deleted", type: TMProject })
|
||||
@@ -63,4 +72,13 @@ export class ProjectController {
|
||||
remove(@Param("id") id: string): Promise<TMProject> {
|
||||
return this.projectService.remove(id);
|
||||
}
|
||||
|
||||
@Get("/workspace/:wsId")
|
||||
@ApiOperation({summary: "Get projects of a specific workspace"})
|
||||
@ApiParam({ name: "wsId", description: "Workspace ID" })
|
||||
@ApiResponse({ status: 200, description: "received projects successfully!"})
|
||||
@ApiResponse({ status: 404, description: "WorkSpace not found" })
|
||||
findByWorkspace(@Param("wsId") wsId: string): Promise<TMProject[]> {
|
||||
return this.findByWorkspace(wsId);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user