Skip to content

Sync #13

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Nov 10, 2020
Merged

Sync #13

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 8 additions & 13 deletions APIJSON.NET/APIJSON.NET/APIJSON.NET.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework>
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>

<ItemGroup>
Expand All @@ -19,18 +19,13 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="AspectCore.Extensions.Reflection" Version="1.2.0" />
<PackageReference Include="Microsoft.AspNetCore.App" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.Cors" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.Rewrite" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.Server.Kestrel.Https" Version="2.2.0" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.2.3" />
<PackageReference Include="MySql.Data" Version="8.0.15" />
<PackageReference Include="Oracle.ManagedDataAccess.Core" Version="2.18.6" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="4.0.1" />
<PackageReference Include="Swashbuckle.AspNetCore.Annotations" Version="4.0.1" />
<PackageReference Include="Swashbuckle.AspNetCore.Swagger" Version="4.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="3.1.9" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="3.1.9" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="3.1.4" />

<PackageReference Include="Swashbuckle.AspNetCore" Version="5.6.3" />
<PackageReference Include="Swashbuckle.AspNetCore.Annotations" Version="5.6.3" />
<PackageReference Include="Swashbuckle.AspNetCore.Swagger" Version="5.6.3" />
</ItemGroup>

<ItemGroup>
Expand Down
27 changes: 16 additions & 11 deletions APIJSON.NET/APIJSON.NET/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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<DbContext>();
services.AddSingleton<SelectTable>();
Expand All @@ -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();
Expand All @@ -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);
}
Expand Down
1 change: 1 addition & 0 deletions APIJSON.NET/APIJSON.NET/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
6 changes: 3 additions & 3 deletions APIJSON.NET/APIJSONCommon/ApiJson.Common.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="AspectCore.Extensions.Reflection" Version="1.1.0" />
<PackageReference Include="Microsoft.Extensions.Options" Version="2.1.1" />
<PackageReference Include="sqlSugarCore" Version="4.9.9.10" />
<PackageReference Include="AspectCore.Extensions.Reflection" Version="2.1.0" />
<PackageReference Include="Microsoft.Extensions.Options" Version="3.1.4" />
<PackageReference Include="sqlSugarCore" Version="5.0.0.15" />
</ItemGroup>

</Project>
5 changes: 2 additions & 3 deletions APIJSON.NET/APIJSONCommon/SelectTable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -624,9 +624,8 @@ private void ProcessHaving(JObject values, ISugarQueryable<ExpandoObject> tb)
}
hw.Add(model);
}

var d = db.Context.Utilities.ConditionalModelToSql(hw);
//tb.Having(d.Key, d.Value);


tb.Having(string.Join(",", havingItems));
}
}
Expand Down