模型类

This commit is contained in:
橙子
2021-10-11 21:50:50 +08:00
parent 543800d0e7
commit 2093d1c78d
38 changed files with 652 additions and 185 deletions

View File

@@ -1,8 +0,0 @@
using System;
namespace Yi.Framework.Model
{
public class Class1
{
}
}

View File

@@ -34,6 +34,7 @@ namespace Yi.Framework.Model
optionsBuilder.UseSqlite(_connStr);
}
}
public virtual DbSet<user> user { get; set; }
public DbSet<user> user { get; set; }
public DbSet<role> role { get; set; }
}
}

View File

@@ -0,0 +1,78 @@
// <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

@@ -0,0 +1,120 @@
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

@@ -1,4 +1,5 @@
// <auto-generated />
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
@@ -15,16 +16,54 @@ namespace Yi.Framework.Model.Migrations
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")
b.Property<int?>("age")
.HasColumnType("INTEGER");
b.Property<string>("name")
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");

View File

@@ -0,0 +1,18 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Yi.Framework.Model.Models
{
public class baseModel<T>
{
[Key]
[DatabaseGeneratedAttribute(DatabaseGeneratedOption.Identity)]
public T id { get; set; }
public int is_delete { get; set; }
}
}

View File

@@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Yi.Framework.Model.Models
{
public class loopModel:baseModel<int>
{
public int? is_top { get; set; }
public int? sort { get; set; }
}
}

View File

@@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Yi.Framework.Model.Models
{
public class menu :loopModel
{
public string icon { get; set; }
public string router { get; set; }
public string menu_name { get; set; }
public menu children { get; set; }
public mould mould { get; set; }
}
}

View File

@@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Yi.Framework.Model.Models
{
public class mould:baseModel<int>
{
public string mould_name { get; set; }
public string url { get; set; }
}
}

View File

@@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Yi.Framework.Model.Models
{
public class role:baseModel
{
public string role_name { get; set; }
public string introduce { get; set; }
public ICollection<menu> menus { get; set; }
}
}

View File

@@ -7,11 +7,18 @@ using System.Threading.Tasks;
namespace Yi.Framework.Model.Models
{
public class user
public class user:baseModel<int>
{
[Key]
public int id { get; set; }
public string name { get; set; }
public int age { get; set; }
public string username { get; set; }
public string password { get; set; }
public string icon { get; set; }
public string nick { get; set; }
public string email { get; set; }
public string ip { get; set; }
public int? age { get; set; }
public string introduction { get; set; }
public ICollection<role> roles { get; set; }
}
}