优化扩展

This commit is contained in:
橙子
2021-10-13 15:40:56 +08:00
parent 16eb1fb1e2
commit e9bc71393c
28 changed files with 687 additions and 326 deletions

View File

@@ -18,6 +18,7 @@ using Yi.Framework.Common.IOCOptions;
using Yi.Framework.Interface;
using Yi.Framework.Model;
using Yi.Framework.Service;
using Yi.Framework.WebCore;
using Yi.Framework.WebCore.MiddlewareExtend;
namespace Yi.Framework.ApiMicroservice
@@ -34,6 +35,11 @@ namespace Yi.Framework.ApiMicroservice
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
#region
//Ioc<6F><63><EFBFBD><EFBFBD>
#endregion
services.AddIocService(Configuration);
#region
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>+<2B><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
#endregion
@@ -50,25 +56,21 @@ namespace Yi.Framework.ApiMicroservice
services.AddCorsService();
#region
//<EFBFBD><EFBFBD><EFBFBD>ݿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
//Sqlite<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
#endregion
services.AddDataBaseService<SqliteOptions>("SqliteConn");
services.AddSqliteService();
#region
//Redis<69><73><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
#endregion
services.AddRedisService();
//services.AddRedisService();
#region
//RabbitMQ<4D><51><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
#endregion
services.AddRabbitMQService();
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ЩӦ<D0A9>Զ<EFBFBD>ע<EFBFBD><D7A2>
services.AddScoped<IUserService, UserService>();
services.AddScoped<IRoleService, RoleService>();
//services.AddRabbitMQService();
}
#region Autofac<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ע<EFBFBD><EFBFBD>
@@ -82,7 +84,7 @@ namespace Yi.Framework.ApiMicroservice
#endregion
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public async void Configure(IApplicationBuilder app, IWebHostEnvironment env)
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
//if (env.IsDevelopment())
{
@@ -115,7 +117,7 @@ namespace Yi.Framework.ApiMicroservice
#region
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ע<EFBFBD><D7A2>
#endregion
app.UseHealthCheckMiddleware();
//app.UseHealthCheckMiddleware();
#region
//<2F><>Ȩע<C8A8><D7A2>
@@ -130,7 +132,7 @@ namespace Yi.Framework.ApiMicroservice
#region
//Consul<75><6C><EFBFBD><EFBFBD>ע<EFBFBD><D7A2>
#endregion
await app.UseConsulService();
//await app.UseConsulService();
#region
//Endpointsע<73><D7A2>

View File

@@ -0,0 +1,43 @@
<?xml version="1.0"?>
<doc>
<assembly>
<name>Yi.Framework.ApiMicroservice</name>
</assembly>
<members>
<member name="M:Yi.Framework.ApiMicroservice.Controllers.UserController.GetUser">
<summary>
</summary>
<returns></returns>
</member>
<member name="M:Yi.Framework.ApiMicroservice.Controllers.UserController.UpdateUser(Yi.Framework.Model.Models.user)">
<summary>
</summary>
<param name="_user"></param>
<returns></returns>
</member>
<member name="M:Yi.Framework.ApiMicroservice.Controllers.UserController.DelListUser(System.Collections.Generic.List{System.Int32})">
<summary>
</summary>
<param name="_ids"></param>
<returns></returns>
</member>
<member name="M:Yi.Framework.ApiMicroservice.Controllers.UserController.AddUser(Yi.Framework.Model.Models.user)">
<summary>
</summary>
<param name="_user"></param>
<returns></returns>
</member>
<member name="T:Yi.Framework.ApiMicroservice.Utility.CustomHostingStartup">
<summary>
必须实现IHostingStartup接口
必须标记HostingStartup特性
就像木马一样
</summary>
</member>
</members>
</doc>

View File

@@ -1,4 +1,5 @@
using System;
using Castle.DynamicProxy;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

View File

@@ -39,9 +39,12 @@ namespace Yi.Framework.ApiMicroservice.Utility
//containerBuilder.RegisterType<A>().As<IA>().EnableInterfaceInterceptors();开启Aop
//将数据库对象注入
containerBuilder.RegisterType<DataContext>().As<DbContext>().InstancePerLifetimeScope().EnableInterfaceInterceptors();
//containerBuilder.RegisterType<DataContext>().As<DbContext>().InstancePerLifetimeScope().EnableInterfaceInterceptors();
containerBuilder.RegisterGeneric(typeof(BaseService<>)).As(typeof(IBaseService<>)).EnableInterfaceInterceptors();
containerBuilder.RegisterGeneric(typeof(BaseService<>)).As(typeof(IBaseService<>)).InstancePerLifetimeScope().EnableInterfaceInterceptors();
containerBuilder.RegisterType<UserService>().As< IUserService >().InstancePerLifetimeScope().EnableInterfaceInterceptors();
containerBuilder.RegisterType<RoleService>().As<IRoleService>().InstancePerLifetimeScope().EnableInterfaceInterceptors();
}

View File

@@ -5,11 +5,14 @@
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<DocumentationFile>D:\CC.Yi\CC.Yi\Yi.Framework\Yi.Framework.ApiMicroservice\Yi.Framework.ApiMicroservice.xml</DocumentationFile>
<DocumentationFile>D:\CC.Yi\CC.Yi\Yi.Framework\Yi.Framework.ApiMicroservice\SwaggerDoc.xml</DocumentationFile>
<NoWarn>1701;1702;CS1591</NoWarn>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Autofac" Version="6.3.0" />
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="7.1.0" />
<PackageReference Include="Autofac.Extras.DynamicProxy" Version="6.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="5.0.10">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
@@ -21,6 +24,7 @@
<ProjectReference Include="..\Yi.Framework.Interface\Yi.Framework.Interface.csproj" />
<ProjectReference Include="..\Yi.Framework.Model\Yi.Framework.Model.csproj" />
<ProjectReference Include="..\Yi.Framework.Service\Yi.Framework.Service.csproj" />
<ProjectReference Include="..\Yi.Framework.WebCore\Yi.Framework.WebCore.csproj" />
</ItemGroup>
</Project>

View File

@@ -5,6 +5,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Yi.Framework.Common.IOCOptions;
namespace Yi.Framework.Core.ConsulExtend
{

View File

@@ -4,8 +4,9 @@ using System.Linq;
using System.Text;
using Consul;
using Microsoft.Extensions.Options;
using Yi.Framework.Common.IOCOptions;
namespace CC.ElectronicCommerce.Core.ConsulExtend
namespace Yi.Framework.Core.ConsulExtend
{
/// <summary>
/// 轮询

View File

@@ -4,6 +4,7 @@ using System.Linq;
using System.Text;
using Consul;
using Microsoft.Extensions.Options;
using Yi.Framework.Common.IOCOptions;
namespace Yi.Framework.Core.ConsulExtend
{

View File

@@ -1,39 +0,0 @@
// <auto-generated />
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Yi.Framework.Model;
namespace Yi.Framework.Model.Migrations
{
[DbContext(typeof(DataContext))]
[Migration("20211010110842_yi-1")]
partial class yi1
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "5.0.10");
modelBuilder.Entity("Yi.Framework.Model.Models.user", b =>
{
b.Property<int>("id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<int>("age")
.HasColumnType("INTEGER");
b.Property<string>("name")
.HasColumnType("TEXT");
b.HasKey("id");
b.ToTable("user");
});
#pragma warning restore 612, 618
}
}
}

View File

@@ -1,30 +0,0 @@
using Microsoft.EntityFrameworkCore.Migrations;
namespace Yi.Framework.Model.Migrations
{
public partial class yi1 : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "user",
columns: table => new
{
id = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
name = table.Column<string>(type: "TEXT", nullable: true),
age = table.Column<int>(type: "INTEGER", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_user", x => x.id);
});
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "user");
}
}
}

View File

@@ -1,78 +0,0 @@
// <auto-generated />
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Yi.Framework.Model;
namespace Yi.Framework.Model.Migrations
{
[DbContext(typeof(DataContext))]
[Migration("20211011082334_yi-2")]
partial class yi2
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "5.0.10");
modelBuilder.Entity("Yi.Framework.Model.Models.role", b =>
{
b.Property<int>("id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<string>("introduce")
.HasColumnType("TEXT");
b.Property<int>("is_delete")
.HasColumnType("INTEGER");
b.Property<string>("role_name")
.HasColumnType("TEXT");
b.HasKey("id");
b.ToTable("role");
});
modelBuilder.Entity("Yi.Framework.Model.Models.user", b =>
{
b.Property<int>("id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<int?>("age")
.HasColumnType("INTEGER");
b.Property<string>("email")
.HasColumnType("TEXT");
b.Property<string>("icon")
.HasColumnType("TEXT");
b.Property<string>("ip")
.HasColumnType("TEXT");
b.Property<int>("is_delete")
.HasColumnType("INTEGER");
b.Property<string>("nick")
.HasColumnType("TEXT");
b.Property<string>("password")
.HasColumnType("TEXT");
b.Property<string>("username")
.HasColumnType("TEXT");
b.HasKey("id");
b.ToTable("user");
});
#pragma warning restore 612, 618
}
}
}

View File

@@ -1,120 +0,0 @@
using Microsoft.EntityFrameworkCore.Migrations;
namespace Yi.Framework.Model.Migrations
{
public partial class yi2 : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.RenameColumn(
name: "name",
table: "user",
newName: "username");
migrationBuilder.AlterColumn<int>(
name: "age",
table: "user",
type: "INTEGER",
nullable: true,
oldClrType: typeof(int),
oldType: "INTEGER");
migrationBuilder.AddColumn<string>(
name: "email",
table: "user",
type: "TEXT",
nullable: true);
migrationBuilder.AddColumn<string>(
name: "icon",
table: "user",
type: "TEXT",
nullable: true);
migrationBuilder.AddColumn<string>(
name: "ip",
table: "user",
type: "TEXT",
nullable: true);
migrationBuilder.AddColumn<int>(
name: "is_delete",
table: "user",
type: "INTEGER",
nullable: false,
defaultValue: 0);
migrationBuilder.AddColumn<string>(
name: "nick",
table: "user",
type: "TEXT",
nullable: true);
migrationBuilder.AddColumn<string>(
name: "password",
table: "user",
type: "TEXT",
nullable: true);
migrationBuilder.CreateTable(
name: "role",
columns: table => new
{
id = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
role_name = table.Column<string>(type: "TEXT", nullable: true),
introduce = table.Column<string>(type: "TEXT", nullable: true),
is_delete = table.Column<int>(type: "INTEGER", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_role", x => x.id);
});
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "role");
migrationBuilder.DropColumn(
name: "email",
table: "user");
migrationBuilder.DropColumn(
name: "icon",
table: "user");
migrationBuilder.DropColumn(
name: "ip",
table: "user");
migrationBuilder.DropColumn(
name: "is_delete",
table: "user");
migrationBuilder.DropColumn(
name: "nick",
table: "user");
migrationBuilder.DropColumn(
name: "password",
table: "user");
migrationBuilder.RenameColumn(
name: "username",
table: "user",
newName: "name");
migrationBuilder.AlterColumn<int>(
name: "age",
table: "user",
type: "INTEGER",
nullable: false,
defaultValue: 0,
oldClrType: typeof(int),
oldType: "INTEGER",
oldNullable: true);
}
}
}

View File

@@ -0,0 +1,218 @@
// <auto-generated />
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Yi.Framework.Model;
namespace Yi.Framework.Model.Migrations
{
[DbContext(typeof(DataContext))]
[Migration("20211013073148_yi-1")]
partial class yi1
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "5.0.10");
modelBuilder.Entity("Yi.Framework.Model.Models.menu", b =>
{
b.Property<int>("id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<string>("icon")
.HasColumnType("TEXT");
b.Property<int>("is_delete")
.HasColumnType("INTEGER");
b.Property<int?>("is_top")
.HasColumnType("INTEGER");
b.Property<string>("menu_name")
.HasColumnType("TEXT");
b.Property<int?>("menuid")
.HasColumnType("INTEGER");
b.Property<int?>("mouldid")
.HasColumnType("INTEGER");
b.Property<string>("router")
.HasColumnType("TEXT");
b.Property<int?>("sort")
.HasColumnType("INTEGER");
b.HasKey("id");
b.HasIndex("menuid");
b.HasIndex("mouldid");
b.ToTable("menu");
});
modelBuilder.Entity("Yi.Framework.Model.Models.mould", b =>
{
b.Property<int>("id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<int>("is_delete")
.HasColumnType("INTEGER");
b.Property<string>("mould_name")
.HasColumnType("TEXT");
b.Property<string>("url")
.HasColumnType("TEXT");
b.HasKey("id");
b.ToTable("mould");
});
modelBuilder.Entity("Yi.Framework.Model.Models.role", b =>
{
b.Property<int>("id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<string>("introduce")
.HasColumnType("TEXT");
b.Property<int>("is_delete")
.HasColumnType("INTEGER");
b.Property<string>("role_name")
.HasColumnType("TEXT");
b.HasKey("id");
b.ToTable("role");
});
modelBuilder.Entity("Yi.Framework.Model.Models.user", b =>
{
b.Property<int>("id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<int?>("age")
.HasColumnType("INTEGER");
b.Property<string>("email")
.HasColumnType("TEXT");
b.Property<string>("icon")
.HasColumnType("TEXT");
b.Property<string>("introduction")
.HasColumnType("TEXT");
b.Property<string>("ip")
.HasColumnType("TEXT");
b.Property<int>("is_delete")
.HasColumnType("INTEGER");
b.Property<string>("nick")
.HasColumnType("TEXT");
b.Property<string>("password")
.HasColumnType("TEXT");
b.Property<string>("username")
.HasColumnType("TEXT");
b.HasKey("id");
b.ToTable("user");
});
modelBuilder.Entity("menurole", b =>
{
b.Property<int>("menusid")
.HasColumnType("INTEGER");
b.Property<int>("rolesid")
.HasColumnType("INTEGER");
b.HasKey("menusid", "rolesid");
b.HasIndex("rolesid");
b.ToTable("menurole");
});
modelBuilder.Entity("roleuser", b =>
{
b.Property<int>("rolesid")
.HasColumnType("INTEGER");
b.Property<int>("usersid")
.HasColumnType("INTEGER");
b.HasKey("rolesid", "usersid");
b.HasIndex("usersid");
b.ToTable("roleuser");
});
modelBuilder.Entity("Yi.Framework.Model.Models.menu", b =>
{
b.HasOne("Yi.Framework.Model.Models.menu", null)
.WithMany("children")
.HasForeignKey("menuid");
b.HasOne("Yi.Framework.Model.Models.mould", "mould")
.WithMany()
.HasForeignKey("mouldid");
b.Navigation("mould");
});
modelBuilder.Entity("menurole", b =>
{
b.HasOne("Yi.Framework.Model.Models.menu", null)
.WithMany()
.HasForeignKey("menusid")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Yi.Framework.Model.Models.role", null)
.WithMany()
.HasForeignKey("rolesid")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("roleuser", b =>
{
b.HasOne("Yi.Framework.Model.Models.role", null)
.WithMany()
.HasForeignKey("rolesid")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Yi.Framework.Model.Models.user", null)
.WithMany()
.HasForeignKey("usersid")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Yi.Framework.Model.Models.menu", b =>
{
b.Navigation("children");
});
#pragma warning restore 612, 618
}
}
}

View File

@@ -0,0 +1,182 @@
using Microsoft.EntityFrameworkCore.Migrations;
namespace Yi.Framework.Model.Migrations
{
public partial class yi1 : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "mould",
columns: table => new
{
id = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
mould_name = table.Column<string>(type: "TEXT", nullable: true),
url = table.Column<string>(type: "TEXT", nullable: true),
is_delete = table.Column<int>(type: "INTEGER", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_mould", x => x.id);
});
migrationBuilder.CreateTable(
name: "role",
columns: table => new
{
id = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
role_name = table.Column<string>(type: "TEXT", nullable: true),
introduce = table.Column<string>(type: "TEXT", nullable: true),
is_delete = table.Column<int>(type: "INTEGER", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_role", x => x.id);
});
migrationBuilder.CreateTable(
name: "user",
columns: table => new
{
id = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
username = table.Column<string>(type: "TEXT", nullable: true),
password = table.Column<string>(type: "TEXT", nullable: true),
icon = table.Column<string>(type: "TEXT", nullable: true),
nick = table.Column<string>(type: "TEXT", nullable: true),
email = table.Column<string>(type: "TEXT", nullable: true),
ip = table.Column<string>(type: "TEXT", nullable: true),
age = table.Column<int>(type: "INTEGER", nullable: true),
introduction = table.Column<string>(type: "TEXT", nullable: true),
is_delete = table.Column<int>(type: "INTEGER", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_user", x => x.id);
});
migrationBuilder.CreateTable(
name: "menu",
columns: table => new
{
id = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
icon = table.Column<string>(type: "TEXT", nullable: true),
router = table.Column<string>(type: "TEXT", nullable: true),
menu_name = table.Column<string>(type: "TEXT", nullable: true),
mouldid = table.Column<int>(type: "INTEGER", nullable: true),
menuid = table.Column<int>(type: "INTEGER", nullable: true),
is_delete = table.Column<int>(type: "INTEGER", nullable: false),
is_top = table.Column<int>(type: "INTEGER", nullable: true),
sort = table.Column<int>(type: "INTEGER", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_menu", x => x.id);
table.ForeignKey(
name: "FK_menu_menu_menuid",
column: x => x.menuid,
principalTable: "menu",
principalColumn: "id",
onDelete: ReferentialAction.Restrict);
table.ForeignKey(
name: "FK_menu_mould_mouldid",
column: x => x.mouldid,
principalTable: "mould",
principalColumn: "id",
onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateTable(
name: "roleuser",
columns: table => new
{
rolesid = table.Column<int>(type: "INTEGER", nullable: false),
usersid = table.Column<int>(type: "INTEGER", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_roleuser", x => new { x.rolesid, x.usersid });
table.ForeignKey(
name: "FK_roleuser_role_rolesid",
column: x => x.rolesid,
principalTable: "role",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_roleuser_user_usersid",
column: x => x.usersid,
principalTable: "user",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "menurole",
columns: table => new
{
menusid = table.Column<int>(type: "INTEGER", nullable: false),
rolesid = table.Column<int>(type: "INTEGER", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_menurole", x => new { x.menusid, x.rolesid });
table.ForeignKey(
name: "FK_menurole_menu_menusid",
column: x => x.menusid,
principalTable: "menu",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_menurole_role_rolesid",
column: x => x.rolesid,
principalTable: "role",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_menu_menuid",
table: "menu",
column: "menuid");
migrationBuilder.CreateIndex(
name: "IX_menu_mouldid",
table: "menu",
column: "mouldid");
migrationBuilder.CreateIndex(
name: "IX_menurole_rolesid",
table: "menurole",
column: "rolesid");
migrationBuilder.CreateIndex(
name: "IX_roleuser_usersid",
table: "roleuser",
column: "usersid");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "menurole");
migrationBuilder.DropTable(
name: "roleuser");
migrationBuilder.DropTable(
name: "menu");
migrationBuilder.DropTable(
name: "role");
migrationBuilder.DropTable(
name: "user");
migrationBuilder.DropTable(
name: "mould");
}
}
}

View File

@@ -16,6 +16,65 @@ namespace Yi.Framework.Model.Migrations
modelBuilder
.HasAnnotation("ProductVersion", "5.0.10");
modelBuilder.Entity("Yi.Framework.Model.Models.menu", b =>
{
b.Property<int>("id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<string>("icon")
.HasColumnType("TEXT");
b.Property<int>("is_delete")
.HasColumnType("INTEGER");
b.Property<int?>("is_top")
.HasColumnType("INTEGER");
b.Property<string>("menu_name")
.HasColumnType("TEXT");
b.Property<int?>("menuid")
.HasColumnType("INTEGER");
b.Property<int?>("mouldid")
.HasColumnType("INTEGER");
b.Property<string>("router")
.HasColumnType("TEXT");
b.Property<int?>("sort")
.HasColumnType("INTEGER");
b.HasKey("id");
b.HasIndex("menuid");
b.HasIndex("mouldid");
b.ToTable("menu");
});
modelBuilder.Entity("Yi.Framework.Model.Models.mould", b =>
{
b.Property<int>("id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<int>("is_delete")
.HasColumnType("INTEGER");
b.Property<string>("mould_name")
.HasColumnType("TEXT");
b.Property<string>("url")
.HasColumnType("TEXT");
b.HasKey("id");
b.ToTable("mould");
});
modelBuilder.Entity("Yi.Framework.Model.Models.role", b =>
{
b.Property<int>("id")
@@ -51,6 +110,9 @@ namespace Yi.Framework.Model.Migrations
b.Property<string>("icon")
.HasColumnType("TEXT");
b.Property<string>("introduction")
.HasColumnType("TEXT");
b.Property<string>("ip")
.HasColumnType("TEXT");
@@ -70,6 +132,84 @@ namespace Yi.Framework.Model.Migrations
b.ToTable("user");
});
modelBuilder.Entity("menurole", b =>
{
b.Property<int>("menusid")
.HasColumnType("INTEGER");
b.Property<int>("rolesid")
.HasColumnType("INTEGER");
b.HasKey("menusid", "rolesid");
b.HasIndex("rolesid");
b.ToTable("menurole");
});
modelBuilder.Entity("roleuser", b =>
{
b.Property<int>("rolesid")
.HasColumnType("INTEGER");
b.Property<int>("usersid")
.HasColumnType("INTEGER");
b.HasKey("rolesid", "usersid");
b.HasIndex("usersid");
b.ToTable("roleuser");
});
modelBuilder.Entity("Yi.Framework.Model.Models.menu", b =>
{
b.HasOne("Yi.Framework.Model.Models.menu", null)
.WithMany("children")
.HasForeignKey("menuid");
b.HasOne("Yi.Framework.Model.Models.mould", "mould")
.WithMany()
.HasForeignKey("mouldid");
b.Navigation("mould");
});
modelBuilder.Entity("menurole", b =>
{
b.HasOne("Yi.Framework.Model.Models.menu", null)
.WithMany()
.HasForeignKey("menusid")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Yi.Framework.Model.Models.role", null)
.WithMany()
.HasForeignKey("rolesid")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("roleuser", b =>
{
b.HasOne("Yi.Framework.Model.Models.role", null)
.WithMany()
.HasForeignKey("rolesid")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Yi.Framework.Model.Models.user", null)
.WithMany()
.HasForeignKey("usersid")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Yi.Framework.Model.Models.menu", b =>
{
b.Navigation("children");
});
#pragma warning restore 612, 618
}
}

View File

@@ -10,6 +10,6 @@ namespace Yi.Framework.Model.Models
{
public string mould_name { get; set; }
public string url { get; set; }
public menu menu { get; set; }
//public menu menu { get; set; }
}
}

View File

@@ -27,8 +27,9 @@ namespace Yi.Framework.Service
public async Task<menu> GetMenuByMould(mould _mould)
{
var mould_data= await _Db.Set<mould>().Include(u=>u.menu).Where(u => u.id == _mould.id&& u.is_delete == (short)Common.Enum.DelFlagEnum.Normal).FirstOrDefaultAsync();
return mould_data.menu;
throw new Exception();
//var mould_data= await _Db.Set<mould>().Include(u=>u.menu).Where(u => u.id == _mould.id&& u.is_delete == (short)Common.Enum.DelFlagEnum.Normal).FirstOrDefaultAsync();
// return mould_data.menu;
}
}
}

View File

@@ -9,7 +9,7 @@ namespace Yi.Framework.WebCore
/// <summary>
/// appsettings.json操作类
/// </summary>
public class Appsettings
public class Appsettings
{
static IConfiguration Configuration { get; set; }
static string contentPath { get; set; }
@@ -26,7 +26,7 @@ namespace Yi.Framework.WebCore
.Add(new JsonConfigurationSource { Path = Path, Optional = false, ReloadOnChange = true })//这样的话可以直接读目录里的json文件而不是 bin 文件夹下的,所以不用修改复制属性
.Build();
}
public Appsettings(IConfiguration configuration)
{
Configuration = configuration;
@@ -60,10 +60,16 @@ namespace Yi.Framework.WebCore
/// <returns></returns>
public static T app<T>(params string[] sections)
{
List<T> list = new List<T>();
T app = Activator.CreateInstance<T>();
// 引用 Microsoft.Extensions.Configuration.Binder 包
Configuration.Bind(string.Join(":", sections), list);
return list[0];
Configuration.Bind(string.Join(":", sections), app);
return app;
}
public static IConfiguration appConfiguration(params string[] sections)
{
return Configuration.GetSection(string.Join(":", sections));
}
}
}

View File

@@ -18,7 +18,6 @@ namespace Yi.Framework.WebCore.FilterExtend
{
#region Identity
private readonly ILogger<CustomActionCheckFilterAttribute> _logger;
private readonly IModelMetadataProvider _modelMetadataProvider;
public CustomActionCheckFilterAttribute(ILogger<CustomActionCheckFilterAttribute> logger)
{
this._logger = logger;

View File

@@ -1,6 +1,5 @@
using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.OpenApi.Models;
using System;
using System.IO;

View File

@@ -1,27 +0,0 @@
using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.OpenApi.Models;
using System;
using System.IO;
using Yi.Framework.Common.IOCOptions;
namespace Yi.Framework.WebCore.MiddlewareExtend
{
/// <summary>
/// 数据库扩展
/// </summary>
public static class DataBaseExtension
{
public static IServiceCollection AddDataBaseService<IocOptios>(this IServiceCollection services , string appsettings)
{
Appsettings.app<IocOptios>(appsettings);
return services;
}
public static void UseDataBaseService(this IApplicationBuilder app)
{
}
}
}

View File

@@ -0,0 +1,32 @@
using Microsoft.AspNetCore.Builder;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using System;
using System.IO;
using Yi.Framework.Model;
namespace Yi.Framework.WebCore.MiddlewareExtend
{
/// <summary>
/// 通用跨域扩展
/// </summary>
public static class IocExtension
{
public static IServiceCollection AddIocService(this IServiceCollection services, IConfiguration configuration)
{
#region
//配置文件使用配置
#endregion
services.AddSingleton(new Appsettings(configuration));
#region
//数据库配置
#endregion
services.AddScoped<DbContext, DataContext>();
return services;
}
}
}

View File

@@ -14,7 +14,7 @@ namespace Yi.Framework.WebCore.MiddlewareExtend
{
public static IServiceCollection AddRabbitMQService(this IServiceCollection services)
{
Appsettings.app<RabbitMQOptions>("RabbitConn");
services.Configure<RabbitMQOptions>(Appsettings.appConfiguration("RabbitConn"));
return services;
}
}

View File

@@ -14,7 +14,7 @@ namespace Yi.Framework.WebCore.MiddlewareExtend
{
public static IServiceCollection AddRedisService(this IServiceCollection services)
{
Appsettings.app<RedisConnOptions>("RedisConn");
services.Configure<RedisConnOptions>(Appsettings.appConfiguration("RedisConn"));
return services;
}
}

View File

@@ -0,0 +1,20 @@
using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.DependencyInjection;
using System;
using System.IO;
using Yi.Framework.Common.IOCOptions;
namespace Yi.Framework.WebCore.MiddlewareExtend
{
/// <summary>
/// 数据库扩展
/// </summary>
public static class SqliteExtension
{
public static IServiceCollection AddSqliteService(this IServiceCollection services)
{
services.Configure<SqliteOptions>(Appsettings.appConfiguration("SqliteConn"));
return services;
}
}
}

View File

@@ -28,10 +28,10 @@ namespace Yi.Framework.WebCore.MiddlewareExtend
//为 Swagger JSON and UI设置xml文档注释路径
//获取应用程序所在目录(绝对路径不受工作目录影响建议采用此方法获取路径使用windwos&Linux
var basePath = Path.GetDirectoryName(typeof(Program).Assembly.Location);
var apiXmlPath = Path.Combine(basePath, @"ApiDoc.xml");//控制器层注释
var entityXmlPath = Path.Combine(basePath, @"SwaggerDoc.xml");//实体注释
var apiXmlPath = Path.Combine(basePath, @"SwaggerDoc.xml");//控制器层注释
//var entityXmlPath = Path.Combine(basePath, @"SwaggerDoc.xml");//实体注释
//c.IncludeXmlComments(apiXmlPath, true);//true表示显示控制器注释
c.IncludeXmlComments(entityXmlPath);
c.IncludeXmlComments(apiXmlPath);
//添加控制器注释
//c.DocumentFilter<SwaggerDocTag>();

View File

@@ -9,10 +9,12 @@
<PackageReference Include="Microsoft.AspNetCore.Http.Abstractions" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Abstractions" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Formatters.Json" Version="2.2.0" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="5.6.3" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Yi.Framework.Core\Yi.Framework.Core.csproj" />
<ProjectReference Include="..\Yi.Framework.Model\Yi.Framework.Model.csproj" />
</ItemGroup>
</Project>