aboutsummaryrefslogtreecommitdiff
path: root/Timeline
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2020-02-03 18:18:45 +0800
committercrupest <crupest@outlook.com>2020-02-03 18:18:45 +0800
commitbe8cbe2c4ddf2076cc02bcb2feb1a70d30a4bda0 (patch)
tree28ef20f9dfe742008bb934f09b99d1d4719cabaa /Timeline
parent5f93daed17338abbcade5eaba8936acbc4955b56 (diff)
downloadtimeline-be8cbe2c4ddf2076cc02bcb2feb1a70d30a4bda0.tar.gz
timeline-be8cbe2c4ddf2076cc02bcb2feb1a70d30a4bda0.tar.bz2
timeline-be8cbe2c4ddf2076cc02bcb2feb1a70d30a4bda0.zip
Finish normal timeline development.
Diffstat (limited to 'Timeline')
-rw-r--r--Timeline/Controllers/TimelineController.cs9
-rw-r--r--Timeline/Services/TimelineService.cs1
-rw-r--r--Timeline/Startup.cs1
3 files changed, 8 insertions, 3 deletions
diff --git a/Timeline/Controllers/TimelineController.cs b/Timeline/Controllers/TimelineController.cs
index d46189b8..a514ccd9 100644
--- a/Timeline/Controllers/TimelineController.cs
+++ b/Timeline/Controllers/TimelineController.cs
@@ -4,6 +4,7 @@ using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using System.Collections.Generic;
using System.Threading.Tasks;
+using Timeline.Filters;
using Timeline.Models.Http;
using Timeline.Models.Validation;
using Timeline.Services;
@@ -11,6 +12,7 @@ using Timeline.Services;
namespace Timeline.Controllers
{
[ApiController]
+ [CatchTimelineNotExistException]
public class TimelineController : Controller
{
private readonly ILogger<TimelineController> _logger;
@@ -26,7 +28,8 @@ namespace Timeline.Controllers
[HttpGet("timelines/{name}")]
public async Task<ActionResult<TimelineInfo>> TimelineGet([FromRoute][TimelineName] string name)
{
- return (await _service.GetTimeline(name)).FillLinksForNormalTimeline(Url);
+ var result = (await _service.GetTimeline(name)).FillLinksForNormalTimeline(Url);
+ return Ok(result);
}
[HttpGet("timelines/{name}/posts")]
@@ -128,13 +131,13 @@ namespace Timeline.Controllers
[HttpPost("timelines")]
[Authorize]
- public async Task<ActionResult<TimelineInfo>> TimelineCreate([FromRoute] TimelineCreateRequest body)
+ public async Task<ActionResult<TimelineInfo>> TimelineCreate([FromBody] TimelineCreateRequest body)
{
var userId = this.GetUserId();
try
{
- var timelineInfo = await _service.CreateTimeline(body.Name, userId);
+ var timelineInfo = (await _service.CreateTimeline(body.Name, userId)).FillLinksForNormalTimeline(Url);
return Ok(timelineInfo);
}
catch (ConflictException)
diff --git a/Timeline/Services/TimelineService.cs b/Timeline/Services/TimelineService.cs
index 991669ad..6f9d437e 100644
--- a/Timeline/Services/TimelineService.cs
+++ b/Timeline/Services/TimelineService.cs
@@ -322,6 +322,7 @@ namespace Timeline.Services
return new TimelineInfo
{
+ Name = timelineEntity.Name,
Description = timelineEntity.Description ?? "",
Owner = owner,
Visibility = timelineEntity.Visibility,
diff --git a/Timeline/Startup.cs b/Timeline/Startup.cs
index 86349a27..2640a061 100644
--- a/Timeline/Startup.cs
+++ b/Timeline/Startup.cs
@@ -89,6 +89,7 @@ namespace Timeline
services.AddScoped<IUserTokenManager, UserTokenManager>();
services.AddUserAvatarService();
+ services.AddScoped<ITimelineService, TimelineService>();
services.AddScoped<IPersonalTimelineService, PersonalTimelineService>();
services.TryAddSingleton<IActionContextAccessor, ActionContextAccessor>();