diff --git a/apps/server/src/task/controller/task.controller.ts b/apps/server/src/task/controller/task.controller.ts index e85f9f6..601e6a3 100644 --- a/apps/server/src/task/controller/task.controller.ts +++ b/apps/server/src/task/controller/task.controller.ts @@ -1,4 +1,4 @@ -import { Body, Controller, Get, Param, Patch, Post } from '@nestjs/common'; +import { Body, Controller, Delete, Get, Param, Patch, Post } from '@nestjs/common'; import { TaskService } from '../service/task.service'; import { CreateTaskRequest } from '../dto/create-task-request.dto'; import { UpdateTaskRequest } from '../dto/update-task-request.dto'; @@ -27,4 +27,9 @@ export class TaskController { get(@Param('id') id: number) { return this.taskService.get(id); } + + @Delete(':id') + delete(@Param('id') id: number) { + return this.taskService.delete(id); + } } diff --git a/apps/server/src/task/dto/delete-task-response.dto.ts b/apps/server/src/task/dto/delete-task-response.dto.ts new file mode 100644 index 0000000..95e42a3 --- /dev/null +++ b/apps/server/src/task/dto/delete-task-response.dto.ts @@ -0,0 +1,7 @@ +export class DeleteTaskResponse { + constructor(id: number) { + this.id = id; + } + + id: number; +} diff --git a/apps/server/src/task/service/task.service.ts b/apps/server/src/task/service/task.service.ts index f85196d..14a6d80 100644 --- a/apps/server/src/task/service/task.service.ts +++ b/apps/server/src/task/service/task.service.ts @@ -11,6 +11,7 @@ import { UpdateTaskResponse } from '../dto/update-task-response.dto'; import { MoveTaskRequest } from '../dto/move-task-request.dto'; import { MoveTaskResponse } from '../dto/move-task-response.dto'; import { TaskResponse } from '../dto/task-response.dto'; +import { DeleteTaskResponse } from '../dto/delete-task-response.dto'; @Injectable() export class TaskService { @@ -64,6 +65,11 @@ export class TaskService { return new TaskResponse(task); } + async delete(id: number) { + await this.taskRepository.delete(id); + return new DeleteTaskResponse(id); + } + private async findTaskOrThrow(id: number) { const task = await this.taskRepository.findOneBy({ id }); if (!task) {