XFE Git
XFE Studio Git
Git 首页 全局搜索
XFE 主站 文档 NuGet

XFEExtension.NetCore.ServerInteractive

[DLL] Server interaction extension, including user identity verification and querying in conjunction with AutoConfig

公开
关注 0 Fork 0 Star 0
返回提交历史

XFEstudio/XFEExtension.NetCore.ServerInteractive

更改测试用例 优化错误输出

bc356de
XFE工作室室长 <mail@xfegzs.com>
提交于

代码差异

3 个文件 +37 -12
Modified XFEExtension.NetCore.ServerInteractive.TServer/Program.cs +32 -6
@@ -15,15 +15,12 @@ var server = XFEServerBuilder.CreateBuilder() // 创建服务器构建器
15 15 .UseXFEStandardServerCore<IUserFaceInfo>(options =>
16 16 { // 使用XFE标准服务器核心
17 17 options.GetUserFunction = static () => UserProfile.UserTable; // 获取用户表的方法
18 options.AddUserFunction = user => UserProfile.UserTable.Add(user); // 添加用户的方法
18 19 options.GetEncryptedUserLoginModelFunction = static () => UserProfile.EncryptedUserLoginModelTable; // 获取用户加密模型的方法
19 20 options.AddEncryptedUserLoginModelFunction = UserProfile.EncryptedUserLoginModelTable.Add; // 添加用户加密模型的方法
20 21 options.RemoveEncryptedUserLoginModelFunction = static user => UserProfile.EncryptedUserLoginModelTable.Remove(user); // 移除用户加密模型的方法
21 22 options.GetLoginKeepDays = static () => 7; // 获取登录维持天数方法
22 23 options.LoginResultConvertFunction = static user => (IUserFaceInfo)user; // 登录结果转换方法
23 options.DataTableManagerBuilder = XFEDataTableManagerBuilder.CreateBuilder() // 创建DataTable管理器构建器
24 .AddTable<Person, DataProfile>("人物", (int)UserRole.业务员, (int)UserRole.经理, (int)UserRole.业务员, (int)UserRole.业务员) // 添加名为人物的格, Person 类 型, AutoConfig为 DataProfile。添加更改获取权限为业务员,移除权限为经理
25 .AddTable<Order, DataProfile>("订单", (int)UserRole.业务员, (int)UserRole.经理, (int)UserRole.业务员, (int)UserRole.业务员) // 添加名为订单的表格Order 类 型, AutoConfig 为 DataProfile。添加更改获取权限为业务员,移除权限为经理
26 .AddTable<User, UserProfile>("用户", (int)UserRole.经理, (int)UserRole.经理, (int)UserRole.经理, (int)UserRole.业务员); // 添加名为用户的表格User类 型, AutoConfig为 UserProfile。获取权限为业务员,添加移除更改权限为经理
27 24 })
28 25 .AddService<TestCoreService>()
29 26 .AddService<EchoCoreService>()
@@ -33,12 +30,41 @@ var server = XFEServerBuilder.CreateBuilder() // 创建服务器构建器
33 30 .AddService<TimeCoreService>()
34 31 .Build(options =>
35 32 {
33 options.ServerCoreName = "ClientServer";
36 34 options.AcceptGet = true;
37 35 options.AcceptPost = true;
38 36 options.AcceptNonStandardJson = true;
39 37 options.MainEntryPoint = "api";
40 options.BindIP("http://localhost:3305/")
41 .BindIP("https://localhost:3306/");
38 options.BindIP("http://localhost:3301/")
39 .BindIP("https://localhost:3401/");
42 40 })) // 构建核心服务器
41 .AddServerCore(
42 XFEServerCoreBuilder.CreateBuilder()
43 .UseXFEStandardServerCore<IUserFaceInfo>(options =>
44 {
45 // 使用XFE标准服务器核心
46 options.GetUserFunction = static () => UserProfile.UserTable; // 获取用户表的方法
47 options.AddUserFunction = user => UserProfile.UserTable.Add(user); // 添加用户的方法
48 options.GetEncryptedUserLoginModelFunction = static () => UserProfile.EncryptedUserLoginModelTable; // 获取用户加密模型的方法
49 options.AddEncryptedUserLoginModelFunction = UserProfile.EncryptedUserLoginModelTable.Add; // 添加用户加密模型的方法
50 options.RemoveEncryptedUserLoginModelFunction = static user => UserProfile.EncryptedUserLoginModelTable.Remove(user); // 移除用户加密模型的方法
51 options.GetLoginKeepDays = static () => 7; // 获取登录维持天数方法
52 options.LoginResultConvertFunction = static user => (IUserFaceInfo)user; // 登录结果转换方法
53 options.DataTableManagerBuilder = XFEDataTableManagerBuilder.CreateBuilder() // 创建DataTable管理器构建器
54 .AddTable<Person, DataProfile>("人物", (int)UserRole.业务员, (int)UserRole.经理, (int)UserRole.业务员, (int)UserRole.业务员) // 添加名为人物的格, Person 类 型, AutoConfig为 DataProfile。添加更改获取权限为业务员,移除权限为经理
55 .AddTable<Order, DataProfile>("订单", (int)UserRole.业务员, (int)UserRole.经理, (int)UserRole.业务员, (int)UserRole.业务员) // 添加名为订单的表格Order 类 型, AutoConfig 为 DataProfile。添加更改获取权限为业务员,移除权限为经理
56 .AddTable<User, UserProfile>("用户", (int)UserRole.经理, (int)UserRole.经理, (int)UserRole.经理, (int)UserRole.业务员); // 添加名为用户的表格Use类 型, AutoConfig为 UserProfile。获取权限为业务员,添加移除更改权限为经理
57 })
58 .Build(options =>
59 {
60 options.ServerCoreName = "BackendServer";
61 options.AcceptGet = true;
62 options.AcceptPost = true;
63 options.AcceptNonStandardJson = true;
64 options.MainEntryPoint = "backend";
65 options.BindIP("http://localhost:3302/")
66 .BindIP("https://localhost:3402/");
67 })
68 )
43 69 .Build(); // 构建服务器
44 70 await server.Start(); // 启动服务
Modified XFEExtension.NetCore.ServerInteractive.Test/Program.cs +3 -4
@@ -5,7 +5,6 @@ using XFEExtension.NetCore.ServerInteractive.Models.RequesterModels;
5 5 using XFEExtension.NetCore.ServerInteractive.TServer.Models;
6 6 using XFEExtension.NetCore.ServerInteractive.Utilities.Extensions;
7 7 using XFEExtension.NetCore.ServerInteractive.Utilities.Requester;
8 using XFEExtension.NetCore.XUnit.Attributes;
9 8
10 9 namespace XFEExtension.NetCore.ServerInteractive.Test;
11 10
@@ -49,7 +48,7 @@ internal class Program
49 48 }, response => response)
50 49 .Build(options =>
51 50 {
52 options.RequestAddress = "http://localhost:3305/api";
51 options.RequestAddress = "http://localhost:3302/backend";
53 52 });
54 53
55 54 private static readonly TableRequester TableRequester = new();
@@ -63,7 +62,7 @@ internal class Program
63 62
64 63 #region 基础测试
65 64
66 [SMTest]
65 // [SMTest]
67 66 public static async Task TestPOST()
68 67 {
69 68 using var client = new HttpClient
@@ -493,7 +492,7 @@ internal class Program
493 492 /// <summary>
494 493 /// 测试获取订单列表
495 494 /// </summary>
496 //[SMTest]
495 [SMTest]
497 496 public static async Task GetOrder()
498 497 {
499 498 var result = await TableRequester.Get<Order>();
Modified XFEExtension.NetCore.ServerInteractive/Utilities/Server/Services/CoreService/ServerCoreExceptionProcessService.cs +2 -2
@@ -46,9 +46,9 @@ public class ServerCoreExceptionProcessService : ServerCoreOriginalServiceBase
46 46 }
47 47 errorInfo = errorMessage.Contains("请求的路由未注册") ? "路由未找到" : "服务器内部异常";
48 48 Console.WriteLine();
49 Console.WriteLine($"[WARN]【{errorInfo}】{errorMessage}");
49 Console.WriteLine($"[WARN]({sender.ServerCoreName})【{errorInfo}】{errorMessage}");
50 50 if (e.ServerException?.InnerException?.StackTrace is not null)
51 Console.WriteLine($"[TRACE]{e.ServerException?.InnerException?.StackTrace}");
51 Console.WriteLine($"[TRACE]({sender.ServerCoreName}){e.ServerException?.InnerException?.StackTrace}");
52 52 }
53 53
54 54 try