issue-106 #107
@ -196,4 +196,15 @@ public class TaskController {
|
|||||||
Collection<Task> subtasks = taskPermissionResult.getResult().getSubtasks();
|
Collection<Task> subtasks = taskPermissionResult.getResult().getSubtasks();
|
||||||
return ResponseEntity.ok(subtasks.stream().map(TaskEntityInfo::new).toList());
|
return ResponseEntity.ok(subtasks.stream().map(TaskEntityInfo::new).toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@DeleteMapping("/tasks/{taskID}/subtasks")
|
||||||
|
public ResponseEntity<?> onClearSubtasks(@PathVariable long taskID) {
|
||||||
|
var taskPermissionResult = taskService.getTaskPermissions(taskID, SecurityContextHolder.getContext().getAuthentication().getName());
|
||||||
|
if(taskPermissionResult.hasIssue()) {
|
||||||
|
return taskPermissionResult.mapToResponseEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
ServiceExitCode result = taskService.clearSubTasks(taskPermissionResult.getResult());
|
||||||
|
return result.mapToResponseEntity();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -44,4 +44,9 @@ public interface TaskRepository extends CrudRepository<Task, Long> {
|
|||||||
@Transactional
|
@Transactional
|
||||||
@Query(value = "UPDATE Task t SET t.parent = null WHERE t.taskgroup = ?1")
|
@Query(value = "UPDATE Task t SET t.parent = null WHERE t.taskgroup = ?1")
|
||||||
void deleteTaskHierarchyWhereTaskgroup(Taskgroup taskgroup);
|
void deleteTaskHierarchyWhereTaskgroup(Taskgroup taskgroup);
|
||||||
|
|
||||||
|
@Modifying
|
||||||
|
@Transactional
|
||||||
|
@Query(value = "DELETE Task t WHERE t.parent = ?1")
|
||||||
|
void deleteTasksByParent(Task parentTask);
|
||||||
}
|
}
|
||||||
|
@ -140,7 +140,7 @@ public class TaskSeriesService {
|
|||||||
}
|
}
|
||||||
taskSerie.getTasks().clear();
|
taskSerie.getTasks().clear();
|
||||||
taskSeriesRepository.delete(taskSerie);
|
taskSeriesRepository.delete(taskSerie);
|
||||||
} else {
|
} else if(task.getParent() == null){
|
||||||
repearIndexing(taskSerie, item.getSeriesIndex());
|
repearIndexing(taskSerie, item.getSeriesIndex());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -159,4 +159,9 @@ public class TaskService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ServiceExitCode clearSubTasks(Task parentTask) {
|
||||||
|
taskRepository.deleteTasksByParent(parentTask);
|
||||||
|
return ServiceExitCode.OK;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
33
openapi.yaml
33
openapi.yaml
@ -1349,7 +1349,38 @@ paths:
|
|||||||
application/json:
|
application/json:
|
||||||
schema:
|
schema:
|
||||||
$ref: '#/components/schemas/SimpleStatusResponse'
|
$ref: '#/components/schemas/SimpleStatusResponse'
|
||||||
|
delete:
|
||||||
|
security:
|
||||||
|
- API_TOKEN: []
|
||||||
|
tags:
|
||||||
|
- task
|
||||||
|
parameters:
|
||||||
|
- name: taskID
|
||||||
|
in: path
|
||||||
|
description: internal id of task
|
||||||
|
required: true
|
||||||
|
schema:
|
||||||
|
type: number
|
||||||
|
example: 1
|
||||||
|
responses:
|
||||||
|
200:
|
||||||
|
description: Operation successfull
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
$ref: '#/components/schemas/SimpleStatusResponse'
|
||||||
|
403:
|
||||||
|
description: No permission
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
$ref: '#/components/schemas/SimpleStatusResponse'
|
||||||
|
404:
|
||||||
|
description: Task not found
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
$ref: '#/components/schemas/SimpleStatusResponse'
|
||||||
|
|
||||||
|
|
||||||
/schedules:
|
/schedules:
|
||||||
|
Loading…
Reference in New Issue
Block a user