aboutsummaryrefslogtreecommitdiff
path: root/Timeline/Models
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2020-01-21 01:11:17 +0800
committercrupest <crupest@outlook.com>2020-01-21 01:11:17 +0800
commit4aadb05cd5718c7d16bf432c96e23ae4e7db4783 (patch)
treea45506852659b9d8e2bfe0b9e58a496060f7cd9b /Timeline/Models
parente6069a6980ec6d2505e19026d4c84a9588f153dc (diff)
downloadtimeline-4aadb05cd5718c7d16bf432c96e23ae4e7db4783.tar.gz
timeline-4aadb05cd5718c7d16bf432c96e23ae4e7db4783.tar.bz2
timeline-4aadb05cd5718c7d16bf432c96e23ae4e7db4783.zip
...
Diffstat (limited to 'Timeline/Models')
-rw-r--r--Timeline/Models/Http/Token.cs4
-rw-r--r--Timeline/Models/Http/User.cs6
-rw-r--r--Timeline/Models/UserInfo.cs23
-rw-r--r--Timeline/Models/UserRoleConvert.cs (renamed from Timeline/Models/UserConvert.cs)23
4 files changed, 13 insertions, 43 deletions
diff --git a/Timeline/Models/Http/Token.cs b/Timeline/Models/Http/Token.cs
index ea8b59ed..0649f1d1 100644
--- a/Timeline/Models/Http/Token.cs
+++ b/Timeline/Models/Http/Token.cs
@@ -16,7 +16,7 @@ namespace Timeline.Models.Http
public class CreateTokenResponse
{
public string Token { get; set; } = default!;
- public UserInfo User { get; set; } = default!;
+ public User User { get; set; } = default!;
}
public class VerifyTokenRequest
@@ -27,6 +27,6 @@ namespace Timeline.Models.Http
public class VerifyTokenResponse
{
- public UserInfo User { get; set; } = default!;
+ public User User { get; set; } = default!;
}
}
diff --git a/Timeline/Models/Http/User.cs b/Timeline/Models/Http/User.cs
index 516c1329..69bfacf2 100644
--- a/Timeline/Models/Http/User.cs
+++ b/Timeline/Models/Http/User.cs
@@ -3,6 +3,12 @@ using Timeline.Models.Validation;
namespace Timeline.Models.Http
{
+ public class User
+ {
+ public string Username { get; set; } = default!;
+ public bool Administrator { get; set; }
+ }
+
public class UserPutRequest
{
[Required]
diff --git a/Timeline/Models/UserInfo.cs b/Timeline/Models/UserInfo.cs
index b60bdfa2..eff47329 100644
--- a/Timeline/Models/UserInfo.cs
+++ b/Timeline/Models/UserInfo.cs
@@ -1,23 +1,10 @@
-namespace Timeline.Models
+namespace Timeline.Models
{
- public sealed class UserInfo
+ public class UserInfo
{
- public UserInfo()
- {
- }
-
- public UserInfo(string username, bool administrator)
- {
- Username = username;
- Administrator = administrator;
- }
-
+ public long Id { get; set; }
+ public long Version { get; set; }
public string Username { get; set; } = default!;
- public bool Administrator { get; set; } = default!;
-
- public override string ToString()
- {
- return $"Username: {Username} ; Administrator: {Administrator}";
- }
+ public bool Administrator { get; set; }
}
}
diff --git a/Timeline/Models/UserConvert.cs b/Timeline/Models/UserRoleConvert.cs
index 5b132421..ade9a799 100644
--- a/Timeline/Models/UserConvert.cs
+++ b/Timeline/Models/UserRoleConvert.cs
@@ -2,32 +2,9 @@ using System;
using System.Collections.Generic;
using System.Linq;
using Timeline.Entities;
-using Timeline.Services;
namespace Timeline.Models
{
- public static class UserConvert
- {
- public static UserInfo CreateUserInfo(User user)
- {
- if (user == null)
- throw new ArgumentNullException(nameof(user));
- return new UserInfo(user.Name, UserRoleConvert.ToBool(user.RoleString));
- }
-
- internal static UserCache CreateUserCache(User user)
- {
- if (user == null)
- throw new ArgumentNullException(nameof(user));
- return new UserCache
- {
- Username = user.Name,
- Administrator = UserRoleConvert.ToBool(user.RoleString),
- Version = user.Version
- };
- }
- }
-
[System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1062:Validate arguments of public methods", Justification = "No need.")]
public static class UserRoleConvert
{