From 13da13b954575dd1dce4618dba9d2aa353362413 Mon Sep 17 00:00:00 2001 From: yang Date: Tue, 12 Nov 2024 23:35:51 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20=ED=83=9C=EC=8A=A4=ED=81=AC=20=EC=82=AD?= =?UTF-8?q?=EC=A0=9C=20API=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/server/src/task/controller/task.controller.ts | 7 ++++++- apps/server/src/task/dto/delete-task-response.dto.ts | 7 +++++++ apps/server/src/task/service/task.service.ts | 6 ++++++ 3 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 apps/server/src/task/dto/delete-task-response.dto.ts diff --git a/apps/server/src/task/controller/task.controller.ts b/apps/server/src/task/controller/task.controller.ts index 255af67..8b7a1a7 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 c952755..4f85fd3 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) {