|
|
|
@ -2,10 +2,8 @@
|
|
|
|
|
using Autofac;
|
|
|
|
|
using Autofac.Extensions.DependencyInjection;
|
|
|
|
|
using ce.autofac.extension;
|
|
|
|
|
using DocumentFormat.OpenXml.Validation;
|
|
|
|
|
using IdentityServer4.AccessTokenValidation;
|
|
|
|
|
using Infrastructure;
|
|
|
|
|
using Infrastructure.Cache;
|
|
|
|
|
using Infrastructure.CloudSdk.minio;
|
|
|
|
|
using Infrastructure.CloudSdk.mqttmessagecenter;
|
|
|
|
|
using Infrastructure.Extensions.AutofacManager;
|
|
|
|
@ -13,13 +11,11 @@ using Infrastructure.Middleware;
|
|
|
|
|
using Microsoft.AspNetCore.DataProtection;
|
|
|
|
|
using Microsoft.AspNetCore.Http.Features;
|
|
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
|
using Microsoft.AspNetCore.Mvc.Controllers;
|
|
|
|
|
using Microsoft.AspNetCore.Server.Kestrel.Core;
|
|
|
|
|
using Microsoft.AspNetCore.StaticFiles;
|
|
|
|
|
using Microsoft.Extensions.FileProviders;
|
|
|
|
|
using Microsoft.IdentityModel.Logging;
|
|
|
|
|
using Microsoft.OpenApi.Models;
|
|
|
|
|
using Newtonsoft.Json;
|
|
|
|
|
using Newtonsoft.Json.Serialization;
|
|
|
|
|
using Npgsql;
|
|
|
|
|
using OpenAuth.App;
|
|
|
|
|
using OpenAuth.App.BaseApp.ImMsgManager;
|
|
|
|
@ -27,11 +23,9 @@ using OpenAuth.App.HostedService;
|
|
|
|
|
using OpenAuth.Repository;
|
|
|
|
|
using OpenAuth.WebApi.Model;
|
|
|
|
|
using OpenAuth.WebApi.Model.mqtt;
|
|
|
|
|
using Quartz;
|
|
|
|
|
using Quartz.Impl;
|
|
|
|
|
using SqlSugar;
|
|
|
|
|
using Swashbuckle.AspNetCore.SwaggerUI;
|
|
|
|
|
|
|
|
|
|
using Yitter.IdGenerator;
|
|
|
|
|
|
|
|
|
|
namespace OpenAuth.WebApi
|
|
|
|
|
{
|
|
|
|
@ -257,14 +251,14 @@ namespace OpenAuth.WebApi
|
|
|
|
|
////没有直接 using SqlSugar,因为如果引用命名空间的话,会和Microsoft的一个GetTypeInfo存在二义性,所以就直接这么使用了
|
|
|
|
|
services.AddScoped<ISqlSugarClient>(s =>
|
|
|
|
|
{
|
|
|
|
|
StaticConfig.CustomSnowFlakeFunc = () => { return Yitter.IdGenerator.YitIdHelper.NextId(); };
|
|
|
|
|
StaticConfig.CustomSnowFlakeFunc = () => { return YitIdHelper.NextId(); };
|
|
|
|
|
|
|
|
|
|
var sqlSugar = new SqlSugarClient(new ConnectionConfig()
|
|
|
|
|
{
|
|
|
|
|
DbType = SqlSugar.DbType.PostgreSQL,
|
|
|
|
|
DbType = DbType.PostgreSQL,
|
|
|
|
|
ConnectionString = Configuration.GetConnectionString("OpenAuthDBContext"),
|
|
|
|
|
IsAutoCloseConnection = true,
|
|
|
|
|
MoreSettings = new SqlSugar.ConnMoreSettings()
|
|
|
|
|
MoreSettings = new ConnMoreSettings()
|
|
|
|
|
{
|
|
|
|
|
PgSqlIsAutoToLower = false,
|
|
|
|
|
PgSqlIsAutoToLowerCodeFirst = false
|
|
|
|
@ -303,8 +297,8 @@ namespace OpenAuth.WebApi
|
|
|
|
|
});
|
|
|
|
|
return sqlSugar;
|
|
|
|
|
});
|
|
|
|
|
services.AddScoped<SqlSugar.ISugarUnitOfWork<SugarDbContext>>(s =>
|
|
|
|
|
new SqlSugar.SugarUnitOfWork<SugarDbContext>(s.GetService<ISqlSugarClient>()));
|
|
|
|
|
services.AddScoped<ISugarUnitOfWork<SugarDbContext>>(s =>
|
|
|
|
|
new SugarUnitOfWork<SugarDbContext>(s.GetService<ISqlSugarClient>()));
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
@ -373,7 +367,7 @@ namespace OpenAuth.WebApi
|
|
|
|
|
//可以在这里为静态文件添加其他http头信息,默认添加跨域信息
|
|
|
|
|
ctx.Context.Response.Headers["Access-Control-Allow-Origin"] = "*";
|
|
|
|
|
},
|
|
|
|
|
ContentTypeProvider = new Microsoft.AspNetCore.StaticFiles.FileExtensionContentTypeProvider(
|
|
|
|
|
ContentTypeProvider = new FileExtensionContentTypeProvider(
|
|
|
|
|
new Dictionary<string, string>
|
|
|
|
|
{
|
|
|
|
|
{ ".amr", "audio/AMR" },
|
|
|
|
@ -445,7 +439,7 @@ namespace OpenAuth.WebApi
|
|
|
|
|
app.UseSwaggerUI(c =>
|
|
|
|
|
{
|
|
|
|
|
c.SwaggerEndpoint("v1/swagger.json", "V1 Docs");
|
|
|
|
|
c.DocExpansion(Swashbuckle.AspNetCore.SwaggerUI.DocExpansion.None);
|
|
|
|
|
c.DocExpansion(DocExpansion.None);
|
|
|
|
|
c.OAuthClientId("OpenAuth.WebApi"); //oauth客户端名称
|
|
|
|
|
c.OAuthAppName("开源版webapi认证"); // 描述
|
|
|
|
|
});
|
|
|
|
|