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

增强数据表管理与服务方法错误处理

- 在服务器构建器中集成 DataTableManagerBuilder,新增人物、订单、用户三张数据表并配置权限 - 优化 GreetCoreService,精简引用并改进参数校验错误处理 - 调整测试方法注解,启用 AddOrder 和 GetOrder 测试,禁用 TimeTest 和 ConvertOrder

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

代码差异

3 个文件 +10 -11
Modified XFEExtension.NetCore.ServerInteractive.TServer/Program.cs +4 -0
@@ -21,6 +21,10 @@ var server = XFEServerBuilder.CreateBuilder() // 创建服务器构建器
21 21 options.RemoveEncryptedUserLoginModelFunction = static user => UserProfile.EncryptedUserLoginModelTable.Remove(user); // 移除用户加密模型的方法
22 22 options.GetLoginKeepDays = static () => 7; // 获取登录维持天数方法
23 23 options.LoginResultConvertFunction = static user => (IUserFaceInfo)user; // 登录结果转换方法
24 options.DataTableManagerBuilder = XFEDataTableManagerBuilder.CreateBuilder() // 创建DataTable管理器构建器
25 .AddTable<Person, DataProfile>("人物", (int)UserRole.业务员, (int)UserRole.经理, (int)UserRole.业务员, (int)UserRole.业务员) // 添加名为人物的格, Person 类 型, AutoConfig为 DataProfile。添加更改获取权限为业务员,移除权限为经理
26 .AddTable<Order, DataProfile>("订单", (int)UserRole.业务员, (int)UserRole.经理, (int)UserRole.业务员, (int)UserRole.业务员) // 添加名为订单的表格Order 类 型, AutoConfig 为 DataProfile。添加更改获取权限为业务员,移除权限为经理
27 .AddTable<User, UserProfile>("用户", (int)UserRole.经理, (int)UserRole.经理, (int)UserRole.经理, (int)UserRole.业务员); // 添加名为用户的表格User类 型, AutoConfig为 UserProfile。获取权限为业务员,添加移除更改权限为经理
24 28 })
25 29 .AddService<TestCoreService>()
26 30 .AddService<EchoCoreService>()
Modified XFEExtension.NetCore.ServerInteractive.TServer/Services/GreetCoreService.cs +2 -7
@@ -1,5 +1,4 @@
1 using System.Net;
2 using XFEExtension.NetCore.ServerInteractive.Attributes;
1 using XFEExtension.NetCore.ServerInteractive.Attributes;
3 2 using XFEExtension.NetCore.ServerInteractive.Implements.CoreService;
4 3
5 4 namespace XFEExtension.NetCore.ServerInteractive.TServer.Services;
@@ -13,11 +12,7 @@ public partial class GreetCoreService : ServerCoreStandardServiceBase
13 12 public async Task GreetEntryPoint()
14 13 {
15 14 var name = Json?["name"]?.GetValue<string>();
16 if (string.IsNullOrWhiteSpace(name))
17 {
18 await CloseWithError("名称不能为空", HttpStatusCode.BadRequest);
19 return;
20 }
15 if (string.IsNullOrWhiteSpace(name)) throw Error("名称不能为空");
21 16 await Close(new { greeting = $"你好, {name}!" });
22 17 }
23 18 }
Modified XFEExtension.NetCore.ServerInteractive.Test/Program.cs +4 -4
@@ -381,7 +381,7 @@ internal class Program
381 381 /// <summary>
382 382 /// 测试服务器时间端点
383 383 /// </summary>
384 [SMTest]
384 //[SMTest]
385 385 public static async Task TimeTest()
386 386 {
387 387 var result = await s_xFEClientRequester.Request<string>("time");
@@ -449,7 +449,7 @@ internal class Program
449 449 /// <summary>
450 450 /// 测试Order模型序列化
451 451 /// </summary>
452 [SMTest]
452 //[SMTest]
453 453 public static string ConvertOrder()
454 454 {
455 455 var order = new Order
@@ -463,7 +463,7 @@ internal class Program
463 463 /// <summary>
464 464 /// 测试添加订单
465 465 /// </summary>
466 //[SMTest]
466 [SMTest]
467 467 public static async Task<bool> AddOrder() => await TableRequester.Add<Order>(new()
468 468 {
469 469 Description = "测试订单的描述",
@@ -473,7 +473,7 @@ internal class Program
473 473 /// <summary>
474 474 /// 测试获取订单列表
475 475 /// </summary>
476 //[SMTest]
476 [SMTest]
477 477 public static async Task GetOrder()
478 478 {
479 479 var result = await TableRequester.Get<Order>();