aboutsummaryrefslogtreecommitdiff
path: root/BackEnd/Timeline/Controllers
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2020-12-17 23:09:24 +0800
committercrupest <crupest@outlook.com>2020-12-17 23:09:24 +0800
commita0f8b2ba0d41678b09bff2adaac94e5bac717b9b (patch)
treebc4c4e681ebd63a69e711f4aec995f9b51f00864 /BackEnd/Timeline/Controllers
parentfb7e9fdc042fa14656a6cdd21f4b002d92badb29 (diff)
downloadtimeline-a0f8b2ba0d41678b09bff2adaac94e5bac717b9b.tar.gz
timeline-a0f8b2ba0d41678b09bff2adaac94e5bac717b9b.tar.bz2
timeline-a0f8b2ba0d41678b09bff2adaac94e5bac717b9b.zip
...
Diffstat (limited to 'BackEnd/Timeline/Controllers')
-rw-r--r--BackEnd/Timeline/Controllers/HighlightTimelineController.cs52
1 files changed, 48 insertions, 4 deletions
diff --git a/BackEnd/Timeline/Controllers/HighlightTimelineController.cs b/BackEnd/Timeline/Controllers/HighlightTimelineController.cs
index 3819bfc4..0b6e1665 100644
--- a/BackEnd/Timeline/Controllers/HighlightTimelineController.cs
+++ b/BackEnd/Timeline/Controllers/HighlightTimelineController.cs
@@ -15,7 +15,6 @@ namespace Timeline.Controllers
/// </summary>
[ApiController]
[ProducesErrorResponseType(typeof(CommonResponse))]
- [Route("highlights")]
public class HighlightTimelineController : Controller
{
private readonly IHighlightTimelineService _service;
@@ -31,7 +30,7 @@ namespace Timeline.Controllers
/// Get all highlight timelines.
/// </summary>
/// <returns>Highlight timeline list.</returns>
- [HttpGet]
+ [HttpGet("highlights")]
[ProducesResponseType(200)]
public async Task<ActionResult<List<HttpTimeline>>> List()
{
@@ -42,8 +41,8 @@ namespace Timeline.Controllers
/// <summary>
/// Add a timeline to highlight list.
/// </summary>
- /// <param name="timeline"></param>
- [HttpPut("{timeline}")]
+ /// <param name="timeline">The timeline name.</param>
+ [HttpPut("highlights/{timeline}")]
[PermissionAuthorize(UserPermission.HighlightTimelineManagement)]
[ProducesResponseType(200)]
[ProducesResponseType(400)]
@@ -59,5 +58,50 @@ namespace Timeline.Controllers
return BadRequest(ErrorResponse.TimelineController.NotExist());
}
}
+
+ /// <summary>
+ /// Remove a timeline from highlight list.
+ /// </summary>
+ /// <param name="timeline">Timeline name.</param>
+ [HttpDelete("highlights/{timeline}")]
+ [PermissionAuthorize(UserPermission.HighlightTimelineManagement)]
+ [ProducesResponseType(200)]
+ [ProducesResponseType(400)]
+ public async Task<ActionResult> Delete([GeneralTimelineName] string timeline)
+ {
+ try
+ {
+ await _service.RemoveHighlightTimeline(timeline, this.GetUserId());
+ return Ok();
+ }
+ catch (TimelineNotExistException)
+ {
+ return BadRequest(ErrorResponse.TimelineController.NotExist());
+ }
+ }
+
+ /// <summary>
+ /// Move a highlight position.
+ /// </summary>
+ [HttpPost("highlightop/move")]
+ [PermissionAuthorize(UserPermission.HighlightTimelineManagement)]
+ [ProducesResponseType(200)]
+ [ProducesResponseType(400)]
+ public async Task<ActionResult> Move([FromBody] HttpHighlightTimelineMoveRequest body)
+ {
+ try
+ {
+ await _service.MoveHighlightTimeline(body.Timeline, body.NewPosition!.Value);
+ return Ok();
+ }
+ catch (TimelineNotExistException)
+ {
+ return BadRequest(ErrorResponse.TimelineController.NotExist());
+ }
+ catch (InvalidHighlightTimelineException)
+ {
+ return BadRequest(new CommonResponse(ErrorCodes.HighlightTimelineController.NonHighlight, "Can't move a non-highlight timeline."));
+ }
+ }
}
}