issue-6 #8

Merged
sebastian merged 12 commits from issue-6 into master 2023-09-25 13:18:06 +02:00
2 changed files with 19 additions and 0 deletions
Showing only changes of commit ad407fb525 - Show all commits

View File

@ -55,4 +55,19 @@ public class TaskgroupController {
return ResponseEntity.status(409).body(new SimpleStatusResponse("failed"));
}
}
@DeleteMapping("/taskgroups/{taskgroupID}")
public ResponseEntity<?> deleteTaskgroup(@PathVariable long taskgroupID) {
PermissionResult<Taskgroup> taskgroupPermissionResult = taskgroupService.getTaskgroupByIDAndUsername(taskgroupID, SecurityContextHolder.getContext().getAuthentication().getName());
if (!taskgroupPermissionResult.isHasPermissions()) {
return ResponseEntity.status(403).body(new SimpleStatusResponse("failed"));
}
if(taskgroupPermissionResult.getExitCode() == ServiceExitCode.MISSING_ENTITY) {
return ResponseEntity.status(404).body(new SimpleStatusResponse("failed"));
}
taskgroupService.deleteTaskgroup(taskgroupPermissionResult.getResult());
return ResponseEntity.ok(new SimpleStatusResponse("success"));
}
}

View File

@ -62,4 +62,8 @@ public class TaskgroupService {
return ServiceExitCode.OK;
}
}
public void deleteTaskgroup(Taskgroup taskgroup) {
taskgroupRepository.delete(taskgroup);
}
}