diff options
author | crupest <crupest@outlook.com> | 2020-02-24 16:52:19 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2020-02-24 16:52:19 +0800 |
commit | bcae79d0b753cccecffac3ae3c7f049b56a8d800 (patch) | |
tree | 15a9ecbe1339813d59af04b571f350043df36abc /Timeline/Controllers | |
parent | 4475246be00d0f9d1a5df6c181589ed0b2a7009b (diff) | |
download | timeline-bcae79d0b753cccecffac3ae3c7f049b56a8d800.tar.gz timeline-bcae79d0b753cccecffac3ae3c7f049b56a8d800.tar.bz2 timeline-bcae79d0b753cccecffac3ae3c7f049b56a8d800.zip |
Add delete timeline.
Diffstat (limited to 'Timeline/Controllers')
-rw-r--r-- | Timeline/Controllers/TimelineController.cs | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/Timeline/Controllers/TimelineController.cs b/Timeline/Controllers/TimelineController.cs index 9ada16e0..85ccb5c1 100644 --- a/Timeline/Controllers/TimelineController.cs +++ b/Timeline/Controllers/TimelineController.cs @@ -206,5 +206,25 @@ namespace Timeline.Controllers return BadRequest(ErrorResponse.TimelineCommon.NameConflict());
}
}
+
+ [HttpDelete("timelines/{name}")]
+ [Authorize]
+ public async Task<ActionResult<TimelineInfo>> TimelineDelete([FromRoute][TimelineName] string name)
+ {
+ if (!this.IsAdministrator() && !(await _service.HasManagePermission(name, this.GetUserId())))
+ {
+ return StatusCode(StatusCodes.Status403Forbidden, ErrorResponse.Common.Forbid());
+ }
+
+ try
+ {
+ await _service.DeleteTimeline(name);
+ return Ok(CommonDeleteResponse.Delete());
+ }
+ catch (TimelineNotExistException)
+ {
+ return Ok(CommonDeleteResponse.NotExist());
+ }
+ }
}
}
|