diff --git a/Controllers/SimApiAuthController.cs b/Controllers/SimApiAuthController.cs
new file mode 100644
index 0000000..7bddf55
--- /dev/null
+++ b/Controllers/SimApiAuthController.cs
@@ -0,0 +1,49 @@
+using System.Collections.Generic;
+using Microsoft.AspNetCore.Mvc;
+using SimApi.Attributes;
+using SimApi.Communications;
+using SimApi.Helpers;
+
+namespace SimApi.Controllers;
+
+public class SimApiAuthController(SimApiAuth auth) : SimApiBaseController
+{
+ ///
+ /// 检测用户登陆的控制器
+ ///
+ ///
+ [HttpPost, SimApiDoc("认证", "检测登陆")]
+ public SimApiBaseResponse CheckLogin()
+ {
+ ErrorWhenNull(LoginInfo, 401, "未登录");
+ return new SimApiBaseResponse
+ {
+ Data = LoginInfo.Id
+ };
+ }
+
+ ///
+ /// 退出登陆
+ ///
+ ///
+ [HttpPost, SimApiDoc("认证", "退出登陆")]
+ public SimApiBaseResponse Logout()
+ {
+ string? token = null;
+
+ if (Request.Headers.TryGetValue("Token", out var value))
+ {
+ token = value;
+ }
+
+ auth.Logout(token!);
+ return new SimApiBaseResponse();
+ }
+
+
+ [HttpPost, SimApiAuth]
+ public SimApiBaseResponse UserInfo()
+ {
+ return new SimApiBaseResponse(LoginInfo);
+ }
+}
\ No newline at end of file
diff --git a/Controllers/SimApiCommonController.cs b/Controllers/SimApiCommonController.cs
index b74af01..f88c300 100644
--- a/Controllers/SimApiCommonController.cs
+++ b/Controllers/SimApiCommonController.cs
@@ -1,12 +1,11 @@
-using System.Collections.Generic;
+using System.Collections.Generic;
using Microsoft.AspNetCore.Mvc;
-using SimApi.Attributes;
using SimApi.Communications;
using SimApi.Helpers;
namespace SimApi.Controllers;
-public class SimApiCommonController(SimApiAuth auth) : SimApiBaseController
+public class SimApiCommonController : SimApiBaseController
{
///
/// 错误回馈页面
@@ -20,37 +19,6 @@ public class SimApiCommonController(SimApiAuth auth) : SimApiBaseController
return new SimApiBaseResponse(code);
}
- ///
- /// 检测用户登陆的控制器
- ///
- ///
- [HttpPost, SimApiDoc("认证", "检测登陆")]
- public SimApiBaseResponse CheckLogin()
- {
- ErrorWhenNull(LoginInfo, 401, "未登录");
- return new SimApiBaseResponse
- {
- Data = LoginInfo.Id
- };
- }
-
- ///
- /// 退出登陆
- ///
- ///
- [HttpPost, SimApiDoc("认证", "退出登陆")]
- public SimApiBaseResponse Logout()
- {
- string? token = null;
-
- if (Request.Headers.TryGetValue("Token", out var value))
- {
- token = value;
- }
-
- auth.Logout(token!);
- return new SimApiBaseResponse();
- }
[HttpPost, HttpGet]
public SimApiBaseResponse> Versions()
@@ -64,10 +32,4 @@ public class SimApiCommonController(SimApiAuth auth) : SimApiBaseController
}
};
}
-
- [HttpPost, SimApiAuth]
- public SimApiBaseResponse UserInfo()
- {
- return new SimApiBaseResponse(LoginInfo);
- }
}
\ No newline at end of file
diff --git a/SimApiExtensions.cs b/SimApiExtensions.cs
index b8e06bf..de85b44 100644
--- a/SimApiExtensions.cs
+++ b/SimApiExtensions.cs
@@ -141,6 +141,7 @@ public static class SimApiExtensions
{
return docName == "api"; // 未分组接口只属于默认分组v1
}
+
return docName == actionGroupName;
});
@@ -324,19 +325,19 @@ public static class SimApiExtensions
builder.MapControllerRoute(name: "GetUserInfo", pattern: "/user/info",
defaults: new
{
- controller = "SimApiCommon",
+ controller = "SimApiAuth",
action = "UserInfo"
});
builder.MapControllerRoute(name: "CheckLogin", pattern: "/auth/check",
defaults: new
{
- controller = "SimApiCommon",
+ controller = "SimApiAuth",
action = "CheckLogin"
});
builder.MapControllerRoute(name: "Logout", pattern: "/auth/logout",
defaults: new
{
- controller = "SimApiCommon",
+ controller = "SimApiAuth",
action = "Logout"
});
if (options.EnableCoceSdk)