|
|
|
|
using Microsoft.AspNetCore.Authentication;
|
|
|
|
|
using Microsoft.AspNetCore.Authentication.JwtBearer;
|
|
|
|
|
using Microsoft.AspNetCore.Components.Forms;
|
|
|
|
|
using Microsoft.IdentityModel.Tokens;
|
|
|
|
|
using ReZero;
|
|
|
|
|
using ReZero.Configuration;
|
|
|
|
|
using ReZero.SuperAPI;
|
|
|
|
|
using SqlSugar;
|
|
|
|
|
using SuperAPITest;
|
|
|
|
|
using System.Reflection;
|
|
|
|
|
using System.Runtime.CompilerServices;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using Microsoft.AspNetCore.Cors;
|
|
|
|
|
using Newtonsoft.Json;
|
|
|
|
|
using Newtonsoft.Json.Serialization;
|
|
|
|
|
|
|
|
|
|
var builder = WebApplication.CreateBuilder(args);
|
|
|
|
|
builder.Services.AddControllers();
|
|
|
|
|
builder.Services.AddEndpointsApiExplorer();
|
|
|
|
|
builder.Services.AddSwaggerGen();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//ע<EFBFBD><EFBFBD>db: <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>д<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Բ<EFBFBD>ע<EFBFBD><EFBFBD>
|
|
|
|
|
builder.Services.AddScoped<ISqlSugarClient>(it =>
|
|
|
|
|
{
|
|
|
|
|
var config = ApiConfiguration.GetJsonValue<ReZeroJson>("ReZero");
|
|
|
|
|
return new SqlSugarClient(new ConnectionConfig()
|
|
|
|
|
{
|
|
|
|
|
DbType = config!.BasicDatabase!.DbType,
|
|
|
|
|
ConnectionString = config!.BasicDatabase!.ConnectionString,
|
|
|
|
|
IsAutoCloseConnection = true
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
//builder.Services.AddCors();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//ע<EFBFBD><EFBFBD>ReZero.Api
|
|
|
|
|
builder.Services.AddReZeroServices(api =>
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
//<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ؿɻ<EFBFBD>json<EFBFBD>ļ<EFBFBD>
|
|
|
|
|
var apiObj = SuperAPIOptions.GetOptions();
|
|
|
|
|
|
|
|
|
|
//IOCҵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>м<EFBFBD><EFBFBD>̼<EFBFBD>
|
|
|
|
|
var assemblyList = Assembly.GetExecutingAssembly()
|
|
|
|
|
.GetAllDependentAssemblies(it => it.Contains("SuperAPITest"))
|
|
|
|
|
.ToArray();
|
|
|
|
|
|
|
|
|
|
apiObj!.DependencyInjectionOptions = new DependencyInjectionOptions(assemblyList);
|
|
|
|
|
|
|
|
|
|
//<EFBFBD><EFBFBD><EFBFBD>ó<EFBFBD><EFBFBD><EFBFBD>API
|
|
|
|
|
api.EnableSuperApi(apiObj);
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var app = builder.Build();
|
|
|
|
|
if (app.Environment.IsDevelopment())
|
|
|
|
|
{
|
|
|
|
|
app.UseSwagger();
|
|
|
|
|
app.UseSwaggerUI();
|
|
|
|
|
}
|
|
|
|
|
app.UseHttpsRedirection();
|
|
|
|
|
app.UseAuthorization();
|
|
|
|
|
app.MapControllers();
|
|
|
|
|
app.Run();
|