XFEExtension.NetCore.ServerInteractive
[DLL] Server interaction extension, including user identity verification and querying in conjunction with AutoConfig
关注
0
Fork
0
Star
0
返回提交历史
Modified
XFEExtension.NetCore.ServerInteractive.TServer/Services/TestCoreService.cs
+0
-1
Modified
XFEExtension.NetCore.ServerInteractive/Interfaces/IUserServiceBase.cs
+0
-18
Modified
XFEExtension.NetCore.ServerInteractive/Utilities/Server/Services/CoreService/ServerCoreUserServiceBase.cs
+13
-9
XFEstudio/XFEExtension.NetCore.ServerInteractive
重构用户服务接口与基类的职责划分
移除 IUserServiceBase 接口中的会话、设备信息、用户属性及用户校验方法声明,将相关实现和注释迁移至 ServerCoreUserServiceBase 抽象类,并将 VerifyUserInfo 方法设为 protected,简化接口职责。
e9bdb83
代码差异
3 个文件
+13
-28
@@ -11,6 +11,5 @@ public partial class TestCoreService : ServerCoreUserServiceBase
11
11
Your route is {Route};
12
12
Your IP is {ClientIP};
13
13
Your headers are {string.Join(',', Args.Request.Headers)}
14
{}
15
14
""");
16
15
}
@@ -8,18 +8,6 @@ namespace XFEExtension.NetCore.ServerInteractive.Interfaces;
8
8
/// </summary>
9
9
public interface IUserServiceBase
10
10
{
11
/// <summary>
12
/// 会话
13
/// </summary>
14
string? Session { get; }
15
/// <summary>
16
/// 设备信息
17
/// </summary>
18
string? DeviceInfo { get; }
19
/// <summary>
20
/// 当前请求的用户
21
/// </summary>
22
IUserInfo? User { get; }
23
11
/// <summary>
24
12
/// Json序列化设置
25
13
/// </summary>
@@ -48,10 +36,4 @@ public interface IUserServiceBase
48
36
/// 获取用户方法
49
37
/// </summary>
50
38
Func<IEnumerable<IUserInfo>> GetUserFunction { get; set; }
51
52
/// <summary>
53
/// 校验用户信息(仅限标准请求)
54
/// </summary>
55
/// <returns></returns>
56
(string session, string deviceInfo, IUserInfo user) VerifyUserInfo();
57
39
}
@@ -13,11 +13,17 @@ public abstract class ServerCoreUserServiceBase : ServerCoreStandardServiceBase,
13
13
{
14
14
IUserInfo? _user;
15
15
16
/// <inheritdoc/>
16
/// <summary>
17
/// 会话
18
/// </summary>
17
19
public string? Session { get => Json > "session"; }
18
/// <inheritdoc/>
20
/// <summary>
21
/// 设备信息
22
/// </summary>
19
23
public string? DeviceInfo { get => Json > "deviceInfo"; }
20
/// <inheritdoc/>
24
/// <summary>
25
/// 本次请求用户(自动校验)
26
/// </summary>
21
27
public IUserInfo? User
22
28
{
23
29
get
@@ -48,7 +54,10 @@ public abstract class ServerCoreUserServiceBase : ServerCoreStandardServiceBase,
48
54
/// <inheritdoc/>
49
55
protected ServerCoreUserServiceBase() => JsonSerializerOptions.Converters.Add(new JsonDateTimeConverter());
50
56
51
/// <inheritdoc/>
57
/// <summary>
58
/// 校验用户信息(仅限标准请求)
59
/// </summary>
60
/// <returns></returns>
52
61
protected (string session, string deviceInfo, IUserInfo user) VerifyUserInfo()
53
62
{
54
63
string session = Json > "session" ?? throw Error("用户未登录");
@@ -58,9 +67,4 @@ public abstract class ServerCoreUserServiceBase : ServerCoreStandardServiceBase,
58
67
var result = UserHelper.GetUser(session, deviceInfo, ClientIP, GetEncryptedUserLoginModelFunction(), GetUserFunction(), out var user);
59
68
return user is null ? throw Error(UserHelper.OutPutResult(result)) : (session, deviceInfo, user);
60
69
}
61
62
(string session, string deviceInfo, IUserInfo user) IUserServiceBase.VerifyUserInfo()
63
{
64
return VerifyUserInfo();
65
}
66
70
}