feat: added checklistitem controller
This commit is contained in:
@@ -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 { CheckListItemService } from '../providers/check-list-item.service';
|
||||
import { CreateCheckListItemDto } from '../dto/check-list-item/create-check-list-item.dto';
|
||||
import { UpdateCheckListItemDto } from '../dto/check-list-item/update-check-list-item.dto';
|
||||
import { TMCheckListItem } from '../entities/check-list-item.entity';
|
||||
|
||||
@ApiTags('Task Manager - Check List Items')
|
||||
@Controller('task-manager/check-list-items')
|
||||
export class CheckListItemController {
|
||||
constructor(private readonly checkListItemService: CheckListItemService) {}
|
||||
|
||||
@Get()
|
||||
@ApiOperation({ summary: 'Get all check list items, optionally filtered by task' })
|
||||
@ApiQuery({ name: 'taskId', required: false, description: 'Filter check list items by task ID' })
|
||||
@ApiResponse({ status: 200, description: 'List of check list items', type: [TMCheckListItem] })
|
||||
findAll(@Query('taskId') taskId?: string): Promise<TMCheckListItem[]> {
|
||||
if (taskId) return this.checkListItemService.findByTask(taskId);
|
||||
return this.checkListItemService.findAll();
|
||||
}
|
||||
|
||||
@Get(':id')
|
||||
@ApiOperation({ summary: 'Get a check list item by ID' })
|
||||
@ApiParam({ name: 'id', description: 'CheckListItem ID' })
|
||||
@ApiResponse({ status: 200, description: 'CheckListItem found', type: TMCheckListItem })
|
||||
@ApiResponse({ status: 404, description: 'CheckListItem not found' })
|
||||
findOne(@Param('id') id: string): Promise<TMCheckListItem> {
|
||||
return this.checkListItemService.findOne(id);
|
||||
}
|
||||
|
||||
@Post()
|
||||
@ApiOperation({ summary: 'Create a new check list item' })
|
||||
@ApiResponse({ status: 201, description: 'CheckListItem created', type: TMCheckListItem })
|
||||
@ApiResponse({ status: 404, description: 'Task not found' })
|
||||
create(@Body() body: CreateCheckListItemDto): Promise<TMCheckListItem> {
|
||||
return this.checkListItemService.create(body);
|
||||
}
|
||||
|
||||
@Patch(':id')
|
||||
@ApiOperation({ summary: 'Update a check list item' })
|
||||
@ApiParam({ name: 'id', description: 'CheckListItem ID' })
|
||||
@ApiResponse({ status: 200, description: 'CheckListItem updated', type: TMCheckListItem })
|
||||
@ApiResponse({ status: 404, description: 'CheckListItem or Task not found' })
|
||||
update(@Param('id') id: string, @Body() body: UpdateCheckListItemDto): Promise<TMCheckListItem> {
|
||||
return this.checkListItemService.update(id, body);
|
||||
}
|
||||
|
||||
@Delete(':id')
|
||||
@ApiOperation({ summary: 'Delete a check list item' })
|
||||
@ApiParam({ name: 'id', description: 'CheckListItem ID' })
|
||||
@ApiResponse({ status: 200, description: 'CheckListItem deleted' })
|
||||
@ApiResponse({ status: 404, description: 'CheckListItem not found' })
|
||||
remove(@Param('id') id: string): Promise<void> {
|
||||
return this.checkListItemService.remove(id);
|
||||
}
|
||||
}
|
||||
@@ -19,12 +19,28 @@ import { WorkspaceTypeController } from "./controllers/workspace-type.controller
|
||||
import { ProjectController } from "./controllers/project.controller";
|
||||
import { ProjectRepository } from "./repositories/project.repository";
|
||||
import { ProjectService } from "./providers/project.service";
|
||||
import { TaskPhaseService } from "./providers/task-phase.service";
|
||||
import { TaskPhaseRepository } from "./repositories/task-phase.repository";
|
||||
import { TaskRepository } from "./repositories/task.repository";
|
||||
import { TaskService } from "./providers/task.service";
|
||||
import { CheckListItemRepository } from "./repositories/check-list-item.repository";
|
||||
import { CheckListItemService } from "./providers/check-list-item.service";
|
||||
import { TaskPhaseController } from "./controllers/task-phase.controller";
|
||||
import { TaskController } from "./controllers/task.controller";
|
||||
import { CheckListItemController } from "./controllers/check-list-item.controller";
|
||||
|
||||
@Module({
|
||||
imports: [
|
||||
TypeOrmModule.forFeature([TMWorkspaceType, TMWorkspace, TMProject, TMTaskPhase, TMTask, TMRemark, TMAttachment, TMCheckListItem, User]),
|
||||
],
|
||||
controllers: [WorkspaceController, WorkspaceTypeController, ProjectController],
|
||||
controllers: [
|
||||
WorkspaceController,
|
||||
WorkspaceTypeController,
|
||||
ProjectController,
|
||||
TaskPhaseController,
|
||||
TaskController,
|
||||
CheckListItemController,
|
||||
],
|
||||
providers: [
|
||||
WorkspaceRepository,
|
||||
WorkspaceService,
|
||||
@@ -32,9 +48,26 @@ import { ProjectService } from "./providers/project.service";
|
||||
WorkspaceTypeService,
|
||||
ProjectRepository,
|
||||
ProjectService,
|
||||
// TaskPhaseService,
|
||||
// TaskService,
|
||||
TaskPhaseRepository,
|
||||
TaskPhaseService,
|
||||
TaskRepository,
|
||||
TaskService,
|
||||
CheckListItemRepository,
|
||||
CheckListItemService,
|
||||
],
|
||||
exports: [
|
||||
WorkspaceRepository,
|
||||
WorkspaceService,
|
||||
WorkspaceTypeRepository,
|
||||
WorkspaceTypeService,
|
||||
ProjectRepository,
|
||||
ProjectService,
|
||||
TaskPhaseRepository,
|
||||
TaskPhaseService,
|
||||
TaskRepository,
|
||||
TaskService,
|
||||
CheckListItemRepository,
|
||||
CheckListItemService,
|
||||
],
|
||||
exports: [WorkspaceService, WorkspaceRepository, WorkspaceTypeService, WorkspaceTypeRepository, ProjectService, ProjectRepository],
|
||||
})
|
||||
export class TaskManagerModule {}
|
||||
|
||||
Reference in New Issue
Block a user