diff options
author | crupest <crupest@outlook.com> | 2020-01-18 00:50:31 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2020-01-18 00:50:31 +0800 |
commit | c5f3c69b3a008ab87542e523e2a59f37801bd65a (patch) | |
tree | 8479cc9af91a7e7b1c0c60a0abc778244359bdbd /Timeline/Models/Http | |
parent | 289c7e1fada1f4dae6ce5e421e997ebddd55c2df (diff) | |
download | timeline-c5f3c69b3a008ab87542e523e2a59f37801bd65a.tar.gz timeline-c5f3c69b3a008ab87542e523e2a59f37801bd65a.tar.bz2 timeline-c5f3c69b3a008ab87542e523e2a59f37801bd65a.zip |
...
Diffstat (limited to 'Timeline/Models/Http')
-rw-r--r-- | Timeline/Models/Http/Common.cs | 33 | ||||
-rw-r--r-- | Timeline/Models/Http/ErrorResponse.cs | 261 | ||||
-rw-r--r-- | Timeline/Models/Http/Timeline.cs | 3 |
3 files changed, 261 insertions, 36 deletions
diff --git a/Timeline/Models/Http/Common.cs b/Timeline/Models/Http/Common.cs index d1e95397..a9fc8a79 100644 --- a/Timeline/Models/Http/Common.cs +++ b/Timeline/Models/Http/Common.cs @@ -1,15 +1,9 @@ -using System.Globalization;
using static Timeline.Resources.Models.Http.Common;
namespace Timeline.Models.Http
{
public class CommonResponse
{
- internal static CommonResponse InvalidModel(string message)
- {
- return new CommonResponse(ErrorCodes.Http.Common.InvalidModel, message);
- }
-
public CommonResponse()
{
@@ -25,33 +19,6 @@ namespace Timeline.Models.Http public string? Message { get; set; }
}
- internal static class HeaderErrorResponse
- {
- internal static CommonResponse BadIfNonMatch()
- {
- return new CommonResponse(ErrorCodes.Http.Common.Header.IfNonMatch.BadFormat, MessageHeaderIfNonMatchBad);
- }
- }
-
- internal static class ContentErrorResponse
- {
- internal static CommonResponse TooBig(string maxLength)
- {
- return new CommonResponse(ErrorCodes.Http.Common.Content.TooBig,
- string.Format(CultureInfo.CurrentCulture, MessageContentTooBig, maxLength));
- }
-
- internal static CommonResponse UnmatchedLength_Smaller()
- {
- return new CommonResponse(ErrorCodes.Http.Common.Content.UnmatchedLength_Smaller, MessageContentUnmatchedLengthSmaller);
- }
- internal static CommonResponse UnmatchedLength_Bigger()
- {
- return new CommonResponse(ErrorCodes.Http.Common.Content.UnmatchedLength_Bigger, MessageContentUnmatchedLengthBigger);
- }
- }
-
-
public class CommonDataResponse<T> : CommonResponse
{
public CommonDataResponse()
diff --git a/Timeline/Models/Http/ErrorResponse.cs b/Timeline/Models/Http/ErrorResponse.cs new file mode 100644 index 00000000..6a53e0c3 --- /dev/null +++ b/Timeline/Models/Http/ErrorResponse.cs @@ -0,0 +1,261 @@ +using static Timeline.Resources.Messages;
+
+namespace Timeline.Models.Http
+{
+
+ public static class ErrorResponse
+ {
+
+ public static class Common
+ {
+
+ public static CommonResponse InvalidModel(params object?[] formatArgs)
+ {
+ return new CommonResponse(ErrorCodes.Common.InvalidModel, string.Format(Common_InvalidModel, formatArgs));
+ }
+
+ public static CommonResponse CustomMessage_InvalidModel(string message, params object?[] formatArgs)
+ {
+ return new CommonResponse(ErrorCodes.Common.InvalidModel, string.Format(message, formatArgs));
+ }
+
+ public static CommonResponse Forbid(params object?[] formatArgs)
+ {
+ return new CommonResponse(ErrorCodes.Common.Forbid, string.Format(Common_Forbid, formatArgs));
+ }
+
+ public static CommonResponse CustomMessage_Forbid(string message, params object?[] formatArgs)
+ {
+ return new CommonResponse(ErrorCodes.Common.Forbid, string.Format(message, formatArgs));
+ }
+
+ public static class Header
+ {
+
+ public static CommonResponse IfNonMatch_BadFormat(params object?[] formatArgs)
+ {
+ return new CommonResponse(ErrorCodes.Common.Header.IfNonMatch_BadFormat, string.Format(Common_Header_IfNonMatch_BadFormat, formatArgs));
+ }
+
+ public static CommonResponse CustomMessage_IfNonMatch_BadFormat(string message, params object?[] formatArgs)
+ {
+ return new CommonResponse(ErrorCodes.Common.Header.IfNonMatch_BadFormat, string.Format(message, formatArgs));
+ }
+
+ public static CommonResponse ContentType_Missing(params object?[] formatArgs)
+ {
+ return new CommonResponse(ErrorCodes.Common.Header.ContentType_Missing, string.Format(Common_Header_ContentType_Missing, formatArgs));
+ }
+
+ public static CommonResponse CustomMessage_ContentType_Missing(string message, params object?[] formatArgs)
+ {
+ return new CommonResponse(ErrorCodes.Common.Header.ContentType_Missing, string.Format(message, formatArgs));
+ }
+
+ public static CommonResponse ContentLength_Missing(params object?[] formatArgs)
+ {
+ return new CommonResponse(ErrorCodes.Common.Header.ContentLength_Missing, string.Format(Common_Header_ContentLength_Missing, formatArgs));
+ }
+
+ public static CommonResponse CustomMessage_ContentLength_Missing(string message, params object?[] formatArgs)
+ {
+ return new CommonResponse(ErrorCodes.Common.Header.ContentLength_Missing, string.Format(message, formatArgs));
+ }
+
+ public static CommonResponse ContentLength_Zero(params object?[] formatArgs)
+ {
+ return new CommonResponse(ErrorCodes.Common.Header.ContentLength_Zero, string.Format(Common_Header_ContentLength_Zero, formatArgs));
+ }
+
+ public static CommonResponse CustomMessage_ContentLength_Zero(string message, params object?[] formatArgs)
+ {
+ return new CommonResponse(ErrorCodes.Common.Header.ContentLength_Zero, string.Format(message, formatArgs));
+ }
+
+ }
+
+ public static class Content
+ {
+
+ public static CommonResponse TooBig(params object?[] formatArgs)
+ {
+ return new CommonResponse(ErrorCodes.Common.Content.TooBig, string.Format(Common_Content_TooBig, formatArgs));
+ }
+
+ public static CommonResponse CustomMessage_TooBig(string message, params object?[] formatArgs)
+ {
+ return new CommonResponse(ErrorCodes.Common.Content.TooBig, string.Format(message, formatArgs));
+ }
+
+ public static CommonResponse UnmatchedLength_Smaller(params object?[] formatArgs)
+ {
+ return new CommonResponse(ErrorCodes.Common.Content.UnmatchedLength_Smaller, string.Format(Common_Content_UnmatchedLength_Smaller, formatArgs));
+ }
+
+ public static CommonResponse CustomMessage_UnmatchedLength_Smaller(string message, params object?[] formatArgs)
+ {
+ return new CommonResponse(ErrorCodes.Common.Content.UnmatchedLength_Smaller, string.Format(message, formatArgs));
+ }
+
+ public static CommonResponse UnmatchedLength_Bigger(params object?[] formatArgs)
+ {
+ return new CommonResponse(ErrorCodes.Common.Content.UnmatchedLength_Bigger, string.Format(Common_Content_UnmatchedLength_Bigger, formatArgs));
+ }
+
+ public static CommonResponse CustomMessage_UnmatchedLength_Bigger(string message, params object?[] formatArgs)
+ {
+ return new CommonResponse(ErrorCodes.Common.Content.UnmatchedLength_Bigger, string.Format(message, formatArgs));
+ }
+
+ }
+
+ }
+
+ public static class UserCommon
+ {
+
+ public static CommonResponse NotExist(params object?[] formatArgs)
+ {
+ return new CommonResponse(ErrorCodes.UserCommon.NotExist, string.Format(UserCommon_NotExist, formatArgs));
+ }
+
+ public static CommonResponse CustomMessage_NotExist(string message, params object?[] formatArgs)
+ {
+ return new CommonResponse(ErrorCodes.UserCommon.NotExist, string.Format(message, formatArgs));
+ }
+
+ }
+
+ public static class TokenController
+ {
+
+ public static CommonResponse Create_BadCredential(params object?[] formatArgs)
+ {
+ return new CommonResponse(ErrorCodes.TokenController.Create_BadCredential, string.Format(TokenController_Create_BadCredential, formatArgs));
+ }
+
+ public static CommonResponse CustomMessage_Create_BadCredential(string message, params object?[] formatArgs)
+ {
+ return new CommonResponse(ErrorCodes.TokenController.Create_BadCredential, string.Format(message, formatArgs));
+ }
+
+ public static CommonResponse Verify_BadFormat(params object?[] formatArgs)
+ {
+ return new CommonResponse(ErrorCodes.TokenController.Verify_BadFormat, string.Format(TokenController_Verify_BadFormat, formatArgs));
+ }
+
+ public static CommonResponse CustomMessage_Verify_BadFormat(string message, params object?[] formatArgs)
+ {
+ return new CommonResponse(ErrorCodes.TokenController.Verify_BadFormat, string.Format(message, formatArgs));
+ }
+
+ public static CommonResponse Verify_UserNotExist(params object?[] formatArgs)
+ {
+ return new CommonResponse(ErrorCodes.TokenController.Verify_UserNotExist, string.Format(TokenController_Verify_UserNotExist, formatArgs));
+ }
+
+ public static CommonResponse CustomMessage_Verify_UserNotExist(string message, params object?[] formatArgs)
+ {
+ return new CommonResponse(ErrorCodes.TokenController.Verify_UserNotExist, string.Format(message, formatArgs));
+ }
+
+ public static CommonResponse Verify_OldVersion(params object?[] formatArgs)
+ {
+ return new CommonResponse(ErrorCodes.TokenController.Verify_OldVersion, string.Format(TokenController_Verify_OldVersion, formatArgs));
+ }
+
+ public static CommonResponse CustomMessage_Verify_OldVersion(string message, params object?[] formatArgs)
+ {
+ return new CommonResponse(ErrorCodes.TokenController.Verify_OldVersion, string.Format(message, formatArgs));
+ }
+
+ public static CommonResponse Verify_TimeExpired(params object?[] formatArgs)
+ {
+ return new CommonResponse(ErrorCodes.TokenController.Verify_TimeExpired, string.Format(TokenController_Verify_TimeExpired, formatArgs));
+ }
+
+ public static CommonResponse CustomMessage_Verify_TimeExpired(string message, params object?[] formatArgs)
+ {
+ return new CommonResponse(ErrorCodes.TokenController.Verify_TimeExpired, string.Format(message, formatArgs));
+ }
+
+ }
+
+ public static class UserController
+ {
+
+ public static CommonResponse ChangeUsername_Conflict(params object?[] formatArgs)
+ {
+ return new CommonResponse(ErrorCodes.UserController.ChangeUsername_Conflict, string.Format(UserController_ChangeUsername_Conflict, formatArgs));
+ }
+
+ public static CommonResponse CustomMessage_ChangeUsername_Conflict(string message, params object?[] formatArgs)
+ {
+ return new CommonResponse(ErrorCodes.UserController.ChangeUsername_Conflict, string.Format(message, formatArgs));
+ }
+
+ public static CommonResponse ChangePassword_BadOldPassword(params object?[] formatArgs)
+ {
+ return new CommonResponse(ErrorCodes.UserController.ChangePassword_BadOldPassword, string.Format(UserController_ChangePassword_BadOldPassword, formatArgs));
+ }
+
+ public static CommonResponse CustomMessage_ChangePassword_BadOldPassword(string message, params object?[] formatArgs)
+ {
+ return new CommonResponse(ErrorCodes.UserController.ChangePassword_BadOldPassword, string.Format(message, formatArgs));
+ }
+
+ }
+
+ public static class UserAvatar
+ {
+
+ public static CommonResponse BadFormat_CantDecode(params object?[] formatArgs)
+ {
+ return new CommonResponse(ErrorCodes.UserAvatar.BadFormat_CantDecode, string.Format(UserAvatar_BadFormat_CantDecode, formatArgs));
+ }
+
+ public static CommonResponse CustomMessage_BadFormat_CantDecode(string message, params object?[] formatArgs)
+ {
+ return new CommonResponse(ErrorCodes.UserAvatar.BadFormat_CantDecode, string.Format(message, formatArgs));
+ }
+
+ public static CommonResponse BadFormat_UnmatchedFormat(params object?[] formatArgs)
+ {
+ return new CommonResponse(ErrorCodes.UserAvatar.BadFormat_UnmatchedFormat, string.Format(UserAvatar_BadFormat_UnmatchedFormat, formatArgs));
+ }
+
+ public static CommonResponse CustomMessage_BadFormat_UnmatchedFormat(string message, params object?[] formatArgs)
+ {
+ return new CommonResponse(ErrorCodes.UserAvatar.BadFormat_UnmatchedFormat, string.Format(message, formatArgs));
+ }
+
+ public static CommonResponse BadFormat_BadSize(params object?[] formatArgs)
+ {
+ return new CommonResponse(ErrorCodes.UserAvatar.BadFormat_BadSize, string.Format(UserAvatar_BadFormat_BadSize, formatArgs));
+ }
+
+ public static CommonResponse CustomMessage_BadFormat_BadSize(string message, params object?[] formatArgs)
+ {
+ return new CommonResponse(ErrorCodes.UserAvatar.BadFormat_BadSize, string.Format(message, formatArgs));
+ }
+
+ }
+
+ public static class TimelineController
+ {
+
+ public static CommonResponse PostOperationDelete_NotExist(params object?[] formatArgs)
+ {
+ return new CommonResponse(ErrorCodes.TimelineController.PostOperationDelete_NotExist, string.Format(TimelineController_PostOperationDelete_NotExist, formatArgs));
+ }
+
+ public static CommonResponse CustomMessage_PostOperationDelete_NotExist(string message, params object?[] formatArgs)
+ {
+ return new CommonResponse(ErrorCodes.TimelineController.PostOperationDelete_NotExist, string.Format(message, formatArgs));
+ }
+
+ }
+
+ }
+
+}
diff --git a/Timeline/Models/Http/Timeline.cs b/Timeline/Models/Http/Timeline.cs index 06b88ad1..3029434e 100644 --- a/Timeline/Models/Http/Timeline.cs +++ b/Timeline/Models/Http/Timeline.cs @@ -1,9 +1,6 @@ using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
-using System.Linq;
-using System.Threading.Tasks;
-using Timeline.Entities;
namespace Timeline.Models.Http
{
|