修改框架

This commit is contained in:
橙子
2021-10-10 17:52:23 +08:00
parent cf062cadcd
commit ee14ab4d2b
11 changed files with 84 additions and 5 deletions

View File

@@ -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();

View File

@@ -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>

View File

@@ -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
{

View File

@@ -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
{

View File

@@ -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
{

View 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; }
}
}

View File

@@ -4,4 +4,8 @@
<TargetFramework>net5.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<Folder Include="QueueModel\" />
</ItemGroup>
</Project>

View File

@@ -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
{

View 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; }
}
}

View File

@@ -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>

View File

@@ -4,4 +4,8 @@
<TargetFramework>net5.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Http.Abstractions" Version="2.2.0" />
</ItemGroup>
</Project>