mirror of
https://gitee.com/ccnetcore/Yi
synced 2026-03-20 00:16:37 +08:00
添加模块化功能+动态api
This commit is contained in:
@@ -1,28 +1,45 @@
|
||||
|
||||
using AspNetCore.Microsoft.AspNetCore.Builder;
|
||||
using Panda.DynamicWebApi;
|
||||
using Yi.Framework.Application;
|
||||
using Yi.Framework.Core;
|
||||
using Yi.Framework.Core.Extensions;
|
||||
using Yi.Framework.Core.Sqlsugar;
|
||||
using Yi.Framework.Core.Sqlsugar.Repository;
|
||||
using Yi.Framework.Ddd;
|
||||
using Yi.Framework.Ddd.Repository;
|
||||
using Yi.Framework.Web;
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
builder.UseYiModules();
|
||||
// Add services to the container.
|
||||
|
||||
builder.UseYiModules(
|
||||
typeof(YiFrameworkCoreModule).Assembly,
|
||||
typeof(YiFrameworkDddModule).Assembly,
|
||||
typeof(YiFrameworkCoreSqlsugarModule).Assembly
|
||||
);
|
||||
builder.Services.AddControllers();
|
||||
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
|
||||
builder.Services.AddDynamicWebApi();
|
||||
|
||||
|
||||
builder.Services.AddEndpointsApiExplorer();
|
||||
builder.Services.AddSwaggerGen();
|
||||
|
||||
builder.Services.AddSwaggerServer<YiFrameworkApplicationModule>();
|
||||
//builder.Services.AddAutoIocServer("Yi.Framework.Core.Sqlsugar");
|
||||
|
||||
|
||||
var app = builder.Build();
|
||||
|
||||
// Configure the HTTP request pipeline.
|
||||
if (app.Environment.IsDevelopment())
|
||||
app.Services.GetRequiredService<IRepository<TestEntity>>();
|
||||
//if (app.Environment.IsDevelopment())
|
||||
{
|
||||
app.UseSwagger();
|
||||
app.UseSwaggerUI();
|
||||
app.UseSwaggerServer();
|
||||
}
|
||||
|
||||
app.UseHttpsRedirection();
|
||||
|
||||
app.UseAuthorization();
|
||||
|
||||
app.UseRouting();
|
||||
app.MapControllers();
|
||||
|
||||
app.Run();
|
||||
|
||||
6
src/Yi.Framework/Yi.Framework.Web/TestEntity.cs
Normal file
6
src/Yi.Framework/Yi.Framework.Web/TestEntity.cs
Normal file
@@ -0,0 +1,6 @@
|
||||
namespace Yi.Framework.Web
|
||||
{
|
||||
public class TestEntity
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
@@ -7,10 +7,9 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.2.3" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Yi.Framework.Application\Yi.Framework.Application.csproj" />
|
||||
<ProjectReference Include="..\Yi.Framework.AspNetCore\Yi.Framework.AspNetCore.csproj" />
|
||||
<ProjectReference Include="..\Yi.Framework.Core.Sqlsugar\Yi.Framework.Core.Sqlsugar.csproj" />
|
||||
<ProjectReference Include="..\Yi.Framework.Core\Yi.Framework.Core.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
using StartupModules;
|
||||
using Yi.Framework.Core.Module;
|
||||
|
||||
namespace Yi.Framework.Web
|
||||
{
|
||||
public class YiFrameworkWebModule : IYiModule
|
||||
public class YiFrameworkWebModule : IStartupModule
|
||||
{
|
||||
public void ConfigureServices(IServiceCollection services, ConfigureServicesContext context)
|
||||
{
|
||||
|
||||
@@ -5,5 +5,20 @@
|
||||
"Microsoft.AspNetCore": "Warning"
|
||||
}
|
||||
},
|
||||
"AllowedHosts": "*"
|
||||
"AllowedHosts": "*",
|
||||
|
||||
|
||||
//数据库列表
|
||||
"DbList": [ "Sqlite", "Mysql", "Sqlserver", "Oracle" ],
|
||||
//数据库类型选择
|
||||
"DbSelect": "Sqlite",
|
||||
//数据库连接地址,支持读写分离
|
||||
"DbConn": {
|
||||
"WriteUrl": "DataSource=yi-sqlsugar-dev.db",
|
||||
"ReadUrl": [
|
||||
"DataSource=[xxxx]", //sqlite
|
||||
"server=[xxxx];port=3306;database=[xxxx];user id=[xxxx];password=[xxxx]", //mysql
|
||||
"Data Source=[xxxx];Initial Catalog=[xxxx];User ID=[xxxx];password=[xxxx]" //sqlserver
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user