新增注册流程

This commit is contained in:
南浔
2024-11-03 22:01:35 +08:00
36 changed files with 2001 additions and 143 deletions
+9
View File
@@ -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();
}
}
+21
View File
@@ -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);
}
}
}