aboutsummaryrefslogtreecommitdiff
path: root/Timeline/Models/Http
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2020-02-04 18:02:39 +0800
committercrupest <crupest@outlook.com>2020-02-04 18:02:39 +0800
commit3cbb2e7ef4bb2ccbbaadd18e49e2de392d6db2e1 (patch)
tree458d802973d4768e4bd5d463540608404b86c309 /Timeline/Models/Http
parente5cf0da3976116cd575e884fb8f191f225fe9301 (diff)
downloadtimeline-3cbb2e7ef4bb2ccbbaadd18e49e2de392d6db2e1.tar.gz
timeline-3cbb2e7ef4bb2ccbbaadd18e49e2de392d6db2e1.tar.bz2
timeline-3cbb2e7ef4bb2ccbbaadd18e49e2de392d6db2e1.zip
Add get timeline list feature.
Diffstat (limited to 'Timeline/Models/Http')
-rw-r--r--Timeline/Models/Http/ErrorResponse.cs15
-rw-r--r--Timeline/Models/Http/TimelineCommon.cs35
2 files changed, 30 insertions, 20 deletions
diff --git a/Timeline/Models/Http/ErrorResponse.cs b/Timeline/Models/Http/ErrorResponse.cs
index 0d23fe59..9f7e70e1 100644
--- a/Timeline/Models/Http/ErrorResponse.cs
+++ b/Timeline/Models/Http/ErrorResponse.cs
@@ -277,6 +277,21 @@ namespace Timeline.Models.Http
}
+ public static class TimelineController
+ {
+
+ public static CommonResponse QueryRelateNotExist(params object?[] formatArgs)
+ {
+ return new CommonResponse(ErrorCodes.TimelineController.QueryRelateNotExist, string.Format(TimelineController_QueryRelateNotExist, formatArgs));
+ }
+
+ public static CommonResponse CustomMessage_QueryRelateNotExist(string message, params object?[] formatArgs)
+ {
+ return new CommonResponse(ErrorCodes.TimelineController.QueryRelateNotExist, string.Format(message, formatArgs));
+ }
+
+ }
+
}
}
diff --git a/Timeline/Models/Http/TimelineCommon.cs b/Timeline/Models/Http/TimelineCommon.cs
index 6b857862..d0dfd837 100644
--- a/Timeline/Models/Http/TimelineCommon.cs
+++ b/Timeline/Models/Http/TimelineCommon.cs
@@ -53,34 +53,29 @@ namespace Timeline.Models.Http
public static class TimelineInfoExtensions
{
- public static TimelineInfo FillLinksForPersonalTimeline(this TimelineInfo info, IUrlHelper urlHelper)
+ public static TimelineInfo FillLinks(this TimelineInfo info, IUrlHelper urlHelper)
{
if (info == null)
throw new ArgumentNullException(nameof(info));
if (urlHelper == null)
throw new ArgumentNullException(nameof(urlHelper));
- info._links = new TimelineInfoLinks
+ if (string.IsNullOrEmpty(info.Name))
{
- Self = urlHelper.ActionLink(nameof(PersonalTimelineController.TimelineGet), nameof(PersonalTimelineController)[0..^nameof(Controller).Length], new { info.Owner.Username }),
- Posts = urlHelper.ActionLink(nameof(PersonalTimelineController.PostListGet), nameof(PersonalTimelineController)[0..^nameof(Controller).Length], new { info.Owner.Username })
- };
-
- return info;
- }
-
- public static TimelineInfo FillLinksForNormalTimeline(this TimelineInfo info, IUrlHelper urlHelper)
- {
- if (info == null)
- throw new ArgumentNullException(nameof(info));
- if (urlHelper == null)
- throw new ArgumentNullException(nameof(urlHelper));
-
- info._links = new TimelineInfoLinks
+ info._links = new TimelineInfoLinks
+ {
+ Self = urlHelper.ActionLink(nameof(PersonalTimelineController.TimelineGet), nameof(PersonalTimelineController)[0..^nameof(Controller).Length], new { info.Owner.Username }),
+ Posts = urlHelper.ActionLink(nameof(PersonalTimelineController.PostListGet), nameof(PersonalTimelineController)[0..^nameof(Controller).Length], new { info.Owner.Username })
+ };
+ }
+ else
{
- Self = urlHelper.ActionLink(nameof(TimelineController.TimelineGet), nameof(TimelineController)[0..^nameof(Controller).Length], new { info.Name }),
- Posts = urlHelper.ActionLink(nameof(TimelineController.PostListGet), nameof(TimelineController)[0..^nameof(Controller).Length], new { info.Name })
- };
+ info._links = new TimelineInfoLinks
+ {
+ Self = urlHelper.ActionLink(nameof(TimelineController.TimelineGet), nameof(TimelineController)[0..^nameof(Controller).Length], new { info.Name }),
+ Posts = urlHelper.ActionLink(nameof(TimelineController.PostListGet), nameof(TimelineController)[0..^nameof(Controller).Length], new { info.Name })
+ };
+ }
return info;
}