修改框架
This commit is contained in:
@@ -11,6 +11,7 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Yi.Framework.Common.IOCOptions;
|
||||
|
||||
namespace Yi.Framework.ApiMicroservice
|
||||
{
|
||||
@@ -28,6 +29,9 @@ namespace Yi.Framework.ApiMicroservice
|
||||
{
|
||||
|
||||
services.AddControllers();
|
||||
|
||||
services.Configure<SqliteOptions>(this.Configuration.GetSection("SqliteConn"));
|
||||
|
||||
services.AddSwaggerGen(c =>
|
||||
{
|
||||
c.SwaggerDoc("v1", new OpenApiInfo { Title = "Yi.Framework.ApiMicroservice", Version = "v1" });
|
||||
@@ -48,8 +52,10 @@ namespace Yi.Framework.ApiMicroservice
|
||||
|
||||
app.UseRouting();
|
||||
|
||||
app.UseAuthentication();
|
||||
app.UseAuthorization();
|
||||
|
||||
|
||||
app.UseEndpoints(endpoints =>
|
||||
{
|
||||
endpoints.MapControllers();
|
||||
|
||||
@@ -8,4 +8,8 @@
|
||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="5.6.3" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Yi.Framework.Model\Yi.Framework.Model.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
@@ -4,7 +4,7 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Yi.Common.IOCOptions
|
||||
namespace Yi.Framework.Common.IOCOptions
|
||||
{
|
||||
public class ElasticSearchOptions
|
||||
{
|
||||
|
||||
@@ -4,7 +4,7 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace CC.ElectronicCommerce.Common.IOCOptions
|
||||
namespace Yi.Framework.Common.IOCOptions
|
||||
{
|
||||
public class JWTTokenOptions
|
||||
{
|
||||
|
||||
@@ -4,7 +4,7 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace CC.ElectronicCommerce.Common.IOCOptions
|
||||
namespace Yi.Framework.Common.IOCOptions
|
||||
{
|
||||
public class KafkaOptions
|
||||
{
|
||||
|
||||
13
Yi.Framework/Yi.Framework.Common/IOCOptions/SqliteOptions.cs
Normal file
13
Yi.Framework/Yi.Framework.Common/IOCOptions/SqliteOptions.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Yi.Framework.Common.IOCOptions
|
||||
{
|
||||
public class SqliteOptions
|
||||
{
|
||||
public string Url { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -4,4 +4,8 @@
|
||||
<TargetFramework>net5.0</TargetFramework>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="QueueModel\" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
@@ -11,9 +11,9 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.IO;
|
||||
using CC.ElectronicCommerce.Common.IOCOptions;
|
||||
using Yi.Framework.Common.IOCOptions;
|
||||
|
||||
namespace CC.ElectronicCommerce.Core
|
||||
namespace Yi.Framework.Core
|
||||
{
|
||||
public class CacheClientDB : IDisposable
|
||||
{
|
||||
|
||||
36
Yi.Framework/Yi.Framework.Model/Models/DataContext.cs
Normal file
36
Yi.Framework/Yi.Framework.Model/Models/DataContext.cs
Normal file
@@ -0,0 +1,36 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Options;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Yi.Framework.Common.IOCOptions;
|
||||
|
||||
namespace Yi.Framework.Model.Models
|
||||
{
|
||||
public class DataContext : DbContext
|
||||
{
|
||||
private readonly IOptionsMonitor<SqliteOptions> _optionsMonitor;
|
||||
private readonly string _connStr;
|
||||
|
||||
public DataContext(IOptionsMonitor<SqliteOptions> optionsMonitor)
|
||||
{
|
||||
_optionsMonitor = optionsMonitor;
|
||||
_connStr = _optionsMonitor.CurrentValue.Url;
|
||||
}
|
||||
|
||||
public DataContext(string connstr)
|
||||
{
|
||||
_connStr = connstr;
|
||||
}
|
||||
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
||||
{
|
||||
if (!optionsBuilder.IsConfigured)
|
||||
{
|
||||
optionsBuilder.UseSqlite(_connStr);
|
||||
}
|
||||
}
|
||||
//public virtual DbSet<TbBrand> TbBrand { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -4,4 +4,16 @@
|
||||
<TargetFramework>net5.0</TargetFramework>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="Search\" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="5.0.10" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Yi.Framework.Common\Yi.Framework.Common.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
@@ -4,4 +4,8 @@
|
||||
<TargetFramework>net5.0</TargetFramework>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.AspNetCore.Http.Abstractions" Version="2.2.0" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
Reference in New Issue
Block a user