diff --git a/APIJSON.NET/APIJSON.NET/APIJSON.NET.csproj b/APIJSON.NET/APIJSON.NET/APIJSON.NET.csproj index d4d0dd7..1a23f95 100644 --- a/APIJSON.NET/APIJSON.NET/APIJSON.NET.csproj +++ b/APIJSON.NET/APIJSON.NET/APIJSON.NET.csproj @@ -1,7 +1,7 @@  - netcoreapp2.2 + netcoreapp3.1 @@ -19,18 +19,13 @@ - - - - - - - - - - - - + + + + + + + diff --git a/APIJSON.NET/APIJSON.NET/Startup.cs b/APIJSON.NET/APIJSON.NET/Startup.cs index 15d9b6c..756a23c 100644 --- a/APIJSON.NET/APIJSON.NET/Startup.cs +++ b/APIJSON.NET/APIJSON.NET/Startup.cs @@ -12,6 +12,7 @@ using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.IdentityModel.Tokens; + using Microsoft.OpenApi.Models; using Swashbuckle.AspNetCore.Swagger; public class Startup @@ -40,16 +41,22 @@ public void ConfigureServices(IServiceCollection services) }); AuthConfigurer.Configure(services, Configuration); + var origins = Configuration.GetSection("CorsUrls").Value.Split(","); services.AddCors( options => options.AddPolicy( _defaultCorsPolicyName, builder => - builder.AllowAnyOrigin() + builder.WithOrigins(origins) .AllowAnyHeader() .AllowAnyMethod().AllowCredentials() )); - services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1); + services.AddControllers() + .AddNewtonsoftJson(options => + { + options.SerializerSettings.ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore; + options.SerializerSettings.DateFormatString = "yyyy-MM-dd HH:mm:ss"; + }); ; services.AddSwaggerGen(c => { - c.SwaggerDoc("v1", new Info { Title = "APIJSON.NET", Version = "v1" }); + c.SwaggerDoc("v1", new OpenApiInfo { Title = "APIJSON.NET", Version = "v1" }); }); services.AddSingleton(); services.AddSingleton(); @@ -61,17 +68,12 @@ public void ConfigureServices(IServiceCollection services) } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. - public void Configure(IApplicationBuilder app, IHostingEnvironment env) + public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { app.UseAuthentication(); - app.UseMvc(routes => - { - routes.MapRoute( - name: "default", - template: "{controller=Home}/{action=Index}/{id?}"); - }); + app.UseRouting(); app.UseStaticFiles(); app.UseCors(_defaultCorsPolicyName); app.UseSwagger(); @@ -80,7 +82,10 @@ public void Configure(IApplicationBuilder app, IHostingEnvironment env) c.SwaggerEndpoint("/swagger/v1/swagger.json", "My API V1"); }); - + app.UseEndpoints(endpoints => + { + endpoints.MapControllers(); + }); app.UseJwtTokenMiddleware(); DbInit.Initialize(app); } diff --git a/APIJSON.NET/APIJSON.NET/appsettings.json b/APIJSON.NET/APIJSON.NET/appsettings.json index da52e61..610c96b 100644 --- a/APIJSON.NET/APIJSON.NET/appsettings.json +++ b/APIJSON.NET/APIJSON.NET/appsettings.json @@ -4,6 +4,7 @@ "ConnectionString": "Server=192.168.2.25;Database=yunwei;Uid=root;Pwd=xmjk;Port=3306;Character Set=utf8;" //"ConnectionString": "Server=119.29.9.25;Port=3306;Database=test;Uid=root;Pwd=1q,2w.3e?;CharSet=UTF8;" }, + "CorsUrls": "http://localhost:5000,http://localhost5001", "Authentication": { "JwtBearer": { "IsEnabled": "true", diff --git a/APIJSON.NET/APIJSONCommon/ApiJson.Common.csproj b/APIJSON.NET/APIJSONCommon/ApiJson.Common.csproj index e89cd9f..cc2d355 100644 --- a/APIJSON.NET/APIJSONCommon/ApiJson.Common.csproj +++ b/APIJSON.NET/APIJSONCommon/ApiJson.Common.csproj @@ -12,9 +12,9 @@ - - - + + + diff --git a/APIJSON.NET/APIJSONCommon/SelectTable.cs b/APIJSON.NET/APIJSONCommon/SelectTable.cs index de56221..a2c402c 100644 --- a/APIJSON.NET/APIJSONCommon/SelectTable.cs +++ b/APIJSON.NET/APIJSONCommon/SelectTable.cs @@ -624,9 +624,8 @@ private void ProcessHaving(JObject values, ISugarQueryable tb) } hw.Add(model); } - - var d = db.Context.Utilities.ConditionalModelToSql(hw); - //tb.Having(d.Key, d.Value); + + tb.Having(string.Join(",", havingItems)); } }

AltStyle によって変換されたページ (->オリジナル) /