fix & enhance workspace
This commit is contained in:
@@ -0,0 +1,53 @@
|
||||
import { Controller, Get, Post, Patch, Delete, Param, Body } from '@nestjs/common';
|
||||
import { ApiTags, ApiOperation, ApiResponse, ApiParam } from '@nestjs/swagger';
|
||||
import { WorkspaceService } from '../providers/workspace.service';
|
||||
import { CreateWorkspaceDto } from '../dto/workspace/create-workspace.dto';
|
||||
import { UpdateWorkspaceDto } from '../dto/workspace/update-workspace.dto';
|
||||
import { TMWorkspace } from '../entities/workspace.entity';
|
||||
|
||||
@ApiTags('Task Manager - Workspaces')
|
||||
@Controller('task-manager/workspaces')
|
||||
export class WorkspaceController {
|
||||
constructor(private readonly workspaceService: WorkspaceService) {}
|
||||
|
||||
@Get()
|
||||
@ApiOperation({ summary: 'Get all workspaces' })
|
||||
@ApiResponse({ status: 200, description: 'List of workspaces', type: [TMWorkspace] })
|
||||
findAll(): Promise<TMWorkspace[]> {
|
||||
return this.workspaceService.findAll();
|
||||
}
|
||||
|
||||
@Get(':id')
|
||||
@ApiOperation({ summary: 'Get a workspace by ID' })
|
||||
@ApiParam({ name: 'id', description: 'Workspace ID' })
|
||||
@ApiResponse({ status: 200, description: 'Workspace found', type: TMWorkspace })
|
||||
@ApiResponse({ status: 404, description: 'Workspace not found' })
|
||||
findOne(@Param('id') id: string): Promise<TMWorkspace> {
|
||||
return this.workspaceService.findOneOrFail(id);
|
||||
}
|
||||
|
||||
@Post()
|
||||
@ApiOperation({ summary: 'Create a new workspace' })
|
||||
@ApiResponse({ status: 201, description: 'Workspace created', type: TMWorkspace })
|
||||
create(@Body() body: CreateWorkspaceDto): Promise<TMWorkspace> {
|
||||
return this.workspaceService.create(body);
|
||||
}
|
||||
|
||||
@Patch(':id')
|
||||
@ApiOperation({ summary: 'Update a workspace' })
|
||||
@ApiParam({ name: 'id', description: 'Workspace ID' })
|
||||
@ApiResponse({ status: 200, description: 'Workspace updated', type: TMWorkspace })
|
||||
@ApiResponse({ status: 404, description: 'Workspace not found' })
|
||||
update(@Param('id') id: string, @Body() body: UpdateWorkspaceDto): Promise<TMWorkspace> {
|
||||
return this.workspaceService.update(id, body);
|
||||
}
|
||||
|
||||
@Delete(':id')
|
||||
@ApiOperation({ summary: 'Delete a workspace' })
|
||||
@ApiParam({ name: 'id', description: 'Workspace ID' })
|
||||
@ApiResponse({ status: 200, description: 'Workspace deleted' })
|
||||
@ApiResponse({ status: 404, description: 'Workspace not found' })
|
||||
remove(@Param('id') id: string): Promise<void> {
|
||||
return this.workspaceService.remove(id);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user