aboutsummaryrefslogtreecommitdiff
path: root/Timeline/Entities
diff options
context:
space:
mode:
author杨宇千 <crupest@outlook.com>2019-07-23 17:11:59 +0800
committer杨宇千 <crupest@outlook.com>2019-07-23 17:11:59 +0800
commit1e5ac670386614b2d88da0af198a6b3df004f1dd (patch)
tree8fcf9bdeaccac760dca563b04691bf7f0be07453 /Timeline/Entities
parentd088a03986713a71e274fc16144ca42b7f020e3f (diff)
downloadtimeline-1e5ac670386614b2d88da0af198a6b3df004f1dd.tar.gz
timeline-1e5ac670386614b2d88da0af198a6b3df004f1dd.tar.bz2
timeline-1e5ac670386614b2d88da0af198a6b3df004f1dd.zip
WIP: Rewrite TokenController.
Diffstat (limited to 'Timeline/Entities')
-rw-r--r--Timeline/Entities/Http/Common.cs22
-rw-r--r--Timeline/Entities/Http/Token.cs6
-rw-r--r--Timeline/Entities/Http/User.cs20
3 files changed, 18 insertions, 30 deletions
diff --git a/Timeline/Entities/Http/Common.cs b/Timeline/Entities/Http/Common.cs
index 9575e6fa..7708927a 100644
--- a/Timeline/Entities/Http/Common.cs
+++ b/Timeline/Entities/Http/Common.cs
@@ -1,29 +1,19 @@
namespace Timeline.Entities.Http
{
- public class ReturnCodeMessageResponse
+ public class CommonErrorResponse
{
- public ReturnCodeMessageResponse()
+ public CommonErrorResponse()
{
}
- public ReturnCodeMessageResponse(int code)
+ public CommonErrorResponse(int code, string message)
{
- ReturnCode = code;
- }
-
- public ReturnCodeMessageResponse(string message)
- {
- Message = message;
- }
-
- public ReturnCodeMessageResponse(int code, string message)
- {
- ReturnCode = code;
+ Code = code;
Message = message;
}
- public int? ReturnCode { get; set; } = null;
- public string Message { get; set; } = null;
+ public int Code { get; set; }
+ public string Message { get; set; }
}
}
diff --git a/Timeline/Entities/Http/Token.cs b/Timeline/Entities/Http/Token.cs
index 45ee0fc5..aeb9fbf2 100644
--- a/Timeline/Entities/Http/Token.cs
+++ b/Timeline/Entities/Http/Token.cs
@@ -8,9 +8,8 @@
public class CreateTokenResponse
{
- public bool Success { get; set; }
public string Token { get; set; }
- public UserInfo UserInfo { get; set; }
+ public UserInfo User { get; set; }
}
public class VerifyTokenRequest
@@ -20,7 +19,6 @@
public class VerifyTokenResponse
{
- public bool IsValid { get; set; }
- public UserInfo UserInfo { get; set; }
+ public UserInfo User { get; set; }
}
}
diff --git a/Timeline/Entities/Http/User.cs b/Timeline/Entities/Http/User.cs
index db3d5071..f5d233cd 100644
--- a/Timeline/Entities/Http/User.cs
+++ b/Timeline/Entities/Http/User.cs
@@ -17,8 +17,8 @@
public const int CreatedCode = 0;
public const int ModifiedCode = 1;
- public static ReturnCodeMessageResponse Created { get; } = new ReturnCodeMessageResponse(CreatedCode, "A new user is created.");
- public static ReturnCodeMessageResponse Modified { get; } = new ReturnCodeMessageResponse(ModifiedCode, "A existing user is modified.");
+ public static CommonErrorResponse Created { get; } = new CommonErrorResponse(CreatedCode, "A new user is created.");
+ public static CommonErrorResponse Modified { get; } = new CommonErrorResponse(ModifiedCode, "A existing user is modified.");
}
public static class UserDeleteResponse
@@ -26,8 +26,8 @@
public const int DeletedCode = 0;
public const int NotExistsCode = 1;
- public static ReturnCodeMessageResponse Deleted { get; } = new ReturnCodeMessageResponse(DeletedCode, "A existing user is deleted.");
- public static ReturnCodeMessageResponse NotExists { get; } = new ReturnCodeMessageResponse(NotExistsCode, "User with given name does not exists.");
+ public static CommonErrorResponse Deleted { get; } = new CommonErrorResponse(DeletedCode, "A existing user is deleted.");
+ public static CommonErrorResponse NotExists { get; } = new CommonErrorResponse(NotExistsCode, "User with given name does not exists.");
}
public class ChangePasswordRequest
@@ -42,9 +42,9 @@
public const int BadOldPasswordCode = 1;
public const int NotExistsCode = 2;
- public static ReturnCodeMessageResponse Success { get; } = new ReturnCodeMessageResponse(SuccessCode, "Success to change password.");
- public static ReturnCodeMessageResponse BadOldPassword { get; } = new ReturnCodeMessageResponse(BadOldPasswordCode, "Old password is wrong.");
- public static ReturnCodeMessageResponse NotExists { get; } = new ReturnCodeMessageResponse(NotExistsCode, "Username does not exists, please update token.");
+ public static CommonErrorResponse Success { get; } = new CommonErrorResponse(SuccessCode, "Success to change password.");
+ public static CommonErrorResponse BadOldPassword { get; } = new CommonErrorResponse(BadOldPasswordCode, "Old password is wrong.");
+ public static CommonErrorResponse NotExists { get; } = new CommonErrorResponse(NotExistsCode, "Username does not exists, please update token.");
}
public static class PutAvatarResponse
@@ -53,8 +53,8 @@
public const int ForbiddenCode = 1;
public const int NotExistsCode = 2;
- public static ReturnCodeMessageResponse Success { get; } = new ReturnCodeMessageResponse(SuccessCode, "Success to upload avatar.");
- public static ReturnCodeMessageResponse Forbidden { get; } = new ReturnCodeMessageResponse(ForbiddenCode, "You are not allowed to upload the user's avatar.");
- public static ReturnCodeMessageResponse NotExists { get; } = new ReturnCodeMessageResponse(NotExistsCode, "The username does not exists. If you are a user, try update your token.");
+ public static CommonErrorResponse Success { get; } = new CommonErrorResponse(SuccessCode, "Success to upload avatar.");
+ public static CommonErrorResponse Forbidden { get; } = new CommonErrorResponse(ForbiddenCode, "You are not allowed to upload the user's avatar.");
+ public static CommonErrorResponse NotExists { get; } = new CommonErrorResponse(NotExistsCode, "The username does not exists. If you are a user, try update your token.");
}
}