From 86ec43f676bee38d73c9a65362e0cac15312d294 Mon Sep 17 00:00:00 2001 From: xRain Date: Mon, 3 Feb 2020 02:54:02 +0800 Subject: [PATCH] add idonly request --- Communications/Base.cs | 20 ++++++++++++++++++++ Extensions.cs | 9 +++++++-- YYApi.csproj | 2 +- 3 files changed, 28 insertions(+), 3 deletions(-) diff --git a/Communications/Base.cs b/Communications/Base.cs index c1d7f6d..64d5726 100644 --- a/Communications/Base.cs +++ b/Communications/Base.cs @@ -129,4 +129,24 @@ namespace YYApi.Communications /// public T Data { get; set; } } + + + //===========》请求《=============== + + /// + /// 只有ID的请求 + /// + public class IdOnlyRequest + { + public int Id { get; set; } + } + + /// + /// 基础分页请求 + /// + public class BasePageRequest + { + public int Page { get; set; } + public int Count { get; set; } + } } \ No newline at end of file diff --git a/Extensions.cs b/Extensions.cs index ebaf2f2..7c05a23 100644 --- a/Extensions.cs +++ b/Extensions.cs @@ -32,7 +32,7 @@ namespace YYApi public static IServiceCollection AddYYApi(this IServiceCollection builder, string title, string description = null) { - return builder.AddAuth().AddApiDoc(title, description); + return builder.AddAuth().AddApiDoc(title, description).AddCors(); } /// @@ -138,7 +138,12 @@ namespace YYApi public static IApplicationBuilder UseYYApiMiddleware(this IApplicationBuilder builder, string title = "API文档", params SubmitMethod[] submitMethods) { - return builder.UseExceptionMiddleware().UseApiDoc(title, submitMethods).UseMiddleware(); + return builder.UseExceptionMiddleware().UseApiDoc(title, submitMethods).UseMiddleware().UseCors(x => + { + x.AllowAnyHeader(); + x.AllowAnyMethod(); + x.AllowAnyOrigin(); + }); ; } } } \ No newline at end of file diff --git a/YYApi.csproj b/YYApi.csproj index a8421ea..c52780e 100644 --- a/YYApi.csproj +++ b/YYApi.csproj @@ -4,7 +4,7 @@ netcoreapp3.1 Library true - 0.2.1 + 0.2.3 xRain@YYTech AspNetCore一个方便的API文档,捕获异常,统一输入输出的API类库 YY-Tech.YYApi