92 lines
3.0 KiB
C#
92 lines
3.0 KiB
C#
|
||
using Learn.VideoAnalysis.API.Expand;
|
||
using Mapster;
|
||
using Microsoft.AspNetCore.Hosting.Server.Features;
|
||
using Microsoft.AspNetCore.Hosting.Server;
|
||
using Microsoft.OpenApi.Models;
|
||
using System.Text.Encodings.Web;
|
||
using System.Text.Json;
|
||
using System.Text.Unicode;
|
||
using VideoAnalysisCore.AICore.FFMPGE;
|
||
using VideoAnalysisCore.AICore.GPT.DeepSeek;
|
||
using VideoAnalysisCore.AICore.SherpaOnnx;
|
||
using VideoAnalysisCore.Common;
|
||
using VideoAnalysisCore.Common.Expand;
|
||
|
||
namespace Learn.VideoAnalysis.API
|
||
{
|
||
public class Program
|
||
{
|
||
public static void Main(string[] args)
|
||
{
|
||
var builder = WebApplication.CreateBuilder(args);
|
||
|
||
// Add services to the container.
|
||
|
||
builder.Services.AddControllers(options =>
|
||
{
|
||
// 全局模型赋值默认值 和 统一返回格式处理
|
||
options.Filters.Add<HttpLogAttribute>();
|
||
}).AddJsonOptions(options =>
|
||
{
|
||
options.JsonSerializerOptions.Encoder = JavaScriptEncoder.Create(UnicodeRanges.All);//中文转换时不使用Unicode
|
||
//options.JsonSerializerOptions.PropertyNamingPolicy = JsonNamingPolicy.CamelCase;// 默认小驼峰 null 大驼峰
|
||
});
|
||
|
||
builder.Services.AddEndpointsApiExplorer();
|
||
builder.Services.AddSwaggerGen(c =>
|
||
{
|
||
var file = Path.Combine(AppContext.BaseDirectory, "Learn.VideoAnalysis.API.xml"); // xml文档绝对路径
|
||
var file1 = Path.Combine(AppContext.BaseDirectory, "VideoAnalysisCore.xml"); // xml文档绝对路径
|
||
c.IncludeXmlComments(file, true); // true : 显示控制器层注释
|
||
c.IncludeXmlComments(file1, true); // true : 显示控制器层注释
|
||
c.OrderActionsBy(o => o.RelativePath); // 对action的名称进行排序,如果有多个,就可以看见效果了。
|
||
});
|
||
|
||
|
||
builder.Services.AddMapster();
|
||
|
||
//初始化 插件
|
||
builder.AddAppConfig(args);
|
||
|
||
builder.Services.AddHttpClient();
|
||
builder.Services.AddSqlSugarExpand();
|
||
builder.Services.AddRedisExpand();
|
||
|
||
builder.Services.AddCoravel();
|
||
builder.Services.AddCorsExpand();
|
||
|
||
|
||
builder.Services.AddControllersWithViews(options =>
|
||
{
|
||
options.Filters.Add(typeof(ExceptionFilter));
|
||
});
|
||
|
||
|
||
var app = builder.Build();
|
||
AppCommon.Services = app.Services;
|
||
app.UseMiddleware<BasicAuthMiddleware>("Swagger");
|
||
// Configure the HTTP request pipeline.
|
||
|
||
app.UseSwagger();
|
||
app.UseSwaggerUI();
|
||
|
||
app.UseHttpsRedirection();
|
||
|
||
|
||
|
||
app.MapControllers();
|
||
|
||
//自定义 应用
|
||
app.UseCorsExpand();
|
||
app.UseSqlSugarExpand();
|
||
app.UseCoravelExpand();
|
||
// 注册启动后的回调
|
||
app.UseServiceSystem();
|
||
|
||
|
||
app.Run();
|
||
}
|
||
}
|
||
}
|