Skip to content

Commit 87da3c8

Browse files
authored
Merge pull request #13 from liaozb/master
Sync
2 parents 56ef8e6 + 0525f90 commit 87da3c8

File tree

5 files changed

+30
-30
lines changed

5 files changed

+30
-30
lines changed

APIJSON.NET/APIJSON.NET/APIJSON.NET.csproj

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk.Web">
22

33
<PropertyGroup>
4-
<TargetFramework>netcoreapp2.2</TargetFramework>
4+
<TargetFramework>netcoreapp3.1</TargetFramework>
55
</PropertyGroup>
66

77
<ItemGroup>
@@ -19,18 +19,13 @@
1919
</ItemGroup>
2020

2121
<ItemGroup>
22-
<PackageReference Include="AspectCore.Extensions.Reflection" Version="1.2.0" />
23-
<PackageReference Include="Microsoft.AspNetCore.App" />
24-
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="2.2.0" />
25-
<PackageReference Include="Microsoft.AspNetCore.Cors" Version="2.2.0" />
26-
<PackageReference Include="Microsoft.AspNetCore.Rewrite" Version="2.2.0" />
27-
<PackageReference Include="Microsoft.AspNetCore.Server.Kestrel.Https" Version="2.2.0" />
28-
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.2.3" />
29-
<PackageReference Include="MySql.Data" Version="8.0.15" />
30-
<PackageReference Include="Oracle.ManagedDataAccess.Core" Version="2.18.6" />
31-
<PackageReference Include="Swashbuckle.AspNetCore" Version="4.0.1" />
32-
<PackageReference Include="Swashbuckle.AspNetCore.Annotations" Version="4.0.1" />
33-
<PackageReference Include="Swashbuckle.AspNetCore.Swagger" Version="4.0.1" />
22+
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="3.1.9" />
23+
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="3.1.9" />
24+
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="3.1.4" />
25+
26+
<PackageReference Include="Swashbuckle.AspNetCore" Version="5.6.3" />
27+
<PackageReference Include="Swashbuckle.AspNetCore.Annotations" Version="5.6.3" />
28+
<PackageReference Include="Swashbuckle.AspNetCore.Swagger" Version="5.6.3" />
3429
</ItemGroup>
3530

3631
<ItemGroup>

APIJSON.NET/APIJSON.NET/Startup.cs

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
using Microsoft.Extensions.Configuration;
1313
using Microsoft.Extensions.DependencyInjection;
1414
using Microsoft.IdentityModel.Tokens;
15+
using Microsoft.OpenApi.Models;
1516
using Swashbuckle.AspNetCore.Swagger;
1617

1718
public class Startup
@@ -40,16 +41,22 @@ public void ConfigureServices(IServiceCollection services)
4041
});
4142
AuthConfigurer.Configure(services, Configuration);
4243

44+
var origins = Configuration.GetSection("CorsUrls").Value.Split(",");
4345
services.AddCors( options => options.AddPolicy( _defaultCorsPolicyName,
4446
builder =>
45-
builder.AllowAnyOrigin()
47+
builder.WithOrigins(origins)
4648
.AllowAnyHeader()
4749
.AllowAnyMethod().AllowCredentials()
4850
));
49-
services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);
51+
services.AddControllers()
52+
.AddNewtonsoftJson(options =>
53+
{
54+
options.SerializerSettings.ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore;
55+
options.SerializerSettings.DateFormatString = "yyyy-MM-dd HH:mm:ss";
56+
}); ;
5057
services.AddSwaggerGen(c =>
5158
{
52-
c.SwaggerDoc("v1", new Info { Title = "APIJSON.NET", Version = "v1" });
59+
c.SwaggerDoc("v1", new OpenApiInfo { Title = "APIJSON.NET", Version = "v1" });
5360
});
5461
services.AddSingleton<DbContext>();
5562
services.AddSingleton<SelectTable>();
@@ -61,17 +68,12 @@ public void ConfigureServices(IServiceCollection services)
6168
}
6269

6370
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
64-
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
71+
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
6572
{
6673

6774
app.UseAuthentication();
6875

69-
app.UseMvc(routes =>
70-
{
71-
routes.MapRoute(
72-
name: "default",
73-
template: "{controller=Home}/{action=Index}/{id?}");
74-
});
76+
app.UseRouting();
7577
app.UseStaticFiles();
7678
app.UseCors(_defaultCorsPolicyName);
7779
app.UseSwagger();
@@ -80,7 +82,10 @@ public void Configure(IApplicationBuilder app, IHostingEnvironment env)
8082
c.SwaggerEndpoint("/swagger/v1/swagger.json", "My API V1");
8183

8284
});
83-
85+
app.UseEndpoints(endpoints =>
86+
{
87+
endpoints.MapControllers();
88+
});
8489
app.UseJwtTokenMiddleware();
8590
DbInit.Initialize(app);
8691
}

APIJSON.NET/APIJSON.NET/appsettings.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"ConnectionString": "Server=192.168.2.25;Database=yunwei;Uid=root;Pwd=xmjk;Port=3306;Character Set=utf8;"
55
//"ConnectionString": "Server=119.29.9.25;Port=3306;Database=test;Uid=root;Pwd=1q,2w.3e?;CharSet=UTF8;"
66
},
7+
"CorsUrls": "http://localhost:5000,http://localhost5001",
78
"Authentication": {
89
"JwtBearer": {
910
"IsEnabled": "true",

APIJSON.NET/APIJSONCommon/ApiJson.Common.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@
1212
</ItemGroup>
1313

1414
<ItemGroup>
15-
<PackageReference Include="AspectCore.Extensions.Reflection" Version="1.1.0" />
16-
<PackageReference Include="Microsoft.Extensions.Options" Version="2.1.1" />
17-
<PackageReference Include="sqlSugarCore" Version="4.9.9.10" />
15+
<PackageReference Include="AspectCore.Extensions.Reflection" Version="2.1.0" />
16+
<PackageReference Include="Microsoft.Extensions.Options" Version="3.1.4" />
17+
<PackageReference Include="sqlSugarCore" Version="5.0.0.15" />
1818
</ItemGroup>
1919

2020
</Project>

APIJSON.NET/APIJSONCommon/SelectTable.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -624,9 +624,8 @@ private void ProcessHaving(JObject values, ISugarQueryable<ExpandoObject> tb)
624624
}
625625
hw.Add(model);
626626
}
627-
628-
var d = db.Context.Utilities.ConditionalModelToSql(hw);
629-
//tb.Having(d.Key, d.Value);
627+
628+
630629
tb.Having(string.Join(",", havingItems));
631630
}
632631
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy