数据库迁移

This commit is contained in:
橙子
2021-10-23 02:24:18 +08:00
parent eb15667d21
commit ea5d10d2b1
12 changed files with 177 additions and 762 deletions

View File

@@ -68,6 +68,11 @@ namespace Yi.Framework.ApiMicroservice
#endregion
services.AddSqliteService();
#region
//MySql<71><6C><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
#endregion
services.AddMysqlService();
#region
//Redis<69><73><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
#endregion
@@ -78,7 +83,7 @@ namespace Yi.Framework.ApiMicroservice
#endregion
//services.AddRabbitMQService();
}
#region Autofac<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ע<EFBFBD><EFBFBD>

View File

@@ -17,7 +17,7 @@
"Url": "Filename=YIDB.db"
},
"MysqlConn": {
"Url": "server=192.168.2.128;port=3306;database=ECDB;user id=root;password=123456"
"Url": "server=118.195.191.41;port=3306;database=YIDB;user id=root;password=Qz52013142020."
},
"JWTTokenOptions": {

View File

@@ -14,10 +14,10 @@ namespace Yi.Framework.Model
//Update-Database yi-1
public partial class DataContext : DbContext
{
private readonly IOptionsMonitor<SqliteOptions> _optionsMonitor;
private readonly IOptionsMonitor<MySqlConnOptions> _optionsMonitor;
private readonly string _connStr;
public DataContext(IOptionsMonitor<SqliteOptions> optionsMonitor)
public DataContext(IOptionsMonitor<MySqlConnOptions> optionsMonitor)
{
_optionsMonitor = optionsMonitor;
_connStr = _optionsMonitor.CurrentValue.Url;
@@ -31,7 +31,9 @@ namespace Yi.Framework.Model
{
if (!optionsBuilder.IsConfigured)
{
optionsBuilder.UseSqlite(_connStr);
//optionsBuilder.UseSqlite(_connStr);
var serverVersion = new MySqlServerVersion(new Version(8, 0, 21));
optionsBuilder.UseMySql(_connStr, serverVersion);
}
}

View File

@@ -1,218 +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("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

@@ -1,221 +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("20211017105828_yi-2")]
partial class yi2
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "5.0.11");
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_show")
.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

@@ -1,23 +0,0 @@
using Microsoft.EntityFrameworkCore.Migrations;
namespace Yi.Framework.Model.Migrations
{
public partial class yi2 : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<int>(
name: "is_show",
table: "menu",
type: "INTEGER",
nullable: true);
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "is_show",
table: "menu");
}
}
}

View File

@@ -1,87 +0,0 @@
using Microsoft.EntityFrameworkCore.Migrations;
namespace Yi.Framework.Model.Migrations
{
public partial class yi3 : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<string>(
name: "address",
table: "user",
type: "TEXT",
nullable: true);
migrationBuilder.AddColumn<int>(
name: "phone",
table: "user",
type: "INTEGER",
nullable: true);
migrationBuilder.AlterColumn<int>(
name: "sort",
table: "menu",
type: "INTEGER",
nullable: false,
defaultValue: 0,
oldClrType: typeof(int),
oldType: "INTEGER",
oldNullable: true);
migrationBuilder.AlterColumn<int>(
name: "is_top",
table: "menu",
type: "INTEGER",
nullable: false,
defaultValue: 0,
oldClrType: typeof(int),
oldType: "INTEGER",
oldNullable: true);
migrationBuilder.AlterColumn<int>(
name: "is_show",
table: "menu",
type: "INTEGER",
nullable: false,
defaultValue: 0,
oldClrType: typeof(int),
oldType: "INTEGER",
oldNullable: true);
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "address",
table: "user");
migrationBuilder.DropColumn(
name: "phone",
table: "user");
migrationBuilder.AlterColumn<int>(
name: "sort",
table: "menu",
type: "INTEGER",
nullable: true,
oldClrType: typeof(int),
oldType: "INTEGER");
migrationBuilder.AlterColumn<int>(
name: "is_top",
table: "menu",
type: "INTEGER",
nullable: true,
oldClrType: typeof(int),
oldType: "INTEGER");
migrationBuilder.AlterColumn<int>(
name: "is_show",
table: "menu",
type: "INTEGER",
nullable: true,
oldClrType: typeof(int),
oldType: "INTEGER");
}
}
}

View File

@@ -9,47 +9,48 @@ using Yi.Framework.Model;
namespace Yi.Framework.Model.Migrations
{
[DbContext(typeof(DataContext))]
[Migration("20211020073819_yi-3")]
partial class yi3
[Migration("20211022181627_yi-1")]
partial class yi1
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("Relational:MaxIdentifierLength", 64)
.HasAnnotation("ProductVersion", "5.0.11");
modelBuilder.Entity("Yi.Framework.Model.Models.menu", b =>
{
b.Property<int>("id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
.HasColumnType("int");
b.Property<string>("icon")
.HasColumnType("TEXT");
.HasColumnType("longtext");
b.Property<int>("is_delete")
.HasColumnType("INTEGER");
.HasColumnType("int");
b.Property<int>("is_show")
.HasColumnType("INTEGER");
.HasColumnType("int");
b.Property<int>("is_top")
.HasColumnType("INTEGER");
.HasColumnType("int");
b.Property<string>("menu_name")
.HasColumnType("TEXT");
.HasColumnType("longtext");
b.Property<int?>("menuid")
.HasColumnType("INTEGER");
.HasColumnType("int");
b.Property<int?>("mouldid")
.HasColumnType("INTEGER");
.HasColumnType("int");
b.Property<string>("router")
.HasColumnType("TEXT");
.HasColumnType("longtext");
b.Property<int>("sort")
.HasColumnType("INTEGER");
.HasColumnType("int");
b.HasKey("id");
@@ -64,16 +65,16 @@ namespace Yi.Framework.Model.Migrations
{
b.Property<int>("id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
.HasColumnType("int");
b.Property<int>("is_delete")
.HasColumnType("INTEGER");
.HasColumnType("int");
b.Property<string>("mould_name")
.HasColumnType("TEXT");
.HasColumnType("longtext");
b.Property<string>("url")
.HasColumnType("TEXT");
.HasColumnType("longtext");
b.HasKey("id");
@@ -84,16 +85,16 @@ namespace Yi.Framework.Model.Migrations
{
b.Property<int>("id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
.HasColumnType("int");
b.Property<string>("introduce")
.HasColumnType("TEXT");
.HasColumnType("longtext");
b.Property<int>("is_delete")
.HasColumnType("INTEGER");
.HasColumnType("int");
b.Property<string>("role_name")
.HasColumnType("TEXT");
.HasColumnType("longtext");
b.HasKey("id");
@@ -104,40 +105,40 @@ namespace Yi.Framework.Model.Migrations
{
b.Property<int>("id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
.HasColumnType("int");
b.Property<string>("address")
.HasColumnType("TEXT");
.HasColumnType("longtext");
b.Property<int?>("age")
.HasColumnType("INTEGER");
.HasColumnType("int");
b.Property<string>("email")
.HasColumnType("TEXT");
.HasColumnType("longtext");
b.Property<string>("icon")
.HasColumnType("TEXT");
.HasColumnType("longtext");
b.Property<string>("introduction")
.HasColumnType("TEXT");
.HasColumnType("longtext");
b.Property<string>("ip")
.HasColumnType("TEXT");
.HasColumnType("longtext");
b.Property<int>("is_delete")
.HasColumnType("INTEGER");
.HasColumnType("int");
b.Property<string>("nick")
.HasColumnType("TEXT");
.HasColumnType("longtext");
b.Property<string>("password")
.HasColumnType("TEXT");
.HasColumnType("longtext");
b.Property<int?>("phone")
.HasColumnType("INTEGER");
.HasColumnType("int");
b.Property<string>("username")
.HasColumnType("TEXT");
.HasColumnType("longtext");
b.HasKey("id");
@@ -147,10 +148,10 @@ namespace Yi.Framework.Model.Migrations
modelBuilder.Entity("menurole", b =>
{
b.Property<int>("menusid")
.HasColumnType("INTEGER");
.HasColumnType("int");
b.Property<int>("rolesid")
.HasColumnType("INTEGER");
.HasColumnType("int");
b.HasKey("menusid", "rolesid");
@@ -162,10 +163,10 @@ namespace Yi.Framework.Model.Migrations
modelBuilder.Entity("roleuser", b =>
{
b.Property<int>("rolesid")
.HasColumnType("INTEGER");
.HasColumnType("int");
b.Property<int>("usersid")
.HasColumnType("INTEGER");
.HasColumnType("int");
b.HasKey("rolesid", "usersid");

View File

@@ -1,4 +1,5 @@
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
namespace Yi.Framework.Model.Migrations
{
@@ -6,71 +7,95 @@ namespace Yi.Framework.Model.Migrations
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterDatabase()
.Annotation("MySql:CharSet", "utf8mb4");
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)
id = table.Column<int>(type: "int", nullable: false)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
mould_name = table.Column<string>(type: "longtext", nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
url = table.Column<string>(type: "longtext", nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
is_delete = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_mould", x => x.id);
});
})
.Annotation("MySql:CharSet", "utf8mb4");
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)
id = table.Column<int>(type: "int", nullable: false)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
role_name = table.Column<string>(type: "longtext", nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
introduce = table.Column<string>(type: "longtext", nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
is_delete = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_role", x => x.id);
});
})
.Annotation("MySql:CharSet", "utf8mb4");
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)
id = table.Column<int>(type: "int", nullable: false)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
username = table.Column<string>(type: "longtext", nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
password = table.Column<string>(type: "longtext", nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
icon = table.Column<string>(type: "longtext", nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
nick = table.Column<string>(type: "longtext", nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
email = table.Column<string>(type: "longtext", nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
ip = table.Column<string>(type: "longtext", nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
age = table.Column<int>(type: "int", nullable: true),
introduction = table.Column<string>(type: "longtext", nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
address = table.Column<string>(type: "longtext", nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
phone = table.Column<int>(type: "int", nullable: true),
is_delete = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_user", x => x.id);
});
})
.Annotation("MySql:CharSet", "utf8mb4");
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)
id = table.Column<int>(type: "int", nullable: false)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
icon = table.Column<string>(type: "longtext", nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
router = table.Column<string>(type: "longtext", nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
menu_name = table.Column<string>(type: "longtext", nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
mouldid = table.Column<int>(type: "int", nullable: true),
menuid = table.Column<int>(type: "int", nullable: true),
is_delete = table.Column<int>(type: "int", nullable: false),
is_top = table.Column<int>(type: "int", nullable: false),
sort = table.Column<int>(type: "int", nullable: false),
is_show = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
@@ -87,14 +112,15 @@ namespace Yi.Framework.Model.Migrations
principalTable: "mould",
principalColumn: "id",
onDelete: ReferentialAction.Restrict);
});
})
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateTable(
name: "roleuser",
columns: table => new
{
rolesid = table.Column<int>(type: "INTEGER", nullable: false),
usersid = table.Column<int>(type: "INTEGER", nullable: false)
rolesid = table.Column<int>(type: "int", nullable: false),
usersid = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
@@ -111,14 +137,15 @@ namespace Yi.Framework.Model.Migrations
principalTable: "user",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
});
})
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateTable(
name: "menurole",
columns: table => new
{
menusid = table.Column<int>(type: "INTEGER", nullable: false),
rolesid = table.Column<int>(type: "INTEGER", nullable: false)
menusid = table.Column<int>(type: "int", nullable: false),
rolesid = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
@@ -135,7 +162,8 @@ namespace Yi.Framework.Model.Migrations
principalTable: "role",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
});
})
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateIndex(
name: "IX_menu_menuid",

View File

@@ -14,40 +14,41 @@ namespace Yi.Framework.Model.Migrations
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("Relational:MaxIdentifierLength", 64)
.HasAnnotation("ProductVersion", "5.0.11");
modelBuilder.Entity("Yi.Framework.Model.Models.menu", b =>
{
b.Property<int>("id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
.HasColumnType("int");
b.Property<string>("icon")
.HasColumnType("TEXT");
.HasColumnType("longtext");
b.Property<int>("is_delete")
.HasColumnType("INTEGER");
.HasColumnType("int");
b.Property<int>("is_show")
.HasColumnType("INTEGER");
.HasColumnType("int");
b.Property<int>("is_top")
.HasColumnType("INTEGER");
.HasColumnType("int");
b.Property<string>("menu_name")
.HasColumnType("TEXT");
.HasColumnType("longtext");
b.Property<int?>("menuid")
.HasColumnType("INTEGER");
.HasColumnType("int");
b.Property<int?>("mouldid")
.HasColumnType("INTEGER");
.HasColumnType("int");
b.Property<string>("router")
.HasColumnType("TEXT");
.HasColumnType("longtext");
b.Property<int>("sort")
.HasColumnType("INTEGER");
.HasColumnType("int");
b.HasKey("id");
@@ -62,16 +63,16 @@ namespace Yi.Framework.Model.Migrations
{
b.Property<int>("id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
.HasColumnType("int");
b.Property<int>("is_delete")
.HasColumnType("INTEGER");
.HasColumnType("int");
b.Property<string>("mould_name")
.HasColumnType("TEXT");
.HasColumnType("longtext");
b.Property<string>("url")
.HasColumnType("TEXT");
.HasColumnType("longtext");
b.HasKey("id");
@@ -82,16 +83,16 @@ namespace Yi.Framework.Model.Migrations
{
b.Property<int>("id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
.HasColumnType("int");
b.Property<string>("introduce")
.HasColumnType("TEXT");
.HasColumnType("longtext");
b.Property<int>("is_delete")
.HasColumnType("INTEGER");
.HasColumnType("int");
b.Property<string>("role_name")
.HasColumnType("TEXT");
.HasColumnType("longtext");
b.HasKey("id");
@@ -102,40 +103,40 @@ namespace Yi.Framework.Model.Migrations
{
b.Property<int>("id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
.HasColumnType("int");
b.Property<string>("address")
.HasColumnType("TEXT");
.HasColumnType("longtext");
b.Property<int?>("age")
.HasColumnType("INTEGER");
.HasColumnType("int");
b.Property<string>("email")
.HasColumnType("TEXT");
.HasColumnType("longtext");
b.Property<string>("icon")
.HasColumnType("TEXT");
.HasColumnType("longtext");
b.Property<string>("introduction")
.HasColumnType("TEXT");
.HasColumnType("longtext");
b.Property<string>("ip")
.HasColumnType("TEXT");
.HasColumnType("longtext");
b.Property<int>("is_delete")
.HasColumnType("INTEGER");
.HasColumnType("int");
b.Property<string>("nick")
.HasColumnType("TEXT");
.HasColumnType("longtext");
b.Property<string>("password")
.HasColumnType("TEXT");
.HasColumnType("longtext");
b.Property<int?>("phone")
.HasColumnType("INTEGER");
.HasColumnType("int");
b.Property<string>("username")
.HasColumnType("TEXT");
.HasColumnType("longtext");
b.HasKey("id");
@@ -145,10 +146,10 @@ namespace Yi.Framework.Model.Migrations
modelBuilder.Entity("menurole", b =>
{
b.Property<int>("menusid")
.HasColumnType("INTEGER");
.HasColumnType("int");
b.Property<int>("rolesid")
.HasColumnType("INTEGER");
.HasColumnType("int");
b.HasKey("menusid", "rolesid");
@@ -160,10 +161,10 @@ namespace Yi.Framework.Model.Migrations
modelBuilder.Entity("roleuser", b =>
{
b.Property<int>("rolesid")
.HasColumnType("INTEGER");
.HasColumnType("int");
b.Property<int>("usersid")
.HasColumnType("INTEGER");
.HasColumnType("int");
b.HasKey("rolesid", "usersid");

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 MysqlExtension
{
public static IServiceCollection AddMysqlService(this IServiceCollection services)
{
services.Configure<MySqlConnOptions>(Appsettings.appConfiguration("MysqlConn"));
return services;
}
}
}

View File

@@ -12,106 +12,13 @@
</material-card>
</template>
<script>
import {handUrl} from '../util/getMould'
export default {
created() {
this.init();
},
methods: {
recursiveFun(menuList, menuStr) {
if (this.start) {
this.getUrlFun(menuList, menuStr);
}
},
getUrlFun(menuList, menuStr) {
for (var i = 0; i < menuList.length; i++) {
if (menuList[i].menu_name == menuStr) {
this.start = false;
this.axiosUrls= handUrl(menuList[i]);
} else {
if (menuList[i].children != undefined && this.start) {
this.recursiveFun(menuList[i].children, menuStr);
}
}
}
},
init() {
const resp = [
{
menu_name: "首页",
icon: "mdi-view-dashboard",
to: "/",
},
{
menu_name: "用户角色管理",
icon: "mdi-account",
to: "",
children: [
{
menu_name: "用户管理",
icon: "mdi-account",
to: "/admuser/",
children: [
{
menu_name: "",
icon: "mdi-account",
to: "/admrole/",
mould: {
mould_name: "get",
url: "/role/getrole",
},
},
],
},
{
menu_name: "角色管理",
icon: "mdi-account-tie",
to: "/admrole/",
children: [],
},
],
},
{
menu_name: "菜单接口管理",
icon: "mdi-clipboard-outline",
to: "",
children: [
{
menu_name: "菜单管理",
icon: "mdi-account",
to: "/admMenu/",
children: [],
},
{
menu_name: "接口管理",
icon: "mdi-account",
to: "/admMould/",
children: [],
},
{
menu_name: "角色菜单分配管理",
icon: "mdi-account",
to: "/admRoleMenu/",
children: [],
},
],
},
{
menu_name: "测试路由",
icon: "mdi-clipboard-outline",
to: "",
children: [
{
menu_name: "用户信息",
icon: "mdi-account",
to: "/userinfo/",
children: [],
},
],
},
];
this.recursiveFun(resp, "用户管理");
},
}
},
data: () => ({
start: true,
@@ -128,8 +35,8 @@ export default {
{ text: "操作", value: "actions", sortable: false },
],
defaultItem: {
role_name: "test",
introduce: "用于测试",
role_name: "",
introduce: "",
},
}),
};