feat: add workspacetype controller
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
import { Controller, Get, Post, Patch, Delete, Param, Body } from "@nestjs/common";
|
||||
import { ApiTags, ApiOperation, ApiResponse, ApiParam } from "@nestjs/swagger";
|
||||
import { WorkspaceTypeService } from "../providers/workspace-type.service";
|
||||
import { CreateWorkspaceTypeDto } from "../dto/workspace-type/create-workspace-type.dto";
|
||||
import { UpdateWorkspaceTypeDto } from "../dto/workspace-type/update-workspace-type.dto";
|
||||
import { TMWorkspaceType } from "../entities/workspace-type.entity";
|
||||
|
||||
@ApiTags("Task Manager - Workspace Types")
|
||||
@Controller("task-manager/workspace-types")
|
||||
export class WorkspaceTypeController {
|
||||
constructor(private readonly workspaceTypeService: WorkspaceTypeService) {}
|
||||
|
||||
@Get()
|
||||
@ApiOperation({ summary: "Get all workspace types" })
|
||||
@ApiResponse({ status: 200, description: "List of workspace types", type: [TMWorkspaceType] })
|
||||
findAll(): Promise<TMWorkspaceType[]> {
|
||||
return this.workspaceTypeService.findAll();
|
||||
}
|
||||
|
||||
@Get(":id")
|
||||
@ApiOperation({ summary: "Get a workspace type by ID" })
|
||||
@ApiParam({ name: "id", description: "WorkspaceType ID" })
|
||||
@ApiResponse({ status: 200, description: "WorkspaceType found", type: TMWorkspaceType })
|
||||
@ApiResponse({ status: 404, description: "WorkspaceType not found" })
|
||||
findOne(@Param("id") id: string): Promise<TMWorkspaceType> {
|
||||
return this.workspaceTypeService.findOne(id);
|
||||
}
|
||||
|
||||
@Post()
|
||||
@ApiOperation({ summary: "Create a new workspace type" })
|
||||
@ApiResponse({ status: 201, description: "WorkspaceType created", type: TMWorkspaceType })
|
||||
@ApiResponse({ status: 409, description: "WorkspaceType with this name already exists" })
|
||||
create(@Body() body: CreateWorkspaceTypeDto): Promise<TMWorkspaceType> {
|
||||
return this.workspaceTypeService.create(body);
|
||||
}
|
||||
|
||||
@Patch(":id")
|
||||
@ApiOperation({ summary: "Update a workspace type" })
|
||||
@ApiParam({ name: "id", description: "WorkspaceType ID" })
|
||||
@ApiResponse({ status: 200, description: "WorkspaceType updated", type: TMWorkspaceType })
|
||||
@ApiResponse({ status: 404, description: "WorkspaceType not found" })
|
||||
@ApiResponse({ status: 409, description: "WorkspaceType with this name already exists" })
|
||||
update(@Param("id") id: string, @Body() body: UpdateWorkspaceTypeDto): Promise<TMWorkspaceType> {
|
||||
return this.workspaceTypeService.update(id, body);
|
||||
}
|
||||
|
||||
@Delete(":id")
|
||||
@ApiOperation({ summary: "Delete a workspace type" })
|
||||
@ApiParam({ name: "id", description: "WorkspaceType ID" })
|
||||
@ApiResponse({ status: 200, description: "WorkspaceType deleted" })
|
||||
@ApiResponse({ status: 404, description: "WorkspaceType not found" })
|
||||
remove(@Param("id") id: string): Promise<void> {
|
||||
return this.workspaceTypeService.remove(id);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user