diff --git a/Communications/SimApiLoginItem.cs b/Communications/SimApiLoginItem.cs
index 68d978a..17bdda2 100644
--- a/Communications/SimApiLoginItem.cs
+++ b/Communications/SimApiLoginItem.cs
@@ -1,4 +1,5 @@
using System;
+
namespace SimApi.Communications
{
///
@@ -7,8 +8,9 @@ namespace SimApi.Communications
public class SimApiLoginItem
{
//登录用户的ID
- public int Id { get; set; }
+ public string Id { get; set; }
+
//登录用户来源
public string[] Type { get; set; }
}
-}
+}
\ No newline at end of file
diff --git a/Controllers/SimApiBaseController.cs b/Controllers/SimApiBaseController.cs
index 046aae4..e0d7e96 100644
--- a/Controllers/SimApiBaseController.cs
+++ b/Controllers/SimApiBaseController.cs
@@ -85,7 +85,5 @@ namespace SimApi.Controllers
{
return new SimApiBaseResponse();
}
-
-
}
}
\ No newline at end of file
diff --git a/Controllers/SimApiCommonController.cs b/Controllers/SimApiCommonController.cs
index a716819..48a90d5 100644
--- a/Controllers/SimApiCommonController.cs
+++ b/Controllers/SimApiCommonController.cs
@@ -35,10 +35,13 @@ namespace SimApi.Controllers
///
///
[HttpPost("/auth/check"), SimApiDoc("认证", "检测登陆")]
- public SimApiBaseResponse CheckLogin()
+ public SimApiBaseResponse CheckLogin()
{
ErrorWhenNull(LoginInfo, 401);
- return new SimApiBaseResponse {Data = LoginInfo.Id};
+ return new SimApiBaseResponse
+ {
+ Data = LoginInfo.Id
+ };
}
///
diff --git a/Helpers/SimApiAuth.cs b/Helpers/SimApiAuth.cs
index fd5ed55..6a8762c 100644
--- a/Helpers/SimApiAuth.cs
+++ b/Helpers/SimApiAuth.cs
@@ -23,7 +23,7 @@ namespace SimApi.Helpers
///
///
///
- public string Login(int id, string type = "user", string token = null)
+ public string Login(string id, string type = "user", string token = null)
{
return Login(id, new[] { type }, token);
}
@@ -34,7 +34,7 @@ namespace SimApi.Helpers
///
///
///
- public string Login(int id, string[] type, string uuid = null)
+ public string Login(string id, string[] type, string uuid = null)
{
if (uuid == null)
{
diff --git a/Logger/SimApiLogger.cs b/Logger/SimApiLogger.cs
index 0dc2772..ba4f6b3 100644
--- a/Logger/SimApiLogger.cs
+++ b/Logger/SimApiLogger.cs
@@ -12,15 +12,9 @@ namespace SimApi.Logger
Name = name;
}
- public IDisposable BeginScope(TState state)
- {
- return null;
- }
+ public IDisposable BeginScope(TState state) => default!;
- public bool IsEnabled(LogLevel logLevel)
- {
- return true;
- }
+ public bool IsEnabled(LogLevel logLevel) => true;
public void Log(LogLevel logLevel, EventId eventId, TState state, Exception exception,
Func formatter)
diff --git a/SimApiExtensions.cs b/SimApiExtensions.cs
index 4a742cb..24023d2 100644
--- a/SimApiExtensions.cs
+++ b/SimApiExtensions.cs
@@ -23,7 +23,7 @@ namespace SimApi
var simApiOptions = new SimApiOptions();
options?.Invoke(simApiOptions);
- // 是否使用SIMAUTH
+ // 是否使用 AUTH
if (simApiOptions.EnableSimApiAuth)
{
builder.AddScoped();
@@ -43,7 +43,11 @@ namespace SimApi
{
foreach (var group in docOptions.ApiGroups)
{
- x.SwaggerDoc(group.Id, new OpenApiInfo {Title = group.Name, Description = group.Description});
+ x.SwaggerDoc(group.Id, new OpenApiInfo
+ {
+ Title = group.Name,
+ Description = group.Description
+ });
}
x.EnableAnnotations();
@@ -61,9 +65,15 @@ namespace SimApi
new OpenApiSecurityScheme
{
Reference = new OpenApiReference
- {Type = ReferenceType.SecurityScheme, Id = "HeaderToken"}
+ {
+ Type = ReferenceType.SecurityScheme,
+ Id = "HeaderToken"
+ }
},
- new[] {"readAccess", "writeAccess"}
+ new[]
+ {
+ "readAccess", "writeAccess"
+ }
}
});
haveSimApiAuth = true;
@@ -121,9 +131,15 @@ namespace SimApi
new OpenApiSecurityScheme
{
Reference = new OpenApiReference
- {Type = ReferenceType.SecurityScheme, Id = "oauth2"}
+ {
+ Type = ReferenceType.SecurityScheme,
+ Id = "oauth2"
+ }
},
- new[] {"SimApiAuth"}
+ new[]
+ {
+ "SimApiAuth"
+ }
}
});
}
@@ -131,7 +147,11 @@ namespace SimApi
if (haveSimApiAuth)
{
x.AddSecurityDefinition("HeaderToken",
- new OpenApiSecurityScheme {Name = "Token", In = ParameterLocation.Header});
+ new OpenApiSecurityScheme
+ {
+ Name = "Token",
+ In = ParameterLocation.Header
+ });
}
});
}
@@ -139,17 +159,17 @@ namespace SimApi
// 使用Header转发,应对代理后获取真实ip
if (simApiOptions.EnableForwardHeaders)
{
- builder.Configure(options =>
+ builder.Configure(fwOptions =>
{
- options.ForwardedHeaders = ForwardedHeaders.All;
- options.KnownNetworks.Clear();
- options.KnownProxies.Clear();
+ fwOptions.ForwardedHeaders = ForwardedHeaders.All;
+ fwOptions.KnownNetworks.Clear();
+ fwOptions.KnownProxies.Clear();
});
}
if (simApiOptions.EnableLowerUrl)
{
- builder.AddRouting(options => options.LowercaseUrls = true);
+ builder.AddRouting(rOptions => rOptions.LowercaseUrls = true);
}
if (simApiOptions.EnableSimApiStorage)
@@ -169,13 +189,14 @@ namespace SimApi
///
public static IApplicationBuilder UseSimApi(this IApplicationBuilder builder)
{
- var options = builder.ApplicationServices.GetService();
+ var options = builder.ApplicationServices.GetRequiredService();
if (options.EnableLogger)
{
- builder.ApplicationServices.GetService().AddProvider(new SimApiLoggerProvider());
+ builder.ApplicationServices.GetRequiredService()
+ .AddProvider(new SimApiLoggerProvider());
}
- var logger = builder.ApplicationServices.GetService>();
+ var logger = builder.ApplicationServices.GetRequiredService>();
if (options.EnableForwardHeaders)
{