aboutsummaryrefslogtreecommitdiff
path: root/BackEnd
diff options
context:
space:
mode:
Diffstat (limited to 'BackEnd')
-rw-r--r--BackEnd/Timeline/Controllers/Resource.Designer.cs9
-rw-r--r--BackEnd/Timeline/Controllers/Resource.resx3
-rw-r--r--BackEnd/Timeline/Controllers/TimelineController.cs18
-rw-r--r--BackEnd/Timeline/Controllers/TimelineV2Controller.cs33
-rw-r--r--BackEnd/Timeline/Filters/CatchMultipleTimelineExceptionAttribute.cs20
-rw-r--r--BackEnd/Timeline/Filters/Resource.Designer.cs258
-rw-r--r--BackEnd/Timeline/Filters/Resource.resx3
7 files changed, 194 insertions, 150 deletions
diff --git a/BackEnd/Timeline/Controllers/Resource.Designer.cs b/BackEnd/Timeline/Controllers/Resource.Designer.cs
index 4c9da98a..eeb2f0fa 100644
--- a/BackEnd/Timeline/Controllers/Resource.Designer.cs
+++ b/BackEnd/Timeline/Controllers/Resource.Designer.cs
@@ -112,15 +112,6 @@ namespace Timeline.Controllers {
}
/// <summary>
- /// Looks up a localized string similar to Multiple timeline with the name exists. Please use new api to get timeline..
- /// </summary>
- internal static string MessageMultipleTimeline {
- get {
- return ResourceManager.GetString("MessageMultipleTimeline", resourceCulture);
- }
- }
-
- /// <summary>
/// Looks up a localized string similar to The old password is wrong..
/// </summary>
internal static string MessageOldPasswordWrong {
diff --git a/BackEnd/Timeline/Controllers/Resource.resx b/BackEnd/Timeline/Controllers/Resource.resx
index 004bd7cc..b70e5230 100644
--- a/BackEnd/Timeline/Controllers/Resource.resx
+++ b/BackEnd/Timeline/Controllers/Resource.resx
@@ -159,7 +159,4 @@
<data name="MessageUsernameConflict" xml:space="preserve">
<value>A user with given username already exists.</value>
</data>
- <data name="MessageMultipleTimeline" xml:space="preserve">
- <value>Multiple timeline with the name exists. Please use new api to get timeline.</value>
- </data>
</root> \ No newline at end of file
diff --git a/BackEnd/Timeline/Controllers/TimelineController.cs b/BackEnd/Timeline/Controllers/TimelineController.cs
index c10a8793..7aeec02f 100644
--- a/BackEnd/Timeline/Controllers/TimelineController.cs
+++ b/BackEnd/Timeline/Controllers/TimelineController.cs
@@ -21,6 +21,7 @@ namespace Timeline.Controllers
/// </summary>
[ApiController]
[Route("timelines")]
+ [CatchMultipleTimelineException]
[ProducesErrorResponseType(typeof(CommonResponse))]
public class TimelineController : MyControllerBase
{
@@ -120,18 +121,11 @@ namespace Timeline.Controllers
[ProducesResponseType(StatusCodes.Status400BadRequest)]
[ProducesResponseType(StatusCodes.Status404NotFound)]
public async Task<ActionResult<HttpTimeline>> TimelineGet([FromRoute][GeneralTimelineName] string timeline)
- {
- try
- {
- var timelineId = await _service.GetTimelineIdByNameAsync(timeline);
- var t = await _service.GetTimelineAsync(timelineId);
- var result = await Map(t);
- return result;
- }
- catch (MultipleTimelineException)
- {
- return BadRequestWithCommonResponse(ErrorCodes.TimelineController.MultipleTimelineWithSameName, Resource.MessageMultipleTimeline);
- }
+ {
+ var timelineId = await _service.GetTimelineIdByNameAsync(timeline);
+ var t = await _service.GetTimelineAsync(timelineId);
+ var result = await Map(t);
+ return result;
}
/// <summary>
diff --git a/BackEnd/Timeline/Controllers/TimelineV2Controller.cs b/BackEnd/Timeline/Controllers/TimelineV2Controller.cs
new file mode 100644
index 00000000..7543c2a8
--- /dev/null
+++ b/BackEnd/Timeline/Controllers/TimelineV2Controller.cs
@@ -0,0 +1,33 @@
+using System;
+using System.Threading.Tasks;
+using Microsoft.AspNetCore.Mvc;
+using Timeline.Entities;
+using Timeline.Models.Http;
+using Timeline.Services.Mapper;
+using Timeline.Services.Timeline;
+
+namespace Timeline.Controllers
+{
+ [ApiController]
+ [Route("v2/timelines")]
+ public class TimelineV2Controller : MyControllerBase
+ {
+ private ITimelineService _timelineService;
+ private TimelineMapper _timelineMapper;
+
+ public TimelineV2Controller(ITimelineService timelineService, TimelineMapper timelineMapper)
+ {
+ _timelineService = timelineService;
+ _timelineMapper = timelineMapper;
+ }
+
+ [HttpGet("{owner}/{timeline}")]
+ public async Task<ActionResult<HttpTimeline>> Get([FromRoute] string owner, [FromRoute] string timeline)
+ {
+ var timelineId = await _timelineService.GetTimelineIdAsync(owner, timeline);
+ var t = await _timelineService.GetTimelineAsync(timelineId);
+ return await _timelineMapper.MapAsync(t, Url, User);
+ }
+ }
+}
+
diff --git a/BackEnd/Timeline/Filters/CatchMultipleTimelineExceptionAttribute.cs b/BackEnd/Timeline/Filters/CatchMultipleTimelineExceptionAttribute.cs
new file mode 100644
index 00000000..db4a91bd
--- /dev/null
+++ b/BackEnd/Timeline/Filters/CatchMultipleTimelineExceptionAttribute.cs
@@ -0,0 +1,20 @@
+using System;
+using Microsoft.AspNetCore.Mvc;
+using Microsoft.AspNetCore.Mvc.Filters;
+using Timeline.Models.Http;
+using Timeline.Services.Timeline;
+
+namespace Timeline.Filters
+{
+ public class CatchMultipleTimelineExceptionAttribute : ExceptionFilterAttribute
+ {
+ public override void OnException(ExceptionContext context)
+ {
+ if (context.Exception is MultipleTimelineException)
+ {
+ context.Result = new BadRequestObjectResult(new CommonResponse(ErrorCodes.TimelineController.MultipleTimelineWithSameName, Resource.MessageMultipleTimeline));
+ }
+ }
+ }
+}
+
diff --git a/BackEnd/Timeline/Filters/Resource.Designer.cs b/BackEnd/Timeline/Filters/Resource.Designer.cs
index 25d0e222..d4e088cc 100644
--- a/BackEnd/Timeline/Filters/Resource.Designer.cs
+++ b/BackEnd/Timeline/Filters/Resource.Designer.cs
@@ -1,126 +1,132 @@
-//------------------------------------------------------------------------------
-// <auto-generated>
-// This code was generated by a tool.
-// Runtime Version:4.0.30319.42000
-//
-// Changes to this file may cause incorrect behavior and will be lost if
-// the code is regenerated.
-// </auto-generated>
-//------------------------------------------------------------------------------
-
-namespace Timeline.Filters {
- using System;
-
-
- /// <summary>
- /// A strongly-typed resource class, for looking up localized strings, etc.
- /// </summary>
- // This class was auto-generated by the StronglyTypedResourceBuilder
- // class via a tool like ResGen or Visual Studio.
- // To add or remove a member, edit your .ResX file then rerun ResGen
- // with the /str option, or rebuild your VS project.
- [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")]
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
- [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
- internal class Resource {
-
- private static global::System.Resources.ResourceManager resourceMan;
-
- private static global::System.Globalization.CultureInfo resourceCulture;
-
- [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
- internal Resource() {
- }
-
- /// <summary>
- /// Returns the cached ResourceManager instance used by this class.
- /// </summary>
- [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
- internal static global::System.Resources.ResourceManager ResourceManager {
- get {
- if (object.ReferenceEquals(resourceMan, null)) {
- global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Timeline.Filters.Resource", typeof(Resource).Assembly);
- resourceMan = temp;
- }
- return resourceMan;
- }
- }
-
- /// <summary>
- /// Overrides the current thread's CurrentUICulture property for all
- /// resource lookups using this strongly typed resource class.
- /// </summary>
- [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
- internal static global::System.Globalization.CultureInfo Culture {
- get {
- return resourceCulture;
- }
- set {
- resourceCulture = value;
- }
- }
-
- /// <summary>
- /// Looks up a localized string similar to Content length is too big. It can&apos;t be bigger than {0}..
- /// </summary>
- internal static string MessageContentLengthTooBig {
- get {
- return ResourceManager.GetString("MessageContentLengthTooBig", resourceCulture);
- }
- }
-
- /// <summary>
- /// Looks up a localized string similar to The entity you want to create already exists. Entity type is {0}. Constraints are {1}..
- /// </summary>
- internal static string MessageEntityAlreadyExist {
- get {
- return ResourceManager.GetString("MessageEntityAlreadyExist", resourceCulture);
- }
- }
-
- /// <summary>
- /// Looks up a localized string similar to The entity you operate on does not exist. Entity type is {0}. Constraints are {1}..
- /// </summary>
- internal static string MessageEntityNotExist {
- get {
- return ResourceManager.GetString("MessageEntityNotExist", resourceCulture);
- }
- }
-
- /// <summary>
- /// Looks up a localized string similar to Image is not a square..
- /// </summary>
- internal static string MessageImageBadSize {
- get {
- return ResourceManager.GetString("MessageImageBadSize", resourceCulture);
- }
- }
-
- /// <summary>
- /// Looks up a localized string similar to Image decode failed..
- /// </summary>
- internal static string MessageImageDecodeFailed {
- get {
- return ResourceManager.GetString("MessageImageDecodeFailed", resourceCulture);
- }
- }
-
- /// <summary>
- /// Looks up a localized string similar to Specified image format does not match the actual one ..
- /// </summary>
- internal static string MessageImageFormatUnmatch {
- get {
- return ResourceManager.GetString("MessageImageFormatUnmatch", resourceCulture);
- }
- }
-
- /// <summary>
- /// Looks up a localized string similar to Unknown error happened to image..
- /// </summary>
- internal static string MessageImageUnknownError {
- get {
- return ResourceManager.GetString("MessageImageUnknownError", resourceCulture);
- }
- }
- }
-}
+//------------------------------------------------------------------------------
+// <auto-generated>
+// This code was generated by a tool.
+//
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
+// </auto-generated>
+//------------------------------------------------------------------------------
+
+namespace Timeline.Filters {
+ using System;
+
+
+ /// <summary>
+ /// A strongly-typed resource class, for looking up localized strings, etc.
+ /// This class was generated by MSBuild using the GenerateResource task.
+ /// To add or remove a member, edit your .resx file then rerun MSBuild.
+ /// </summary>
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Build.Tasks.StronglyTypedResourceBuilder", "15.1.0.0")]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+ internal class Resource {
+
+ private static global::System.Resources.ResourceManager resourceMan;
+
+ private static global::System.Globalization.CultureInfo resourceCulture;
+
+ [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
+ internal Resource() {
+ }
+
+ /// <summary>
+ /// Returns the cached ResourceManager instance used by this class.
+ /// </summary>
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ internal static global::System.Resources.ResourceManager ResourceManager {
+ get {
+ if (object.ReferenceEquals(resourceMan, null)) {
+ global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Timeline.Filters.Resource", typeof(Resource).Assembly);
+ resourceMan = temp;
+ }
+ return resourceMan;
+ }
+ }
+
+ /// <summary>
+ /// Overrides the current thread's CurrentUICulture property for all
+ /// resource lookups using this strongly typed resource class.
+ /// </summary>
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ internal static global::System.Globalization.CultureInfo Culture {
+ get {
+ return resourceCulture;
+ }
+ set {
+ resourceCulture = value;
+ }
+ }
+
+ /// <summary>
+ /// Looks up a localized string similar to Content length is too big. It can&apos;t be bigger than {0}..
+ /// </summary>
+ internal static string MessageContentLengthTooBig {
+ get {
+ return ResourceManager.GetString("MessageContentLengthTooBig", resourceCulture);
+ }
+ }
+
+ /// <summary>
+ /// Looks up a localized string similar to The entity you want to create already exists. Entity type is {0}. Constraints are {1}..
+ /// </summary>
+ internal static string MessageEntityAlreadyExist {
+ get {
+ return ResourceManager.GetString("MessageEntityAlreadyExist", resourceCulture);
+ }
+ }
+
+ /// <summary>
+ /// Looks up a localized string similar to The entity you operate on does not exist. Entity type is {0}. Constraints are {1}..
+ /// </summary>
+ internal static string MessageEntityNotExist {
+ get {
+ return ResourceManager.GetString("MessageEntityNotExist", resourceCulture);
+ }
+ }
+
+ /// <summary>
+ /// Looks up a localized string similar to Image is not a square..
+ /// </summary>
+ internal static string MessageImageBadSize {
+ get {
+ return ResourceManager.GetString("MessageImageBadSize", resourceCulture);
+ }
+ }
+
+ /// <summary>
+ /// Looks up a localized string similar to Image decode failed..
+ /// </summary>
+ internal static string MessageImageDecodeFailed {
+ get {
+ return ResourceManager.GetString("MessageImageDecodeFailed", resourceCulture);
+ }
+ }
+
+ /// <summary>
+ /// Looks up a localized string similar to Specified image format does not match the actual one ..
+ /// </summary>
+ internal static string MessageImageFormatUnmatch {
+ get {
+ return ResourceManager.GetString("MessageImageFormatUnmatch", resourceCulture);
+ }
+ }
+
+ /// <summary>
+ /// Looks up a localized string similar to Unknown error happened to image..
+ /// </summary>
+ internal static string MessageImageUnknownError {
+ get {
+ return ResourceManager.GetString("MessageImageUnknownError", resourceCulture);
+ }
+ }
+
+ /// <summary>
+ /// Looks up a localized string similar to Multiple timeline with the name exists. Please use new api..
+ /// </summary>
+ internal static string MessageMultipleTimeline {
+ get {
+ return ResourceManager.GetString("MessageMultipleTimeline", resourceCulture);
+ }
+ }
+ }
+}
diff --git a/BackEnd/Timeline/Filters/Resource.resx b/BackEnd/Timeline/Filters/Resource.resx
index 15b13f97..92bca0e1 100644
--- a/BackEnd/Timeline/Filters/Resource.resx
+++ b/BackEnd/Timeline/Filters/Resource.resx
@@ -138,4 +138,7 @@
<data name="MessageImageUnknownError" xml:space="preserve">
<value>Unknown error happened to image.</value>
</data>
+ <data name="MessageMultipleTimeline" xml:space="preserve">
+ <value>Multiple timeline with the name exists. Please use new api.</value>
+ </data>
</root> \ No newline at end of file