diff --git a/Yi.Framework/Yi.Framework.ApiMicroservice/Startup.cs b/Yi.Framework/Yi.Framework.ApiMicroservice/Startup.cs index e863e697..2936745f 100644 --- a/Yi.Framework/Yi.Framework.ApiMicroservice/Startup.cs +++ b/Yi.Framework/Yi.Framework.ApiMicroservice/Startup.cs @@ -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配置 + #endregion + services.AddIocService(Configuration); + #region //控制器+过滤器配置 #endregion @@ -50,25 +56,21 @@ namespace Yi.Framework.ApiMicroservice services.AddCorsService(); #region - //数据库服务配置 + //Sqlite服务配置 #endregion - services.AddDataBaseService("SqliteConn"); + services.AddSqliteService(); #region //Redis服务配置 #endregion - services.AddRedisService(); + //services.AddRedisService(); #region //RabbitMQ服务配置 #endregion - services.AddRabbitMQService(); - - //下面这些应自动注入 - services.AddScoped(); - services.AddScoped(); - + //services.AddRabbitMQService(); + } #region Autofac容器注入 @@ -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 //健康检查注入 #endregion - app.UseHealthCheckMiddleware(); + //app.UseHealthCheckMiddleware(); #region //鉴权注入 @@ -130,7 +132,7 @@ namespace Yi.Framework.ApiMicroservice #region //Consul服务注入 #endregion - await app.UseConsulService(); + //await app.UseConsulService(); #region //Endpoints注入 diff --git a/Yi.Framework/Yi.Framework.ApiMicroservice/SwaggerDoc.xml b/Yi.Framework/Yi.Framework.ApiMicroservice/SwaggerDoc.xml new file mode 100644 index 00000000..b5d09261 --- /dev/null +++ b/Yi.Framework/Yi.Framework.ApiMicroservice/SwaggerDoc.xml @@ -0,0 +1,43 @@ + + + + Yi.Framework.ApiMicroservice + + + + + 鏌 + + + + + + 鏇 + + + + + + + 鍒 + + + + + + + 澧 + + + + + + + 蹇呴』瀹炵幇IHostingStartup鎺ュ彛 + 蹇呴』鏍囪HostingStartup鐗规 + + 灏卞儚鏈ㄩ┈涓鏍 + + + + diff --git a/Yi.Framework/Yi.Framework.ApiMicroservice/Utility/CustomAutofacAop.cs b/Yi.Framework/Yi.Framework.ApiMicroservice/Utility/CustomAutofacAop.cs index 6dba1144..99fd8cc4 100644 --- a/Yi.Framework/Yi.Framework.ApiMicroservice/Utility/CustomAutofacAop.cs +++ b/Yi.Framework/Yi.Framework.ApiMicroservice/Utility/CustomAutofacAop.cs @@ -1,4 +1,5 @@ -锘縰sing System; +锘縰sing Castle.DynamicProxy; +using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; diff --git a/Yi.Framework/Yi.Framework.ApiMicroservice/Utility/CustomAutofacModule.cs b/Yi.Framework/Yi.Framework.ApiMicroservice/Utility/CustomAutofacModule.cs index 3f1dd70f..54bc78c3 100644 --- a/Yi.Framework/Yi.Framework.ApiMicroservice/Utility/CustomAutofacModule.cs +++ b/Yi.Framework/Yi.Framework.ApiMicroservice/Utility/CustomAutofacModule.cs @@ -39,9 +39,12 @@ namespace Yi.Framework.ApiMicroservice.Utility //containerBuilder.RegisterType().As().EnableInterfaceInterceptors();寮鍚疉op //灏嗘暟鎹簱瀵硅薄娉ㄥ叆 - containerBuilder.RegisterType().As().InstancePerLifetimeScope().EnableInterfaceInterceptors(); + //containerBuilder.RegisterType().As().InstancePerLifetimeScope().EnableInterfaceInterceptors(); - containerBuilder.RegisterGeneric(typeof(BaseService<>)).As(typeof(IBaseService<>)).EnableInterfaceInterceptors(); + containerBuilder.RegisterGeneric(typeof(BaseService<>)).As(typeof(IBaseService<>)).InstancePerLifetimeScope().EnableInterfaceInterceptors(); + + containerBuilder.RegisterType().As< IUserService >().InstancePerLifetimeScope().EnableInterfaceInterceptors(); + containerBuilder.RegisterType().As().InstancePerLifetimeScope().EnableInterfaceInterceptors(); } diff --git a/Yi.Framework/Yi.Framework.ApiMicroservice/YIDB.db b/Yi.Framework/Yi.Framework.ApiMicroservice/YIDB.db index e0d4e8a2..485bdae7 100644 Binary files a/Yi.Framework/Yi.Framework.ApiMicroservice/YIDB.db and b/Yi.Framework/Yi.Framework.ApiMicroservice/YIDB.db differ diff --git a/Yi.Framework/Yi.Framework.ApiMicroservice/Yi.Framework.ApiMicroservice.csproj b/Yi.Framework/Yi.Framework.ApiMicroservice/Yi.Framework.ApiMicroservice.csproj index 8a5f2724..c84c99f5 100644 --- a/Yi.Framework/Yi.Framework.ApiMicroservice/Yi.Framework.ApiMicroservice.csproj +++ b/Yi.Framework/Yi.Framework.ApiMicroservice/Yi.Framework.ApiMicroservice.csproj @@ -5,11 +5,14 @@ - D:\CC.Yi\CC.Yi\Yi.Framework\Yi.Framework.ApiMicroservice\Yi.Framework.ApiMicroservice.xml + D:\CC.Yi\CC.Yi\Yi.Framework\Yi.Framework.ApiMicroservice\SwaggerDoc.xml 1701;1702;CS1591 + + + all runtime; build; native; contentfiles; analyzers; buildtransitive @@ -21,6 +24,7 @@ + diff --git a/Yi.Framework/Yi.Framework.Core/ConsulExtend/ClienExtend/AbstractConsulDispatcher.cs b/Yi.Framework/Yi.Framework.Core/ConsulExtend/ClienExtend/AbstractConsulDispatcher.cs index a34e2063..b603875c 100644 --- a/Yi.Framework/Yi.Framework.Core/ConsulExtend/ClienExtend/AbstractConsulDispatcher.cs +++ b/Yi.Framework/Yi.Framework.Core/ConsulExtend/ClienExtend/AbstractConsulDispatcher.cs @@ -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 { diff --git a/Yi.Framework/Yi.Framework.Core/ConsulExtend/ClienExtend/PollingDispatcher.cs b/Yi.Framework/Yi.Framework.Core/ConsulExtend/ClienExtend/PollingDispatcher.cs index 2d8039c5..882d7fbc 100644 --- a/Yi.Framework/Yi.Framework.Core/ConsulExtend/ClienExtend/PollingDispatcher.cs +++ b/Yi.Framework/Yi.Framework.Core/ConsulExtend/ClienExtend/PollingDispatcher.cs @@ -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 { /// /// 杞 diff --git a/Yi.Framework/Yi.Framework.Core/ConsulExtend/ClienExtend/WeightDispatcher.cs b/Yi.Framework/Yi.Framework.Core/ConsulExtend/ClienExtend/WeightDispatcher.cs index 4f6b03fc..41a215f8 100644 --- a/Yi.Framework/Yi.Framework.Core/ConsulExtend/ClienExtend/WeightDispatcher.cs +++ b/Yi.Framework/Yi.Framework.Core/ConsulExtend/ClienExtend/WeightDispatcher.cs @@ -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 { diff --git a/Yi.Framework/Yi.Framework.Model/Migrations/20211010110842_yi-1.Designer.cs b/Yi.Framework/Yi.Framework.Model/Migrations/20211010110842_yi-1.Designer.cs deleted file mode 100644 index aceef25a..00000000 --- a/Yi.Framework/Yi.Framework.Model/Migrations/20211010110842_yi-1.Designer.cs +++ /dev/null @@ -1,39 +0,0 @@ -锘// -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("id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("age") - .HasColumnType("INTEGER"); - - b.Property("name") - .HasColumnType("TEXT"); - - b.HasKey("id"); - - b.ToTable("user"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/Yi.Framework/Yi.Framework.Model/Migrations/20211010110842_yi-1.cs b/Yi.Framework/Yi.Framework.Model/Migrations/20211010110842_yi-1.cs deleted file mode 100644 index 36b28f2e..00000000 --- a/Yi.Framework/Yi.Framework.Model/Migrations/20211010110842_yi-1.cs +++ /dev/null @@ -1,30 +0,0 @@ -锘縰sing 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(type: "INTEGER", nullable: false) - .Annotation("Sqlite:Autoincrement", true), - name = table.Column(type: "TEXT", nullable: true), - age = table.Column(type: "INTEGER", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_user", x => x.id); - }); - } - - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - name: "user"); - } - } -} diff --git a/Yi.Framework/Yi.Framework.Model/Migrations/20211011082334_yi-2.Designer.cs b/Yi.Framework/Yi.Framework.Model/Migrations/20211011082334_yi-2.Designer.cs deleted file mode 100644 index 29411c2c..00000000 --- a/Yi.Framework/Yi.Framework.Model/Migrations/20211011082334_yi-2.Designer.cs +++ /dev/null @@ -1,78 +0,0 @@ -锘// -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("id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("introduce") - .HasColumnType("TEXT"); - - b.Property("is_delete") - .HasColumnType("INTEGER"); - - b.Property("role_name") - .HasColumnType("TEXT"); - - b.HasKey("id"); - - b.ToTable("role"); - }); - - modelBuilder.Entity("Yi.Framework.Model.Models.user", b => - { - b.Property("id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("age") - .HasColumnType("INTEGER"); - - b.Property("email") - .HasColumnType("TEXT"); - - b.Property("icon") - .HasColumnType("TEXT"); - - b.Property("ip") - .HasColumnType("TEXT"); - - b.Property("is_delete") - .HasColumnType("INTEGER"); - - b.Property("nick") - .HasColumnType("TEXT"); - - b.Property("password") - .HasColumnType("TEXT"); - - b.Property("username") - .HasColumnType("TEXT"); - - b.HasKey("id"); - - b.ToTable("user"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/Yi.Framework/Yi.Framework.Model/Migrations/20211011082334_yi-2.cs b/Yi.Framework/Yi.Framework.Model/Migrations/20211011082334_yi-2.cs deleted file mode 100644 index 11b78255..00000000 --- a/Yi.Framework/Yi.Framework.Model/Migrations/20211011082334_yi-2.cs +++ /dev/null @@ -1,120 +0,0 @@ -锘縰sing 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( - name: "age", - table: "user", - type: "INTEGER", - nullable: true, - oldClrType: typeof(int), - oldType: "INTEGER"); - - migrationBuilder.AddColumn( - name: "email", - table: "user", - type: "TEXT", - nullable: true); - - migrationBuilder.AddColumn( - name: "icon", - table: "user", - type: "TEXT", - nullable: true); - - migrationBuilder.AddColumn( - name: "ip", - table: "user", - type: "TEXT", - nullable: true); - - migrationBuilder.AddColumn( - name: "is_delete", - table: "user", - type: "INTEGER", - nullable: false, - defaultValue: 0); - - migrationBuilder.AddColumn( - name: "nick", - table: "user", - type: "TEXT", - nullable: true); - - migrationBuilder.AddColumn( - name: "password", - table: "user", - type: "TEXT", - nullable: true); - - migrationBuilder.CreateTable( - name: "role", - columns: table => new - { - id = table.Column(type: "INTEGER", nullable: false) - .Annotation("Sqlite:Autoincrement", true), - role_name = table.Column(type: "TEXT", nullable: true), - introduce = table.Column(type: "TEXT", nullable: true), - is_delete = table.Column(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( - name: "age", - table: "user", - type: "INTEGER", - nullable: false, - defaultValue: 0, - oldClrType: typeof(int), - oldType: "INTEGER", - oldNullable: true); - } - } -} diff --git a/Yi.Framework/Yi.Framework.Model/Migrations/20211013073148_yi-1.Designer.cs b/Yi.Framework/Yi.Framework.Model/Migrations/20211013073148_yi-1.Designer.cs new file mode 100644 index 00000000..14b7641e --- /dev/null +++ b/Yi.Framework/Yi.Framework.Model/Migrations/20211013073148_yi-1.Designer.cs @@ -0,0 +1,218 @@ +锘// +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("id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("icon") + .HasColumnType("TEXT"); + + b.Property("is_delete") + .HasColumnType("INTEGER"); + + b.Property("is_top") + .HasColumnType("INTEGER"); + + b.Property("menu_name") + .HasColumnType("TEXT"); + + b.Property("menuid") + .HasColumnType("INTEGER"); + + b.Property("mouldid") + .HasColumnType("INTEGER"); + + b.Property("router") + .HasColumnType("TEXT"); + + b.Property("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("id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("is_delete") + .HasColumnType("INTEGER"); + + b.Property("mould_name") + .HasColumnType("TEXT"); + + b.Property("url") + .HasColumnType("TEXT"); + + b.HasKey("id"); + + b.ToTable("mould"); + }); + + modelBuilder.Entity("Yi.Framework.Model.Models.role", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("introduce") + .HasColumnType("TEXT"); + + b.Property("is_delete") + .HasColumnType("INTEGER"); + + b.Property("role_name") + .HasColumnType("TEXT"); + + b.HasKey("id"); + + b.ToTable("role"); + }); + + modelBuilder.Entity("Yi.Framework.Model.Models.user", b => + { + b.Property("id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("age") + .HasColumnType("INTEGER"); + + b.Property("email") + .HasColumnType("TEXT"); + + b.Property("icon") + .HasColumnType("TEXT"); + + b.Property("introduction") + .HasColumnType("TEXT"); + + b.Property("ip") + .HasColumnType("TEXT"); + + b.Property("is_delete") + .HasColumnType("INTEGER"); + + b.Property("nick") + .HasColumnType("TEXT"); + + b.Property("password") + .HasColumnType("TEXT"); + + b.Property("username") + .HasColumnType("TEXT"); + + b.HasKey("id"); + + b.ToTable("user"); + }); + + modelBuilder.Entity("menurole", b => + { + b.Property("menusid") + .HasColumnType("INTEGER"); + + b.Property("rolesid") + .HasColumnType("INTEGER"); + + b.HasKey("menusid", "rolesid"); + + b.HasIndex("rolesid"); + + b.ToTable("menurole"); + }); + + modelBuilder.Entity("roleuser", b => + { + b.Property("rolesid") + .HasColumnType("INTEGER"); + + b.Property("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 + } + } +} diff --git a/Yi.Framework/Yi.Framework.Model/Migrations/20211013073148_yi-1.cs b/Yi.Framework/Yi.Framework.Model/Migrations/20211013073148_yi-1.cs new file mode 100644 index 00000000..4a4475f7 --- /dev/null +++ b/Yi.Framework/Yi.Framework.Model/Migrations/20211013073148_yi-1.cs @@ -0,0 +1,182 @@ +锘縰sing 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(type: "INTEGER", nullable: false) + .Annotation("Sqlite:Autoincrement", true), + mould_name = table.Column(type: "TEXT", nullable: true), + url = table.Column(type: "TEXT", nullable: true), + is_delete = table.Column(type: "INTEGER", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_mould", x => x.id); + }); + + migrationBuilder.CreateTable( + name: "role", + columns: table => new + { + id = table.Column(type: "INTEGER", nullable: false) + .Annotation("Sqlite:Autoincrement", true), + role_name = table.Column(type: "TEXT", nullable: true), + introduce = table.Column(type: "TEXT", nullable: true), + is_delete = table.Column(type: "INTEGER", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_role", x => x.id); + }); + + migrationBuilder.CreateTable( + name: "user", + columns: table => new + { + id = table.Column(type: "INTEGER", nullable: false) + .Annotation("Sqlite:Autoincrement", true), + username = table.Column(type: "TEXT", nullable: true), + password = table.Column(type: "TEXT", nullable: true), + icon = table.Column(type: "TEXT", nullable: true), + nick = table.Column(type: "TEXT", nullable: true), + email = table.Column(type: "TEXT", nullable: true), + ip = table.Column(type: "TEXT", nullable: true), + age = table.Column(type: "INTEGER", nullable: true), + introduction = table.Column(type: "TEXT", nullable: true), + is_delete = table.Column(type: "INTEGER", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_user", x => x.id); + }); + + migrationBuilder.CreateTable( + name: "menu", + columns: table => new + { + id = table.Column(type: "INTEGER", nullable: false) + .Annotation("Sqlite:Autoincrement", true), + icon = table.Column(type: "TEXT", nullable: true), + router = table.Column(type: "TEXT", nullable: true), + menu_name = table.Column(type: "TEXT", nullable: true), + mouldid = table.Column(type: "INTEGER", nullable: true), + menuid = table.Column(type: "INTEGER", nullable: true), + is_delete = table.Column(type: "INTEGER", nullable: false), + is_top = table.Column(type: "INTEGER", nullable: true), + sort = table.Column(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(type: "INTEGER", nullable: false), + usersid = table.Column(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(type: "INTEGER", nullable: false), + rolesid = table.Column(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"); + } + } +} diff --git a/Yi.Framework/Yi.Framework.Model/Migrations/DataContextModelSnapshot.cs b/Yi.Framework/Yi.Framework.Model/Migrations/DataContextModelSnapshot.cs index 98ce4e57..7eb9c22e 100644 --- a/Yi.Framework/Yi.Framework.Model/Migrations/DataContextModelSnapshot.cs +++ b/Yi.Framework/Yi.Framework.Model/Migrations/DataContextModelSnapshot.cs @@ -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("id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("icon") + .HasColumnType("TEXT"); + + b.Property("is_delete") + .HasColumnType("INTEGER"); + + b.Property("is_top") + .HasColumnType("INTEGER"); + + b.Property("menu_name") + .HasColumnType("TEXT"); + + b.Property("menuid") + .HasColumnType("INTEGER"); + + b.Property("mouldid") + .HasColumnType("INTEGER"); + + b.Property("router") + .HasColumnType("TEXT"); + + b.Property("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("id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("is_delete") + .HasColumnType("INTEGER"); + + b.Property("mould_name") + .HasColumnType("TEXT"); + + b.Property("url") + .HasColumnType("TEXT"); + + b.HasKey("id"); + + b.ToTable("mould"); + }); + modelBuilder.Entity("Yi.Framework.Model.Models.role", b => { b.Property("id") @@ -51,6 +110,9 @@ namespace Yi.Framework.Model.Migrations b.Property("icon") .HasColumnType("TEXT"); + b.Property("introduction") + .HasColumnType("TEXT"); + b.Property("ip") .HasColumnType("TEXT"); @@ -70,6 +132,84 @@ namespace Yi.Framework.Model.Migrations b.ToTable("user"); }); + + modelBuilder.Entity("menurole", b => + { + b.Property("menusid") + .HasColumnType("INTEGER"); + + b.Property("rolesid") + .HasColumnType("INTEGER"); + + b.HasKey("menusid", "rolesid"); + + b.HasIndex("rolesid"); + + b.ToTable("menurole"); + }); + + modelBuilder.Entity("roleuser", b => + { + b.Property("rolesid") + .HasColumnType("INTEGER"); + + b.Property("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 } } diff --git a/Yi.Framework/Yi.Framework.Model/Models/mould.cs b/Yi.Framework/Yi.Framework.Model/Models/mould.cs index 659bddc9..17ff8a60 100644 --- a/Yi.Framework/Yi.Framework.Model/Models/mould.cs +++ b/Yi.Framework/Yi.Framework.Model/Models/mould.cs @@ -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; } } } diff --git a/Yi.Framework/Yi.Framework.Service/MouldService.cs b/Yi.Framework/Yi.Framework.Service/MouldService.cs index 1be110ae..ff64a8e2 100644 --- a/Yi.Framework/Yi.Framework.Service/MouldService.cs +++ b/Yi.Framework/Yi.Framework.Service/MouldService.cs @@ -27,8 +27,9 @@ namespace Yi.Framework.Service public async Task GetMenuByMould(mould _mould) { - var mould_data= await _Db.Set().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().Include(u=>u.menu).Where(u => u.id == _mould.id&& u.is_delete == (short)Common.Enum.DelFlagEnum.Normal).FirstOrDefaultAsync(); + // return mould_data.menu; } } } diff --git a/Yi.Framework/Yi.Framework.WebCore/Appsettings.cs b/Yi.Framework/Yi.Framework.WebCore/Appsettings.cs index 0d639e9c..5e07a61c 100644 --- a/Yi.Framework/Yi.Framework.WebCore/Appsettings.cs +++ b/Yi.Framework/Yi.Framework.WebCore/Appsettings.cs @@ -9,7 +9,7 @@ namespace Yi.Framework.WebCore /// /// appsettings.json鎿嶄綔绫 /// - 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 /// public static T app(params string[] sections) { - List list = new List(); + T app = Activator.CreateInstance(); // 寮曠敤 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)); } } } diff --git a/Yi.Framework/Yi.Framework.WebCore/FilterExtend/CustomActionCheckFilterAttribute.cs b/Yi.Framework/Yi.Framework.WebCore/FilterExtend/CustomActionCheckFilterAttribute.cs index 8e255fae..a328775d 100644 --- a/Yi.Framework/Yi.Framework.WebCore/FilterExtend/CustomActionCheckFilterAttribute.cs +++ b/Yi.Framework/Yi.Framework.WebCore/FilterExtend/CustomActionCheckFilterAttribute.cs @@ -18,7 +18,6 @@ namespace Yi.Framework.WebCore.FilterExtend { #region Identity private readonly ILogger _logger; - private readonly IModelMetadataProvider _modelMetadataProvider; public CustomActionCheckFilterAttribute(ILogger logger) { this._logger = logger; diff --git a/Yi.Framework/Yi.Framework.WebCore/MiddlewareExtend/CorsExtension.cs b/Yi.Framework/Yi.Framework.WebCore/MiddlewareExtend/CorsExtension.cs index c5d8827a..457944dc 100644 --- a/Yi.Framework/Yi.Framework.WebCore/MiddlewareExtend/CorsExtension.cs +++ b/Yi.Framework/Yi.Framework.WebCore/MiddlewareExtend/CorsExtension.cs @@ -1,6 +1,5 @@ 锘縰sing Microsoft.AspNetCore.Builder; using Microsoft.Extensions.DependencyInjection; -using Microsoft.OpenApi.Models; using System; using System.IO; diff --git a/Yi.Framework/Yi.Framework.WebCore/MiddlewareExtend/DataBaseExtension.cs b/Yi.Framework/Yi.Framework.WebCore/MiddlewareExtend/DataBaseExtension.cs deleted file mode 100644 index 3a29a6eb..00000000 --- a/Yi.Framework/Yi.Framework.WebCore/MiddlewareExtend/DataBaseExtension.cs +++ /dev/null @@ -1,27 +0,0 @@ -锘縰sing 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 -{ - /// - /// 鏁版嵁搴撴墿灞 - /// - public static class DataBaseExtension - { - public static IServiceCollection AddDataBaseService(this IServiceCollection services , string appsettings) - { - Appsettings.app(appsettings); - return services; - } - - public static void UseDataBaseService(this IApplicationBuilder app) - { - - } - - } -} diff --git a/Yi.Framework/Yi.Framework.WebCore/MiddlewareExtend/IocExtension.cs b/Yi.Framework/Yi.Framework.WebCore/MiddlewareExtend/IocExtension.cs new file mode 100644 index 00000000..3254e064 --- /dev/null +++ b/Yi.Framework/Yi.Framework.WebCore/MiddlewareExtend/IocExtension.cs @@ -0,0 +1,32 @@ +锘縰sing 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 +{ + /// + /// 閫氱敤璺ㄥ煙鎵╁睍 + /// + public static class IocExtension + { + public static IServiceCollection AddIocService(this IServiceCollection services, IConfiguration configuration) + { + #region + //閰嶇疆鏂囦欢浣跨敤閰嶇疆 + #endregion + services.AddSingleton(new Appsettings(configuration)); + + #region + //鏁版嵁搴撻厤缃 + #endregion + services.AddScoped(); + + return services; + } + + } +} diff --git a/Yi.Framework/Yi.Framework.WebCore/MiddlewareExtend/RabbitMQExtension.cs b/Yi.Framework/Yi.Framework.WebCore/MiddlewareExtend/RabbitMQExtension.cs index 2847fb98..54f63136 100644 --- a/Yi.Framework/Yi.Framework.WebCore/MiddlewareExtend/RabbitMQExtension.cs +++ b/Yi.Framework/Yi.Framework.WebCore/MiddlewareExtend/RabbitMQExtension.cs @@ -14,7 +14,7 @@ namespace Yi.Framework.WebCore.MiddlewareExtend { public static IServiceCollection AddRabbitMQService(this IServiceCollection services) { - Appsettings.app("RabbitConn"); + services.Configure(Appsettings.appConfiguration("RabbitConn")); return services; } } diff --git a/Yi.Framework/Yi.Framework.WebCore/MiddlewareExtend/RedisExtension.cs b/Yi.Framework/Yi.Framework.WebCore/MiddlewareExtend/RedisExtension.cs index bfa248d4..4cfbec69 100644 --- a/Yi.Framework/Yi.Framework.WebCore/MiddlewareExtend/RedisExtension.cs +++ b/Yi.Framework/Yi.Framework.WebCore/MiddlewareExtend/RedisExtension.cs @@ -14,7 +14,7 @@ namespace Yi.Framework.WebCore.MiddlewareExtend { public static IServiceCollection AddRedisService(this IServiceCollection services) { - Appsettings.app("RedisConn"); + services.Configure(Appsettings.appConfiguration("RedisConn")); return services; } } diff --git a/Yi.Framework/Yi.Framework.WebCore/MiddlewareExtend/SqliteExtension.cs b/Yi.Framework/Yi.Framework.WebCore/MiddlewareExtend/SqliteExtension.cs new file mode 100644 index 00000000..fec73a51 --- /dev/null +++ b/Yi.Framework/Yi.Framework.WebCore/MiddlewareExtend/SqliteExtension.cs @@ -0,0 +1,20 @@ +锘縰sing Microsoft.AspNetCore.Builder; +using Microsoft.Extensions.DependencyInjection; +using System; +using System.IO; +using Yi.Framework.Common.IOCOptions; + +namespace Yi.Framework.WebCore.MiddlewareExtend +{ + /// + /// 鏁版嵁搴撴墿灞 + /// + public static class SqliteExtension + { + public static IServiceCollection AddSqliteService(this IServiceCollection services) + { + services.Configure(Appsettings.appConfiguration("SqliteConn")); + return services; + } + } +} diff --git a/Yi.Framework/Yi.Framework.WebCore/MiddlewareExtend/SwaggerExtension.cs b/Yi.Framework/Yi.Framework.WebCore/MiddlewareExtend/SwaggerExtension.cs index e0802d84..d395358a 100644 --- a/Yi.Framework/Yi.Framework.WebCore/MiddlewareExtend/SwaggerExtension.cs +++ b/Yi.Framework/Yi.Framework.WebCore/MiddlewareExtend/SwaggerExtension.cs @@ -28,10 +28,10 @@ namespace Yi.Framework.WebCore.MiddlewareExtend //涓 Swagger JSON and UI璁剧疆xml鏂囨。娉ㄩ噴璺緞 //鑾峰彇搴旂敤绋嬪簭鎵鍦ㄧ洰褰(缁濆璺緞锛屼笉鍙楀伐浣滅洰褰曞奖鍝嶏紝寤鸿閲囩敤姝ゆ柟娉曡幏鍙栬矾寰勪娇鐢╳indwos&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(); diff --git a/Yi.Framework/Yi.Framework.WebCore/Yi.Framework.WebCore.csproj b/Yi.Framework/Yi.Framework.WebCore/Yi.Framework.WebCore.csproj index 6a3ce067..8100a672 100644 --- a/Yi.Framework/Yi.Framework.WebCore/Yi.Framework.WebCore.csproj +++ b/Yi.Framework/Yi.Framework.WebCore/Yi.Framework.WebCore.csproj @@ -9,10 +9,12 @@ + +