You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

66 lines
1.8 KiB

3 weeks ago
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 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();
//注册db: 这个不写代码可以不注册
3 weeks ago
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();
//注册ReZero.Api
3 weeks ago
builder.Services.AddReZeroServices(api =>
{
//有重载可换json文件
3 weeks ago
var apiObj = SuperAPIOptions.GetOptions();
//IOC业务等所有需要的所有集程集
3 weeks ago
var assemblyList = Assembly.GetExecutingAssembly()
.GetAllDependentAssemblies(it => it.Contains("medical.insu.transfomer") || it.Contains("medical.transfomer"))
3 weeks ago
.ToArray();
apiObj!.DependencyInjectionOptions = new DependencyInjectionOptions(assemblyList);
//启用超级API
3 weeks ago
api.EnableSuperApi(apiObj);
});
var app = builder.Build();
if (app.Environment.IsDevelopment())
{
app.UseSwagger();
app.UseSwaggerUI();
}
app.UseHttpsRedirection();
app.UseAuthorization();
app.MapControllers();
app.Run();