Skip to content

Commit e347bca

Browse files
committed
Update Success
1 parent 35533f0 commit e347bca

File tree

2 files changed

+20
-4
lines changed

2 files changed

+20
-4
lines changed

nestjs-task-management/src/tasks/tasks.controller.ts

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import { Body, Controller, Get, Param, Post } from '@nestjs/common';
1+
import { Body, Controller, Delete, Get, Param, Patch, Post } from '@nestjs/common';
22
import { TasksService } from './tasks.service';
33
import { CreateTaskDTO } from './dto/create-task.dto';
4-
import { Task } from './tasks.model';
4+
import { Task, TaskStatus } from './tasks.model';
55

66
@Controller('tasks')
77
export class TasksController {
@@ -21,9 +21,9 @@ export class TasksController {
2121
}
2222

2323

24-
@Get('/:id')
24+
@Delete('/:id')
2525
deleteTask(@Param('id') id:string) : void{
26-
this.tasksService.getTaskByID(id)
26+
this.tasksService.deleteTask(id)
2727
}
2828

2929
@Post()
@@ -35,6 +35,14 @@ export class TasksController {
3535

3636
}
3737

38+
@Patch("/:id/status")
39+
updateTaskStatus(
40+
@Param('id') id:string,
41+
@Body('status') status:TaskStatus,){
42+
43+
return this.tasksService.updateTask(id,status);
44+
}
45+
3846
}
3947

4048

nestjs-task-management/src/tasks/tasks.service.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,12 @@ export class TasksService {
3232
this.tasks.push(task);
3333
return task;
3434
}
35+
36+
37+
updateTask(id:string, status:TaskStatus) : Task{
38+
const task=this.getTaskByID(id);
39+
task.status=status;
40+
return task;
41+
42+
}
3543
}

0 commit comments

Comments
 (0)