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/Program.cs
+20
-23
Modified
XFEExtension.NetCore.ServerInteractive/Utilities/XFEServerCoreBuilderExtensions.cs
+44
-10
Modified
XFEExtension.NetCore.ServerInteractive/Utilities/XFEStandardServerCoreOptions.cs
+1
-1
XFEstudio/XFEExtension.NetCore.ServerInteractive
优化前端展示
e88cdd9
代码差异
3 个文件
+65
-34
@@ -7,26 +7,23 @@ using XFEExtension.NetCore.ServerInteractive.Utilities;
7
7
using XFEExtension.NetCore.ServerInteractive.Utilities.DataTable;
8
8
using XFEExtension.NetCore.ServerInteractive.Utilities.Server;
9
9
10
var options = new XFEStandardServerCoreOptions<IUserFaceInfo>
11
{
12
GetUserFunction = static () => UserProfile.UserTable,
13
GetEncryptedUserLoginModelFunction = static () => UserProfile.EncryptedUserLoginModelTable,
14
AddEncryptedUserLoginModelFunction = UserProfile.EncryptedUserLoginModelTable.Add,
15
RemoveEncryptedUserLoginModelFunction = static user => UserProfile.EncryptedUserLoginModelTable.Remove(user),
16
GetLoginKeepDays = static () => 7,
17
LoginResultConvertFunction = static user => (IUserFaceInfo)user,
18
DataTableManagerBuilder = XFEDataTableManagerBuilder.CreateBuilder()
19
.AddTable<Person, DataProfile>("人物", (int)UserRole.业务员, (int)UserRole.经理, (int)UserRole.业务员, (int)UserRole.业务员)
20
.AddTable<Order, DataProfile>("订单", (int)UserRole.业务员, (int)UserRole.经理, (int)UserRole.业务员, (int)UserRole.业务员)
21
.AddTable<User, UserProfile>("用户", (int)UserRole.经理, (int)UserRole.经理, (int)UserRole.经理, (int)UserRole.业务员)
22
};
23
24
var server = XFEServerBuilder.CreateBuilder()
25
.UseXFEServer()
26
.AddServerCore(
27
XFEServerCoreBuilder.CreateBuilder()
28
.UseXFEStandardServerCore(options)
29
.Build())
30
.Build();
31
32
await server.Start();
10
var server = XFEServerBuilder.CreateBuilder() // 创建服务器构建器
11
.UseXFEServer() // 使用XFE服务器架构
12
.AddServerCore( // 添加核心服务器
13
XFEServerCoreBuilder.CreateBuilder() // 创建核心服务器构建器
14
.UseXFEStandardServerCore<IUserFaceInfo>(options =>
15
{ // 使用XFE标准服务器核心
16
options.GetUserFunction = static () => UserProfile.UserTable; // 获取用户表的方法
17
options.GetEncryptedUserLoginModelFunction = static () => UserProfile.EncryptedUserLoginModelTable; // 获取用户加密模型的方法
18
options.AddEncryptedUserLoginModelFunction = UserProfile.EncryptedUserLoginModelTable.Add; // 添加用户加密模型的方法
19
options.RemoveEncryptedUserLoginModelFunction = static user => UserProfile.EncryptedUserLoginModelTable.Remove(user); // 移除用户加密模型的方法
20
options.GetLoginKeepDays = static () => 7; // 获取登录维持天数方法
21
options.LoginResultConvertFunction = static user => (IUserFaceInfo)user; // 登录结果转换方法
22
options.DataTableManagerBuilder = XFEDataTableManagerBuilder.CreateBuilder() // 创建DataTable管理器构建器
23
.AddTable<Person, DataProfile>("人物", (int)UserRole.业务员, (int)UserRole.经理, (int)UserRole.业务员, (int)UserRole.业务员) // 添加名为人物的格, Person 类 型, AutoConfig为 DataProfile。添加更改获取权限为业务员,移除权限为经理
24
.AddTable<Order, DataProfile>("订单", (int)UserRole.业务员, (int)UserRole.经理, (int)UserRole.业务员, (int)UserRole.业务员) // 添加名为订单的表格Order 类 型, AutoConfig 为 DataProfile。添加更改获取权限为业务员,移除权限为经理
25
.AddTable<User, UserProfile>("用户", (int)UserRole.经理, (int)UserRole.经理, (int)UserRole.经理, (int)UserRole.业务员); // 添加名为用户的表格User类 型, AutoConfig为 UserProfile。获取权限为业务员,添加移除更改权限为经理
26
})
27
.Build()) // 构建核心服务器
28
.Build(); // 构建服务器
29
await server.Start(); // 启动服务
@@ -119,15 +119,49 @@ public static class XFEServerCoreBuilderExtensions
119
119
/// </summary>
120
120
public static XFEServerCoreBuilder UseXFEStandardServerCore<T>(this XFEServerCoreBuilder xFEServerCoreBuilder, XFEStandardServerCoreOptions<T> options) where T : class
121
121
{
122
ArgumentNullException.ThrowIfNull(options);
123
var dataTableBuilder = options.DataTableManagerBuilder ?? XFEDataTableManagerBuilder.CreateBuilder();
124
return xFEServerCoreBuilder.UseXFEStandardServerCore(
125
options.GetUserFunction ?? throw new ArgumentNullException(nameof(options.GetUserFunction)),
126
options.GetEncryptedUserLoginModelFunction ?? throw new ArgumentNullException(nameof(options.GetEncryptedUserLoginModelFunction)),
127
options.AddEncryptedUserLoginModelFunction ?? throw new ArgumentNullException(nameof(options.AddEncryptedUserLoginModelFunction)),
128
options.RemoveEncryptedUserLoginModelFunction ?? throw new ArgumentNullException(nameof(options.RemoveEncryptedUserLoginModelFunction)),
129
options.GetLoginKeepDays ?? throw new ArgumentNullException(nameof(options.GetLoginKeepDays)),
130
options.LoginResultConvertFunction ?? throw new ArgumentNullException(nameof(options.LoginResultConvertFunction)),
131
dataTableBuilder);
122
if (options is null) return xFEServerCoreBuilder;
123
124
// start with base builder
125
var builder = xFEServerCoreBuilder;
126
127
// If user-related functions are provided, add user parameters and login services
128
var hasUserFunctions = options.GetUserFunction is not null && options.GetEncryptedUserLoginModelFunction is not null
129
&& options.AddEncryptedUserLoginModelFunction is not null && options.RemoveEncryptedUserLoginModelFunction is not null
130
&& options.GetLoginKeepDays is not null && options.LoginResultConvertFunction is not null;
131
132
if (hasUserFunctions)
133
{
134
builder = builder.AddUserParameterBase(options.GetUserFunction!, options.GetEncryptedUserLoginModelFunction!, options.AddEncryptedUserLoginModelFunction!, options.RemoveEncryptedUserLoginModelFunction!, options.GetLoginKeepDays!, options.LoginResultConvertFunction!);
135
}
136
137
// DataTableManager requires both user functions and a builder
138
if (options.DataTableManagerBuilder is not null && options.GetUserFunction is not null && options.GetEncryptedUserLoginModelFunction is not null)
139
{
140
builder = builder.AddDataTableManager(options.DataTableManagerBuilder, options.GetUserFunction, options.GetEncryptedUserLoginModelFunction);
141
}
142
143
// Common services that don't strictly require user functions
144
builder = builder.AddEntryPotinVerify()
145
.AddDailyCounterService()
146
.AddXFEErrorProcessService()
147
.AddConnectService();
148
149
// Add services that depend on user functions if available
150
if (hasUserFunctions)
151
{
152
builder = builder.AddStandardLoginService<T>().AddServerLogService().AddIpBannerService();
153
}
154
155
return builder;
156
}
157
158
/// <summary>
159
/// 使用 XFE 标准服务器核心,提供 options lambda 初始化器
160
/// </summary>
161
public static XFEServerCoreBuilder UseXFEStandardServerCore<T>(this XFEServerCoreBuilder xFEServerCoreBuilder, Action<XFEStandardServerCoreOptions<T>> optionsBuilder) where T : class
162
{
163
var options = new XFEStandardServerCoreOptions<T>();
164
optionsBuilder?.Invoke(options);
165
return xFEServerCoreBuilder.UseXFEStandardServerCore(options);
132
166
}
133
167
}
@@ -27,7 +27,7 @@ public class XFEStandardServerCoreOptions<T> where T : class
27
27
/// <summary>
28
28
/// 获取登录保持天数函数
29
29
/// </summary>
30
public Func<int>? GetLoginKeepDays { get; set; }
30
public Func<int> GetLoginKeepDays { get; set; } = () => 7;
31
31
/// <summary>
32
32
/// 登录结果转换函数(将用户模型转换为要返回给客户端的登录结果模型)
33
33
/// </summary>