refactor permissions
This commit is contained in:
@@ -23,7 +23,7 @@ export class TaskController {
|
||||
constructor(private readonly taskService: TaskService) {}
|
||||
|
||||
@Post()
|
||||
@PermissionsDec(PermissionEnum.TASK)
|
||||
@PermissionsDec(PermissionEnum.TASK_CREATE)
|
||||
@ApiOperation({ summary: "Create a new task" })
|
||||
@ApiResponse({ status: 201, description: "Task created", type: TMTask })
|
||||
@ApiResponse({ status: 404, description: "TaskPhase not found" })
|
||||
@@ -32,7 +32,7 @@ export class TaskController {
|
||||
}
|
||||
|
||||
@Patch(":id")
|
||||
@PermissionsDec(PermissionEnum.TASK)
|
||||
@PermissionsDec(PermissionEnum.TASK_UPDATE)
|
||||
@ApiOperation({ summary: "Update a task" })
|
||||
@ApiParam({ name: "id", description: "Task ID" })
|
||||
@ApiResponse({ status: 200, description: "Task updated", type: TMTask })
|
||||
@@ -42,18 +42,17 @@ export class TaskController {
|
||||
}
|
||||
|
||||
@Patch(":id/change-phase")
|
||||
@PermissionsDec(PermissionEnum.TASK)
|
||||
@ApiOperation({ summary: "Move a task to a different phase within the same project" })
|
||||
@ApiParam({ name: "id", description: "Task ID" })
|
||||
@ApiResponse({ status: 200, description: "Task phase changed", type: TMTask })
|
||||
@ApiResponse({ status: 400, description: "Target phase belongs to a different project" })
|
||||
@ApiResponse({ status: 404, description: "Task or TaskPhase not found" })
|
||||
changePhase(@Param("id") id: string, @Body() body: ChangeTaskPhaseDto): Promise<TMTask> {
|
||||
return this.taskService.changePhase(id, body);
|
||||
changePhase(@Param("id") id: string,@UserDec() user: ITokenPayload, @Body() body: ChangeTaskPhaseDto): Promise<TMTask> {
|
||||
return this.taskService.changePhase(id, user.permissions, user.id, body);
|
||||
}
|
||||
|
||||
@Delete(":id")
|
||||
@PermissionsDec(PermissionEnum.TASK)
|
||||
@PermissionsDec(PermissionEnum.TASK_DELETE)
|
||||
@ApiOperation({ summary: "Delete a task" })
|
||||
@ApiParam({ name: "id", description: "Task ID" })
|
||||
@ApiResponse({ status: 200, description: "Task deleted" })
|
||||
@@ -98,7 +97,7 @@ export class TaskController {
|
||||
@ApiResponse({ status: 200, description: "Changed the task priority successfully!" })
|
||||
@ApiResponse({ status: 400, description: "Bad Request from user." })
|
||||
@ApiResponse({ status: 404, description: "Task not found!" })
|
||||
changePriority(@Param("srcid") srcId: string, @Param("desid") desId: string): Promise<TMTask> {
|
||||
return this.taskService.changePriority(srcId, desId);
|
||||
changePriority(@Param("srcid") srcId: string, @Param("desid") desId: string,@UserDec() user: ITokenPayload): Promise<TMTask> {
|
||||
return this.taskService.changePriority(srcId, user.permissions, user.id, desId);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user