aboutsummaryrefslogtreecommitdiff
path: root/Timeline/Filters
diff options
context:
space:
mode:
author杨宇千 <crupest@outlook.com>2019-11-20 18:21:17 +0800
committerGitHub <noreply@github.com>2019-11-20 18:21:17 +0800
commitae5bb5cbef2aec94673e26712d7937fca3996f5b (patch)
tree788b8acdf1141c757cb3226d3cd5f64594386b8f /Timeline/Filters
parent37a2e6340ab20de1f9e847d795c0cbec9846de97 (diff)
parentca87f6781a5b0e80989a66be338a699846c40f8d (diff)
downloadtimeline-ae5bb5cbef2aec94673e26712d7937fca3996f5b.tar.gz
timeline-ae5bb5cbef2aec94673e26712d7937fca3996f5b.tar.bz2
timeline-ae5bb5cbef2aec94673e26712d7937fca3996f5b.zip
Merge pull request #54 from crupest/timeline
Add core feature Timeline (currently only personal timeline)
Diffstat (limited to 'Timeline/Filters')
-rw-r--r--Timeline/Filters/Timeline.cs47
1 files changed, 47 insertions, 0 deletions
diff --git a/Timeline/Filters/Timeline.cs b/Timeline/Filters/Timeline.cs
new file mode 100644
index 00000000..7859d409
--- /dev/null
+++ b/Timeline/Filters/Timeline.cs
@@ -0,0 +1,47 @@
+using Microsoft.AspNetCore.Mvc;
+using Microsoft.AspNetCore.Mvc.Filters;
+using Timeline.Models.Http;
+using Timeline.Services;
+using static Timeline.Resources.Filters;
+
+namespace Timeline
+{
+ public static partial class ErrorCodes
+ {
+ public static partial class Http
+ {
+ public static partial class Filter // bxx = 1xx
+ {
+ public static class Timeline // bbb = 102
+ {
+ public const int UserNotExist = 11020101;
+ public const int NameNotExist = 11020102;
+ }
+ }
+ }
+ }
+}
+
+namespace Timeline.Filters
+{
+ public class CatchTimelineNotExistExceptionAttribute : ExceptionFilterAttribute
+ {
+ [System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1062:Validate arguments of public methods")]
+ public override void OnException(ExceptionContext context)
+ {
+ if (context.Exception is TimelineNotExistException e)
+ {
+ if (e.InnerException is UserNotExistException)
+ {
+ context.Result = new BadRequestObjectResult(
+ new CommonResponse(ErrorCodes.Http.Filter.Timeline.UserNotExist, MessageTimelineNotExistUser));
+ }
+ else
+ {
+ context.Result = new BadRequestObjectResult(
+ new CommonResponse(ErrorCodes.Http.Filter.Timeline.NameNotExist, MessageTimelineNotExist));
+ }
+ }
+ }
+ }
+}