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

docs: fix route names, wildcard example, and TableRequester description per review

Agent-Logs-Url: https://github.com/XFEstudio/XFEExtension.NetCore.ServerInteractive/sessions/045f8b2e-9425-4c03-8989-c21b0a0727d0 Co-authored-by: XFEstudio <132526994+XFEstudio@users.noreply.github.com>

9117064
copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
提交于

代码差异

1 个文件 +17 -11
Modified README.md +17 -11
@@ -182,7 +182,7 @@ public partial class DynamicService : ServerCoreStandardServiceBase
182 182 await Close($"您请求的路由是:{Route},您的IP是:{ClientIP}");
183 183 }
184 184
185 // 匹配 v1/test/* 下的所有路径,例如 v1/test/a, v1/test/b/c(仅一段)
185 // 匹配 v1/test/* 下的路径(* 仅匹配单个路径段),例如 v1/test/a, v1/test/hello
186 186 [EntryPoint("v1/test/*")]
187 187 public async Task TestAny()
188 188 {
@@ -198,9 +198,10 @@ public partial class DynamicService : ServerCoreStandardServiceBase
198 198 ### 使用XFE标准服务器核心
199 199
200 200 `UseXFEStandardServerCore<T>()` 扩展方法提供了一套完整的标准化服务器核心,内置:
201 - 用户登录(`login`)、自动重登(`relogin`)服务
202 - 数据表 CRUD 管理(`table/get/*`、`table/add/*`、`table/change/*`、`table/remove/*`)
203 - IP 封禁、每日计数、连接检查、服务器日志等
201 - 用户登录(服务端路由 `user/login`,客户端可通过别名 `login` 调用)、自动重登(路由 `user/relogin`,别名 `relogin`)
202 - 数据表 CRUD 管理(`table/get/{表名}`、`table/add/{表名}`、`table/change/{表名}`、`table/remove/{表名}`)
203 - IP 封禁(`ip/banned/get`、`ip/banned/add`、`ip/banned/remove`)、每日计数
204 - 连接检查(`check_connect`)、服务器日志(路由 `log/get`,别名 `get_log`;路由 `log/clear`,别名 `clear_log`)
204 205
205 206 ```csharp
206 207 var serverCore = XFEServerCoreBuilder.CreateBuilder()
@@ -226,7 +227,7 @@ var serverCore = XFEServerCoreBuilder.CreateBuilder()
226 227 .AddService<MyCustomService>() // 追加自定义业务服务
227 228 .Build(options =>
228 229 {
229 options.MainEntryPoint = "api"; // 所有路由前缀,例如请求路径为 /api/login
230 options.MainEntryPoint = "api"; // 所有路由前缀,例如登录请求的完整路径为 /api/user/login
230 231 options.AcceptPost = true;
231 232 options.AcceptGet = true;
232 233 options.BindIP("http://localhost:3300/")
@@ -580,6 +581,8 @@ var checkResult = await requester.Request<DateTime>("check_connect");
580 581 var logResult = await requester.Request<string>("get_log", DateTime.MinValue, DateTime.MaxValue);
581 582
582 583 // IP 封禁管理
584 // 说明:AddBannedIPRequest() 注册的调用名称为 get_bannedIPList / add_bannedIP / remove_bannedIP
585 // 对应服务端实际路由为 ip/banned/get / ip/banned/add / ip/banned/remove
583 586 var bannedIPs = await requester.Request<List<IPAddressInfo>>("get_bannedIPList");
584 587 await requester.Request<string>("add_bannedIP", "192.168.1.100", "恶意请求");
585 588 await requester.Request<bool>("remove_bannedIP", "192.168.1.100");
@@ -588,9 +591,10 @@ await requester.Request<bool>("remove_bannedIP", "192.168.1.100");
588 591 `UseXFEStandardRequest<T>()` 等价于:
589 592
590 593 ```csharp
591 .AddLoginRequest<T>() // 注册 login、relogin 请求
594 .AddLoginRequest<T>() // 注册 login(→ user/login)、relogin(→ user/relogin)请求
592 595 .AddBannedIPRequest() // 注册 get_bannedIPList、add_bannedIP、remove_bannedIP 请求
593 .AddLogRequest() // 注册 get_log 请求
596 // 对应服务端路由:ip/banned/get、ip/banned/add、ip/banned/remove
597 .AddLogRequest() // 注册 get_log(→ log/get)、clear_log(→ log/clear)请求
594 598 .AddCheckConnectRequest() // 注册 check_connect 请求
595 599 ```
596 600
@@ -628,14 +632,16 @@ await tableRequester.Change(order);
628 632 await tableRequester.Remove<Order>(order.Id);
629 633 ```
630 634
631 表名默认从类型名自动推断(首字母小写),也可手动指定:
635 表名默认从类型名自动推断:类型名首字母小写即为请求表名(`TableNameInRequest`),例如 `Order` → `order`。
636 这是 `TableRequester` 与服务端通信时实际使用的名称,与 `AddTable` 时指定的 `tableShowName`(显示名称,如 `"订单"`)不同。
632 637
633 638 ```csharp
634 // 默认:Order → 表名 order
639 // 默认:Order 类型 → 请求表名自动推断为 "order"(类型名首字母小写)
635 640 await tableRequester.Get<Order>();
636 641
637 // 手动指定表名
638 await tableRequester.Get<Order>("订单"); // 使用服务端注册时指定的 tableShowName
642 // 手动指定请求表名(需与服务端 TableNameInRequest 一致,即类型名首字母小写)
643 // 注意:这里填写的是请求路径中使用的表名,不是 AddTable 时的 tableShowName
644 await tableRequester.Get<Order>("order", pageCount: 10, page: 1);
639 645 ```
640 646
641 647 数据模型需实现 `IIdModel` 接口(包含 `string Id` 属性):