Delete Taskgroup
This commit is contained in:
parent
99ae430d2b
commit
ad407fb525
@ -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"));
|
||||
}
|
||||
}
|
||||
|
@ -62,4 +62,8 @@ public class TaskgroupService {
|
||||
return ServiceExitCode.OK;
|
||||
}
|
||||
}
|
||||
|
||||
public void deleteTaskgroup(Taskgroup taskgroup) {
|
||||
taskgroupRepository.delete(taskgroup);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user