新增注册流程
This commit is contained in:
@@ -20,6 +20,10 @@ namespace Apimanager_backend.Data
|
||||
public DbSet<Order> Orders { get; set; }
|
||||
//用户已订购套餐表
|
||||
public DbSet<UserPackage> UserPackages { get; set; }
|
||||
//用户角色表
|
||||
public DbSet<UserRole> UserRoles { get; set; }
|
||||
//日志表
|
||||
public DbSet<Log> Logs { get; set; }
|
||||
public ApiContext(DbContextOptions<ApiContext> options) : base(options) { }
|
||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||
{
|
||||
@@ -27,6 +31,11 @@ namespace Apimanager_backend.Data
|
||||
// 配置全局查询筛选器
|
||||
modelBuilder.Entity<User>().HasQueryFilter(u => !u.IsDelete);
|
||||
modelBuilder.Entity<Api>().HasQueryFilter(a => !a.IsDelete);
|
||||
//配置日志表
|
||||
modelBuilder.Entity<Log>().HasKey(x => x.Id);
|
||||
modelBuilder.Entity<Log>()
|
||||
.Property(x => x.Id)
|
||||
.ValueGeneratedOnAdd();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
using Apimanager_backend.Models;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
|
||||
namespace Apimanager_backend.Data
|
||||
{
|
||||
public class UserRoleConfig : IEntityTypeConfiguration<UserRole>
|
||||
{
|
||||
public void Configure(EntityTypeBuilder<UserRole> builder)
|
||||
{
|
||||
builder.HasKey(x => x.Id);
|
||||
//自增
|
||||
builder.Property(x => x.Id)
|
||||
.ValueGeneratedOnAdd();
|
||||
//外键
|
||||
builder.HasOne(x => x.User)
|
||||
.WithMany(u => u.Roles)
|
||||
.HasForeignKey(x => x.UserId);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user