From 37b3e2049e1c05064f563ee032b945629ab8ce09 Mon Sep 17 00:00:00 2001 From: zpc Date: Thu, 10 Oct 2024 01:13:46 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E5=AE=9E=E4=BD=93=E7=B1=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../CloudGaming.Model.csproj | 4 + .../CodeTemplates/EFCore/DbContext.t4 | 42 +- .../CodeTemplates/EFCore/EntityType.t4 | 20 +- .../Db_User/CloudGamingUserContext.cs | 474 ++++++++++++++++++ .../DbSqlServer/Db_User/T_User.cs | 81 +++ .../DbSqlServer/Db_User/T_User_Currency.cs | 48 ++ .../Db_User/T_User_Currency_Log.cs | 78 +++ .../DbSqlServer/Db_User/T_User_Data.cs | 46 ++ .../DbSqlServer/Db_User/T_User_IntentOrder.cs | 76 +++ .../Db_User/T_User_MiniProgram_Account.cs | 48 ++ .../DbSqlServer/Db_User/T_User_Order.cs | 73 +++ .../DbSqlServer/Db_User/T_User_OrderItems.cs | 52 ++ .../Db_User/T_User_Phone_Account.cs | 61 +++ .../DbSqlServer/Db_User/T_User_Token.cs | 43 ++ .../DbSqlServer/efcore-gen.md | 6 + .../CloudGaming.Model/GlobalUsings.cs | 2 + 16 files changed, 1145 insertions(+), 9 deletions(-) create mode 100644 src/CloudGaming/CloudGaming.Model/DbSqlServer/Db_User/CloudGamingUserContext.cs create mode 100644 src/CloudGaming/CloudGaming.Model/DbSqlServer/Db_User/T_User.cs create mode 100644 src/CloudGaming/CloudGaming.Model/DbSqlServer/Db_User/T_User_Currency.cs create mode 100644 src/CloudGaming/CloudGaming.Model/DbSqlServer/Db_User/T_User_Currency_Log.cs create mode 100644 src/CloudGaming/CloudGaming.Model/DbSqlServer/Db_User/T_User_Data.cs create mode 100644 src/CloudGaming/CloudGaming.Model/DbSqlServer/Db_User/T_User_IntentOrder.cs create mode 100644 src/CloudGaming/CloudGaming.Model/DbSqlServer/Db_User/T_User_MiniProgram_Account.cs create mode 100644 src/CloudGaming/CloudGaming.Model/DbSqlServer/Db_User/T_User_Order.cs create mode 100644 src/CloudGaming/CloudGaming.Model/DbSqlServer/Db_User/T_User_OrderItems.cs create mode 100644 src/CloudGaming/CloudGaming.Model/DbSqlServer/Db_User/T_User_Phone_Account.cs create mode 100644 src/CloudGaming/CloudGaming.Model/DbSqlServer/Db_User/T_User_Token.cs create mode 100644 src/CloudGaming/CloudGaming.Model/DbSqlServer/efcore-gen.md create mode 100644 src/CloudGaming/CloudGaming.Model/GlobalUsings.cs diff --git a/src/CloudGaming/CloudGaming.Model/CloudGaming.Model.csproj b/src/CloudGaming/CloudGaming.Model/CloudGaming.Model.csproj index 7c5c965..6ae5293 100644 --- a/src/CloudGaming/CloudGaming.Model/CloudGaming.Model.csproj +++ b/src/CloudGaming/CloudGaming.Model/CloudGaming.Model.csproj @@ -17,4 +17,8 @@ + + + + diff --git a/src/CloudGaming/CloudGaming.Model/CodeTemplates/EFCore/DbContext.t4 b/src/CloudGaming/CloudGaming.Model/CodeTemplates/EFCore/DbContext.t4 index 1351902..765dd8c 100644 --- a/src/CloudGaming/CloudGaming.Model/CodeTemplates/EFCore/DbContext.t4 +++ b/src/CloudGaming/CloudGaming.Model/CodeTemplates/EFCore/DbContext.t4 @@ -46,13 +46,16 @@ namespace <#= NamespaceHint #>; <# } #> -public partial class <#= Options.ContextName #> : DbContext +/// +/// 云游戏实体类 +/// +public partial class <#= Options.ContextName #> : MultiTenantDbContext//DbContext { <# if (!Options.SuppressOnConfiguring) { #> - public <#= Options.ContextName #>() + public <#= Options.ContextName #>() : base(null) { } @@ -60,14 +63,37 @@ public partial class <#= Options.ContextName #> : DbContext } #> public <#= Options.ContextName #>(DbContextOptions<<#= Options.ContextName #>> options) - : base(options) + : base(null, options) { } + /// + /// + /// + /// + public <#= Options.ContextName #>(ITenantInfo tenantInfo) : base(tenantInfo) + { + + } + + + /// + /// + /// + /// + /// + public <#= Options.ContextName #>(ITenantInfo tenantInfo, DbContextOptions<<#= Options.ContextName #>> options) : base(tenantInfo, options) + { + } + + <# foreach (var entityType in Model.GetEntityTypes().Where(e => !e.IsSimpleManyToManyJoinEntityType())) { #> + /// + /// <#=entityType.GetComment()??"" #> + /// public virtual DbSet<<#= entityType.Name #>> <#= entityType.GetDbSetName() #> { get; set; } <# @@ -81,7 +107,6 @@ public partial class <#= Options.ContextName #> : DbContext if (!Options.SuppressConnectionStringWarning) { #> -#warning To protect potentially sensitive information in your connection string, you should move it out of source code. You can avoid scaffolding the connection string by using the Name= syntax to read it from configuration - see https://go.microsoft.com/fwlink/?linkid=2131148. For more guidance on storing connection strings, see https://go.microsoft.com/fwlink/?LinkId=723263. <# } @@ -296,7 +321,8 @@ public partial class <#= Options.ContextName #> : DbContext usings.AddRange(propertyFluentApiCalls.GetRequiredUsings()); #> - j.IndexerProperty<<#= code.Reference(property.ClrType) #>>(<#= code.Literal(property.Name) #>)<#= code.Fragment(propertyFluentApiCalls, indent: 7) #>; + j.IndexerProperty<<#= code.Reference(property.ClrType) #>>(<#= code.Literal(property.Name) #>)<#= code.Fragment(propertyFluentApiCalls, indent: 7) #>; + <# } #> @@ -304,7 +330,13 @@ public partial class <#= Options.ContextName #> : DbContext <# anyEntityTypeConfiguration = true; } + #> + //添加全局筛选器 + if (this.TenantInfo != null) + { + entity.HasQueryFilter(it => it.TenantId == this.TenantInfo.TenantId); + } }); <# // If any signicant code was generated, append it to the main environment diff --git a/src/CloudGaming/CloudGaming.Model/CodeTemplates/EFCore/EntityType.t4 b/src/CloudGaming/CloudGaming.Model/CodeTemplates/EFCore/EntityType.t4 index 6c6c708..2511a3e 100644 --- a/src/CloudGaming/CloudGaming.Model/CodeTemplates/EFCore/EntityType.t4 +++ b/src/CloudGaming/CloudGaming.Model/CodeTemplates/EFCore/EntityType.t4 @@ -26,8 +26,8 @@ var usings = new List { - "System", - "System.Collections.Generic" + // "System", + //"System.Collections.Generic", }; if (Options.UseDataAnnotations) @@ -64,8 +64,10 @@ namespace <#= NamespaceHint #>; } } #> -public partial class <#= EntityType.Name #> +public partial class <#= EntityType.Name #>: MultiTenantEntity { + public <#= EntityType.Name #>() { } + <# var firstProperty = true; foreach (var property in EntityType.GetProperties().OrderBy(p => p.GetColumnOrder() ?? -1)) @@ -75,6 +77,15 @@ public partial class <#= EntityType.Name #> WriteLine(""); } + if(property.Name=="TenantId"){ + #> + /// + /// 所属租户 + /// + public override Guid TenantId { get; set; } + <# + continue; + } if (!string.IsNullOrEmpty(property.GetComment())) { #> @@ -100,8 +111,9 @@ public partial class <#= EntityType.Name #> var needsNullable = Options.UseNullableReferenceTypes && property.IsNullable && !property.ClrType.IsValueType; var needsInitializer = Options.UseNullableReferenceTypes && !property.IsNullable && !property.ClrType.IsValueType; + #> - public <#= code.Reference(property.ClrType) #><#= needsNullable ? "?" : "" #> <#= property.Name #> { get; set; }<#= needsInitializer ? " = null!;" : "" #> + public virtual <#= code.Reference(property.ClrType) #><#= needsNullable ? "?" : "" #> <#= property.Name #> { get; set; }<#= needsInitializer ? " = null!;" : "" #> <# firstProperty = false; } diff --git a/src/CloudGaming/CloudGaming.Model/DbSqlServer/Db_User/CloudGamingUserContext.cs b/src/CloudGaming/CloudGaming.Model/DbSqlServer/Db_User/CloudGamingUserContext.cs new file mode 100644 index 0000000..cd73324 --- /dev/null +++ b/src/CloudGaming/CloudGaming.Model/DbSqlServer/Db_User/CloudGamingUserContext.cs @@ -0,0 +1,474 @@ +using System; +using System.Collections.Generic; +using Microsoft.EntityFrameworkCore; + +namespace CloudGaming.Model.DbSqlServer.Db_User; + +/// +/// 云游戏实体类 +/// +public partial class CloudGamingUserContext : MultiTenantDbContext//DbContext +{ + public CloudGamingUserContext() : base(null) + { + } + + public CloudGamingUserContext(DbContextOptions options) + : base(null, options) + { + } + + /// + /// + /// + /// + public CloudGamingUserContext(ITenantInfo tenantInfo) : base(tenantInfo) + { + + } + + + /// + /// + /// + /// + /// + public CloudGamingUserContext(ITenantInfo tenantInfo, DbContextOptions options) : base(tenantInfo, options) + { + } + + + /// + /// 用户表 + /// + public virtual DbSet T_User { get; set; } + + /// + /// 用户货币表 + /// + public virtual DbSet T_User_Currency { get; set; } + + /// + /// 用户金额记录表 + /// + public virtual DbSet T_User_Currency_Log { get; set; } + + /// + /// 用户扩展表 + /// + public virtual DbSet T_User_Data { get; set; } + + /// + /// 意向订单表 + /// + public virtual DbSet T_User_IntentOrder { get; set; } + + /// + /// 小程序登录表 + /// + public virtual DbSet T_User_MiniProgram_Account { get; set; } + + /// + /// 订单完成表 + /// + public virtual DbSet T_User_Order { get; set; } + + /// + /// 订单详情表 + /// + public virtual DbSet T_User_OrderItems { get; set; } + + /// + /// 手机号登录表 + /// + public virtual DbSet T_User_Phone_Account { get; set; } + + /// + /// 用户单点登录表 + /// + public virtual DbSet T_User_Token { get; set; } + + protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) + => optionsBuilder.UseSqlServer("Server=192.168.1.17;Database=CloudGamingUser;User Id=sa;Password=Dbt@com@123;TrustServerCertificate=true;"); + + protected override void OnModelCreating(ModelBuilder modelBuilder) + { + modelBuilder.Entity(entity => + { + entity.HasKey(e => e.Id).HasName("PK__T_User__3214EC073733108B"); + + entity.ToTable(tb => tb.HasComment("用户表")); + + entity.Property(e => e.Id).HasComment("用户Id"); + entity.Property(e => e.CreatedAt) + .HasComment("创建时间") + .HasColumnType("datetime"); + entity.Property(e => e.IDCard) + .HasMaxLength(64) + .HasComment("身份证号"); + entity.Property(e => e.Ip) + .HasMaxLength(100) + .HasComment("Ip地址") + .UseCollation("Chinese_PRC_CI_AS"); + entity.Property(e => e.IsTest).HasComment("是否是测试账号"); + entity.Property(e => e.LastLoginAt) + .HasComment("最后一次登录时间") + .HasColumnType("datetime"); + entity.Property(e => e.LastLoginType).HasComment("最后一次登录方式,1手机号,2默认登录"); + entity.Property(e => e.NickName) + .HasMaxLength(100) + .HasComment("用户昵称") + .UseCollation("Chinese_PRC_CI_AS"); + entity.Property(e => e.RegisterType).HasComment("首次注册方式"); + entity.Property(e => e.State).HasComment("0正常,1注销"); + entity.Property(e => e.TenantId).HasComment("租户Id"); + entity.Property(e => e.UpdatedAt) + .HasComment("修改时间") + .HasColumnType("datetime"); + entity.Property(e => e.UserIconUrl) + .HasMaxLength(300) + .HasComment("用户头像") + .UseCollation("Chinese_PRC_CI_AS"); + entity.Property(e => e.UserName) + .HasMaxLength(100) + .HasComment("姓名") + .UseCollation("Chinese_PRC_CI_AS"); + //添加全局筛选器 + if (this.TenantInfo != null) + { + entity.HasQueryFilter(it => it.TenantId == this.TenantInfo.TenantId); + } + }); + + modelBuilder.Entity(entity => + { + entity.HasKey(e => e.Id).HasName("PK__T_User_C__3214EC0728E86D78"); + + entity.ToTable(tb => tb.HasComment("用户货币表")); + + entity.Property(e => e.CreateAt) + .HasComment("创建时间") + .HasColumnType("datetime"); + entity.Property(e => e.CurrencyMoney) + .HasComment("货币余额") + .HasColumnType("decimal(10, 2)"); + entity.Property(e => e.CurrencyName) + .HasMaxLength(20) + .HasComment("货币名称") + .UseCollation("Chinese_PRC_CI_AS"); + entity.Property(e => e.CurrencyType).HasComment("货币类型 付费币、免费币"); + entity.Property(e => e.TenantId).HasComment("租户Id"); + entity.Property(e => e.UpdateAt) + .HasComment("修改时间") + .HasColumnType("datetime"); + entity.Property(e => e.UserId).HasComment("用户Id"); + //添加全局筛选器 + if (this.TenantInfo != null) + { + entity.HasQueryFilter(it => it.TenantId == this.TenantInfo.TenantId); + } + }); + + modelBuilder.Entity(entity => + { + entity.HasKey(e => e.Id).HasName("PK__T_User_C__3214EC07DBD26048"); + + entity.ToTable(tb => tb.HasComment("用户金额记录表")); + + entity.Property(e => e.Consume) + .HasComment("金额") + .HasColumnType("decimal(10, 2)"); + entity.Property(e => e.ConsumeType).HasComment("消耗类型,0消耗,1增加"); + entity.Property(e => e.CreateAt) + .HasComment("创建时间") + .HasColumnType("datetime"); + entity.Property(e => e.CurrencyType).HasComment("金额类型"); + entity.Property(e => e.ExpiresAt) + .HasComment("消耗的结束时间") + .HasColumnType("datetime"); + entity.Property(e => e.GameId) + .HasMaxLength(200) + .HasComment("消耗的游戏Id"); + entity.Property(e => e.IsShow).HasComment("是否显示给用户"); + entity.Property(e => e.OrderId) + .HasMaxLength(64) + .HasComment("订单号") + .UseCollation("Chinese_PRC_CI_AS"); + entity.Property(e => e.Remarks) + .HasMaxLength(200) + .HasComment("备注") + .UseCollation("Chinese_PRC_CI_AS"); + entity.Property(e => e.TenantId).HasComment("租户"); + entity.Property(e => e.Title) + .HasMaxLength(200) + .HasComment("标题") + .UseCollation("Chinese_PRC_CI_AS"); + entity.Property(e => e.UpdateAt) + .HasComment("修改时间") + .HasColumnType("datetime"); + entity.Property(e => e.UserId).HasComment("用户"); + //添加全局筛选器 + if (this.TenantInfo != null) + { + entity.HasQueryFilter(it => it.TenantId == this.TenantInfo.TenantId); + } + }); + + modelBuilder.Entity(entity => + { + entity.HasKey(e => e.Id).HasName("PK__T_UsersD__3214EC0738D57E8A"); + + entity.ToTable(tb => tb.HasComment("用户扩展表")); + + entity.HasIndex(e => new { e.TenantId, e.UserId }, "UserData_index"); + + entity.Property(e => e.Id).HasComment("主键"); + entity.Property(e => e.CreateAt) + .HasComment("创建时间") + .HasColumnType("datetime"); + entity.Property(e => e.Email) + .HasMaxLength(255) + .HasComment("邮箱"); + entity.Property(e => e.PhoneNum) + .HasMaxLength(20) + .HasComment("手机号"); + entity.Property(e => e.TenantId).HasComment("多租户"); + entity.Property(e => e.UpdateAt) + .HasComment("修改时间") + .HasColumnType("datetime"); + entity.Property(e => e.UserId).HasComment("用户Id"); + //添加全局筛选器 + if (this.TenantInfo != null) + { + entity.HasQueryFilter(it => it.TenantId == this.TenantInfo.TenantId); + } + }); + + modelBuilder.Entity(entity => + { + entity.HasKey(e => e.Id).HasName("PK__T_User_I__3214EC07D27A8CE9"); + + entity.ToTable(tb => tb.HasComment("意向订单表")); + + entity.Property(e => e.Id).HasComment("主键"); + entity.Property(e => e.CreatedAt) + .HasComment("创建时间") + .HasColumnType("datetime"); + entity.Property(e => e.IntentAt) + .HasComment("订单创建时间") + .HasColumnType("datetime"); + entity.Property(e => e.Method) + .HasMaxLength(10) + .HasComment("支付方式") + .UseCollation("Chinese_PRC_CI_AS"); + entity.Property(e => e.Notes) + .HasMaxLength(200) + .HasComment("备注") + .UseCollation("Chinese_PRC_CI_AS"); + entity.Property(e => e.OrderId) + .HasMaxLength(64) + .HasComment("订单Id") + .UseCollation("Chinese_PRC_CI_AS"); + entity.Property(e => e.Price) + .HasComment("价格") + .HasColumnType("money"); + entity.Property(e => e.ProductId) + .HasMaxLength(50) + .HasComment("产品id") + .UseCollation("Chinese_PRC_CI_AS"); + entity.Property(e => e.Quantity).HasComment("数量"); + entity.Property(e => e.Status).HasComment("状态"); + entity.Property(e => e.TenantId).HasComment("租户"); + entity.Property(e => e.UpdatedAt) + .HasComment("修改时间") + .HasColumnType("datetime"); + entity.Property(e => e.UserId).HasComment("用户Id"); + //添加全局筛选器 + if (this.TenantInfo != null) + { + entity.HasQueryFilter(it => it.TenantId == this.TenantInfo.TenantId); + } + }); + + modelBuilder.Entity(entity => + { + entity.HasKey(e => e.Id).HasName("PK__T_User_M__3214EC073889A8B9"); + + entity.ToTable(tb => tb.HasComment("小程序登录表")); + + entity.Property(e => e.Id).HasComment("主键"); + entity.Property(e => e.CreateAt) + .HasComment("创建时间") + .HasColumnType("datetime"); + entity.Property(e => e.OpenId) + .HasMaxLength(200) + .HasComment("用户唯一标识") + .UseCollation("Chinese_PRC_CI_AS"); + entity.Property(e => e.SessionKey) + .HasMaxLength(200) + .UseCollation("Chinese_PRC_CI_AS"); + entity.Property(e => e.TenantId).HasComment("租户"); + entity.Property(e => e.Unionid) + .HasMaxLength(200) + .HasComment("用户在开放平台的唯一标识符,若当前小程序已绑定到微信开放平台账号下会返回,详见") + .UseCollation("Chinese_PRC_CI_AS"); + entity.Property(e => e.UpdateAt) + .HasComment("修改时间") + .HasColumnType("datetime"); + entity.Property(e => e.UserId).HasComment("用户Id"); + //添加全局筛选器 + if (this.TenantInfo != null) + { + entity.HasQueryFilter(it => it.TenantId == this.TenantInfo.TenantId); + } + }); + + modelBuilder.Entity(entity => + { + entity.HasKey(e => e.Id).HasName("PK__T_Order__3214EC07C8DD7EE1"); + + entity.ToTable(tb => tb.HasComment("订单完成表")); + + entity.Property(e => e.CreatedAt) + .HasComment("创建时间") + .HasColumnType("datetime"); + entity.Property(e => e.OrderDate) + .HasComment("订单创建时间") + .HasColumnType("datetime"); + entity.Property(e => e.OrderId) + .HasMaxLength(64) + .HasComment("订单编号") + .UseCollation("Chinese_PRC_CI_AS"); + entity.Property(e => e.PaymentDate) + .HasComment("订单支付时间") + .HasColumnType("datetime"); + entity.Property(e => e.PaymentDay).HasComment("订单创建天"); + entity.Property(e => e.PaymentMethod) + .HasMaxLength(10) + .HasComment("订单支付方式") + .UseCollation("Chinese_PRC_CI_AS"); + entity.Property(e => e.ProductId) + .HasMaxLength(100) + .HasComment("购买的产品Id") + .UseCollation("Chinese_PRC_CI_AS"); + entity.Property(e => e.Status).HasComment("订单状态"); + entity.Property(e => e.TenantId).HasComment("租户"); + entity.Property(e => e.TotalPrice) + .HasComment("价格") + .HasColumnType("money"); + entity.Property(e => e.UpdatedAt) + .HasComment("修改时间") + .HasColumnType("datetime"); + entity.Property(e => e.UserId).HasComment("用户Id"); + //添加全局筛选器 + if (this.TenantInfo != null) + { + entity.HasQueryFilter(it => it.TenantId == this.TenantInfo.TenantId); + } + }); + + modelBuilder.Entity(entity => + { + entity.HasKey(e => e.Id).HasName("PK__T_OrderI__3214EC077E53EC22"); + + entity.ToTable(tb => tb.HasComment("订单详情表")); + + entity.Property(e => e.OrderId) + .HasMaxLength(64) + .HasComment("订单id") + .UseCollation("Chinese_PRC_CI_AS"); + entity.Property(e => e.PayUrl) + .HasComment("支付地址") + .UseCollation("Chinese_PRC_CI_AS"); + entity.Property(e => e.PaymentInfo) + .HasComment("支付信息") + .UseCollation("Chinese_PRC_CI_AS"); + entity.Property(e => e.Product).HasComment("产品id、主键"); + entity.Property(e => e.ProductId) + .HasMaxLength(100) + .HasComment("产品id") + .UseCollation("Chinese_PRC_CI_AS"); + entity.Property(e => e.RewardInfo) + .HasComment("发放奖励信息") + .UseCollation("Chinese_PRC_CI_AS"); + entity.Property(e => e.RewardTips) + .HasComment("发放奖励提示") + .UseCollation("Chinese_PRC_CI_AS"); + entity.Property(e => e.TenantId).HasComment("租户"); + //添加全局筛选器 + if (this.TenantInfo != null) + { + entity.HasQueryFilter(it => it.TenantId == this.TenantInfo.TenantId); + } + }); + + modelBuilder.Entity(entity => + { + entity.HasKey(e => e.Id).HasName("PK__T_User_P__3214EC07987BDDB2"); + + entity.ToTable(tb => tb.HasComment("手机号登录表")); + + entity.Property(e => e.Id).HasComment("主键"); + entity.Property(e => e.CreatedAt) + .HasComment("修改时间") + .HasColumnType("datetime"); + entity.Property(e => e.IsLogout).HasComment("是否注销"); + entity.Property(e => e.LastLoginAt) + .HasComment("最后一次登录时间") + .HasColumnType("datetime"); + entity.Property(e => e.NikeName) + .HasMaxLength(100) + .HasComment("用户昵称") + .UseCollation("Chinese_PRC_CI_AS"); + entity.Property(e => e.PhoneNum) + .HasMaxLength(50) + .IsUnicode(false) + .HasComment("手机号") + .UseCollation("Chinese_PRC_CI_AS"); + entity.Property(e => e.TenantId).HasComment("租户Id"); + entity.Property(e => e.UpdatedAt) + .HasComment("创建时间") + .HasColumnType("datetime"); + entity.Property(e => e.UserId).HasComment("用户Id"); + entity.Property(e => e.VerificationCode) + .HasMaxLength(10) + .IsUnicode(false) + .HasComment("验证码") + .UseCollation("Chinese_PRC_CI_AS"); + //添加全局筛选器 + if (this.TenantInfo != null) + { + entity.HasQueryFilter(it => it.TenantId == this.TenantInfo.TenantId); + } + }); + + modelBuilder.Entity(entity => + { + entity.HasKey(e => e.Id).HasName("PK__T_User_T__3214EC072DF12976"); + + entity.ToTable(tb => tb.HasComment("用户单点登录表")); + + entity.Property(e => e.CreateAt) + .HasComment("创建时间") + .HasColumnType("datetime"); + entity.Property(e => e.ExpiresAt) + .HasComment("过期时间") + .HasColumnType("datetime"); + entity.Property(e => e.TenantId).HasComment("租户"); + entity.Property(e => e.Token).HasComment("登录token"); + entity.Property(e => e.UpdateAt) + .HasComment("修改时间") + .HasColumnType("datetime"); + entity.Property(e => e.UserId).HasComment("用户Id"); + //添加全局筛选器 + if (this.TenantInfo != null) + { + entity.HasQueryFilter(it => it.TenantId == this.TenantInfo.TenantId); + } + }); + + OnModelCreatingPartial(modelBuilder); + } + + partial void OnModelCreatingPartial(ModelBuilder modelBuilder); +} diff --git a/src/CloudGaming/CloudGaming.Model/DbSqlServer/Db_User/T_User.cs b/src/CloudGaming/CloudGaming.Model/DbSqlServer/Db_User/T_User.cs new file mode 100644 index 0000000..c1295b7 --- /dev/null +++ b/src/CloudGaming/CloudGaming.Model/DbSqlServer/Db_User/T_User.cs @@ -0,0 +1,81 @@ +using System; + +namespace CloudGaming.Model.DbSqlServer.Db_User; + +/// +/// 用户表 +/// +public partial class T_User: MultiTenantEntity +{ + public T_User() { } + + /// + /// 用户Id + /// + public virtual int Id { get; set; } + + /// + /// 所属租户 + /// + public override Guid TenantId { get; set; } + + /// + /// 用户昵称 + /// + public virtual string NickName { get; set; } = null!; + + /// + /// 身份证号 + /// + public virtual string? IDCard { get; set; } + + /// + /// 姓名 + /// + public virtual string? UserName { get; set; } + + /// + /// 创建时间 + /// + public virtual DateTime CreatedAt { get; set; } + + /// + /// 首次注册方式 + /// + public virtual int RegisterType { get; set; } + + /// + /// 最后一次登录方式,1手机号,2默认登录 + /// + public virtual int LastLoginType { get; set; } + + /// + /// 最后一次登录时间 + /// + public virtual DateTime LastLoginAt { get; set; } + + /// + /// 修改时间 + /// + public virtual DateTime UpdatedAt { get; set; } + + /// + /// Ip地址 + /// + public virtual string? Ip { get; set; } + + /// + /// 0正常,1注销 + /// + public virtual int State { get; set; } + + /// + /// 用户头像 + /// + public virtual string? UserIconUrl { get; set; } + + /// + /// 是否是测试账号 + /// + public virtual bool? IsTest { get; set; } +} diff --git a/src/CloudGaming/CloudGaming.Model/DbSqlServer/Db_User/T_User_Currency.cs b/src/CloudGaming/CloudGaming.Model/DbSqlServer/Db_User/T_User_Currency.cs new file mode 100644 index 0000000..01fbd77 --- /dev/null +++ b/src/CloudGaming/CloudGaming.Model/DbSqlServer/Db_User/T_User_Currency.cs @@ -0,0 +1,48 @@ +using System; + +namespace CloudGaming.Model.DbSqlServer.Db_User; + +/// +/// 用户货币表 +/// +public partial class T_User_Currency: MultiTenantEntity +{ + public T_User_Currency() { } + + public virtual int Id { get; set; } + + /// + /// 货币类型 付费币、免费币 + /// + public virtual int CurrencyType { get; set; } + + /// + /// 货币名称 + /// + public virtual string CurrencyName { get; set; } = null!; + + /// + /// 货币余额 + /// + public virtual decimal CurrencyMoney { get; set; } + + /// + /// 修改时间 + /// + public virtual DateTime UpdateAt { get; set; } + + /// + /// 创建时间 + /// + public virtual DateTime CreateAt { get; set; } + + /// + /// 用户Id + /// + public virtual int UserId { get; set; } + + /// + /// 所属租户 + /// + public override Guid TenantId { get; set; } + } diff --git a/src/CloudGaming/CloudGaming.Model/DbSqlServer/Db_User/T_User_Currency_Log.cs b/src/CloudGaming/CloudGaming.Model/DbSqlServer/Db_User/T_User_Currency_Log.cs new file mode 100644 index 0000000..69cb102 --- /dev/null +++ b/src/CloudGaming/CloudGaming.Model/DbSqlServer/Db_User/T_User_Currency_Log.cs @@ -0,0 +1,78 @@ +using System; + +namespace CloudGaming.Model.DbSqlServer.Db_User; + +/// +/// 用户金额记录表 +/// +public partial class T_User_Currency_Log: MultiTenantEntity +{ + public T_User_Currency_Log() { } + + public virtual int Id { get; set; } + + /// + /// 所属租户 + /// + public override Guid TenantId { get; set; } + + /// + /// 用户 + /// + public virtual int UserId { get; set; } + + /// + /// 标题 + /// + public virtual string? Title { get; set; } + + /// + /// 金额类型 + /// + public virtual int CurrencyType { get; set; } + + /// + /// 金额 + /// + public virtual decimal Consume { get; set; } + + /// + /// 消耗类型,0消耗,1增加 + /// + public virtual int ConsumeType { get; set; } + + /// + /// 备注 + /// + public virtual string? Remarks { get; set; } + + /// + /// 创建时间 + /// + public virtual DateTime CreateAt { get; set; } + + /// + /// 修改时间 + /// + public virtual DateTime UpdateAt { get; set; } + + /// + /// 订单号 + /// + public virtual string? OrderId { get; set; } + + /// + /// 是否显示给用户 + /// + public virtual bool IsShow { get; set; } + + /// + /// 消耗的结束时间 + /// + public virtual DateTime? ExpiresAt { get; set; } + + /// + /// 消耗的游戏Id + /// + public virtual string? GameId { get; set; } +} diff --git a/src/CloudGaming/CloudGaming.Model/DbSqlServer/Db_User/T_User_Data.cs b/src/CloudGaming/CloudGaming.Model/DbSqlServer/Db_User/T_User_Data.cs new file mode 100644 index 0000000..d3a3d2b --- /dev/null +++ b/src/CloudGaming/CloudGaming.Model/DbSqlServer/Db_User/T_User_Data.cs @@ -0,0 +1,46 @@ +using System; + +namespace CloudGaming.Model.DbSqlServer.Db_User; + +/// +/// 用户扩展表 +/// +public partial class T_User_Data: MultiTenantEntity +{ + public T_User_Data() { } + + /// + /// 主键 + /// + public virtual int Id { get; set; } + + /// + /// 所属租户 + /// + public override Guid TenantId { get; set; } + + /// + /// 用户Id + /// + public virtual int UserId { get; set; } + + /// + /// 手机号 + /// + public virtual string? PhoneNum { get; set; } + + /// + /// 邮箱 + /// + public virtual string? Email { get; set; } + + /// + /// 创建时间 + /// + public virtual DateTime CreateAt { get; set; } + + /// + /// 修改时间 + /// + public virtual DateTime UpdateAt { get; set; } +} diff --git a/src/CloudGaming/CloudGaming.Model/DbSqlServer/Db_User/T_User_IntentOrder.cs b/src/CloudGaming/CloudGaming.Model/DbSqlServer/Db_User/T_User_IntentOrder.cs new file mode 100644 index 0000000..5b1ff5d --- /dev/null +++ b/src/CloudGaming/CloudGaming.Model/DbSqlServer/Db_User/T_User_IntentOrder.cs @@ -0,0 +1,76 @@ +using System; + +namespace CloudGaming.Model.DbSqlServer.Db_User; + +/// +/// 意向订单表 +/// +public partial class T_User_IntentOrder: MultiTenantEntity +{ + public T_User_IntentOrder() { } + + /// + /// 主键 + /// + public virtual int Id { get; set; } + + /// + /// 用户Id + /// + public virtual int UserId { get; set; } + + /// + /// 产品id + /// + public virtual string ProductId { get; set; } = null!; + + /// + /// 支付方式 + /// + public virtual string Method { get; set; } = null!; + + /// + /// 价格 + /// + public virtual decimal Price { get; set; } + + /// + /// 数量 + /// + public virtual int Quantity { get; set; } + + /// + /// 状态 + /// + public virtual int Status { get; set; } + + /// + /// 备注 + /// + public virtual string? Notes { get; set; } + + /// + /// 订单创建时间 + /// + public virtual DateTime IntentAt { get; set; } + + /// + /// 创建时间 + /// + public virtual DateTime CreatedAt { get; set; } + + /// + /// 修改时间 + /// + public virtual DateTime UpdatedAt { get; set; } + + /// + /// 所属租户 + /// + public override Guid TenantId { get; set; } + + /// + /// 订单Id + /// + public virtual string OrderId { get; set; } = null!; +} diff --git a/src/CloudGaming/CloudGaming.Model/DbSqlServer/Db_User/T_User_MiniProgram_Account.cs b/src/CloudGaming/CloudGaming.Model/DbSqlServer/Db_User/T_User_MiniProgram_Account.cs new file mode 100644 index 0000000..11490ef --- /dev/null +++ b/src/CloudGaming/CloudGaming.Model/DbSqlServer/Db_User/T_User_MiniProgram_Account.cs @@ -0,0 +1,48 @@ +using System; + +namespace CloudGaming.Model.DbSqlServer.Db_User; + +/// +/// 小程序登录表 +/// +public partial class T_User_MiniProgram_Account: MultiTenantEntity +{ + public T_User_MiniProgram_Account() { } + + /// + /// 主键 + /// + public virtual int Id { get; set; } + + /// + /// 所属租户 + /// + public override Guid TenantId { get; set; } + + /// + /// 用户Id + /// + public virtual int UserId { get; set; } + + /// + /// 用户唯一标识 + /// + public virtual string OpenId { get; set; } = null!; + + /// + /// 用户在开放平台的唯一标识符,若当前小程序已绑定到微信开放平台账号下会返回,详见 + /// + public virtual string? Unionid { get; set; } + + public virtual string? SessionKey { get; set; } + + /// + /// 创建时间 + /// + public virtual DateTime CreateAt { get; set; } + + /// + /// 修改时间 + /// + public virtual DateTime UpdateAt { get; set; } +} diff --git a/src/CloudGaming/CloudGaming.Model/DbSqlServer/Db_User/T_User_Order.cs b/src/CloudGaming/CloudGaming.Model/DbSqlServer/Db_User/T_User_Order.cs new file mode 100644 index 0000000..daace75 --- /dev/null +++ b/src/CloudGaming/CloudGaming.Model/DbSqlServer/Db_User/T_User_Order.cs @@ -0,0 +1,73 @@ +using System; + +namespace CloudGaming.Model.DbSqlServer.Db_User; + +/// +/// 订单完成表 +/// +public partial class T_User_Order: MultiTenantEntity +{ + public T_User_Order() { } + + public virtual int Id { get; set; } + + /// + /// 所属租户 + /// + public override Guid TenantId { get; set; } + + /// + /// 订单编号 + /// + public virtual string OrderId { get; set; } = null!; + + /// + /// 用户Id + /// + public virtual int UserId { get; set; } + + /// + /// 订单创建时间 + /// + public virtual DateTime OrderDate { get; set; } + + /// + /// 订单支付时间 + /// + public virtual DateTime PaymentDate { get; set; } + + /// + /// 订单支付方式 + /// + public virtual string PaymentMethod { get; set; } = null!; + + /// + /// 购买的产品Id + /// + public virtual string ProductId { get; set; } = null!; + + /// + /// 价格 + /// + public virtual decimal TotalPrice { get; set; } + + /// + /// 订单状态 + /// + public virtual int Status { get; set; } + + /// + /// 创建时间 + /// + public virtual DateTime CreatedAt { get; set; } + + /// + /// 修改时间 + /// + public virtual DateTime UpdatedAt { get; set; } + + /// + /// 订单创建天 + /// + public virtual DateOnly PaymentDay { get; set; } +} diff --git a/src/CloudGaming/CloudGaming.Model/DbSqlServer/Db_User/T_User_OrderItems.cs b/src/CloudGaming/CloudGaming.Model/DbSqlServer/Db_User/T_User_OrderItems.cs new file mode 100644 index 0000000..b5d16c2 --- /dev/null +++ b/src/CloudGaming/CloudGaming.Model/DbSqlServer/Db_User/T_User_OrderItems.cs @@ -0,0 +1,52 @@ + +namespace CloudGaming.Model.DbSqlServer.Db_User; + +/// +/// 订单详情表 +/// +public partial class T_User_OrderItems: MultiTenantEntity +{ + public T_User_OrderItems() { } + + public virtual int Id { get; set; } + + /// + /// 所属租户 + /// + public override Guid TenantId { get; set; } + + /// + /// 产品id + /// + public virtual string ProductId { get; set; } = null!; + + /// + /// 订单id + /// + public virtual string OrderId { get; set; } = null!; + + /// + /// 发放奖励信息 + /// + public virtual string? RewardInfo { get; set; } + + /// + /// 产品id、主键 + /// + public virtual int Product { get; set; } + + /// + /// 支付信息 + /// + public virtual string? PaymentInfo { get; set; } + + /// + /// 发放奖励提示 + /// + public virtual string? RewardTips { get; set; } + + /// + /// 支付地址 + /// + public virtual string? PayUrl { get; set; } +} diff --git a/src/CloudGaming/CloudGaming.Model/DbSqlServer/Db_User/T_User_Phone_Account.cs b/src/CloudGaming/CloudGaming.Model/DbSqlServer/Db_User/T_User_Phone_Account.cs new file mode 100644 index 0000000..84c3411 --- /dev/null +++ b/src/CloudGaming/CloudGaming.Model/DbSqlServer/Db_User/T_User_Phone_Account.cs @@ -0,0 +1,61 @@ +using System; + +namespace CloudGaming.Model.DbSqlServer.Db_User; + +/// +/// 手机号登录表 +/// +public partial class T_User_Phone_Account: MultiTenantEntity +{ + public T_User_Phone_Account() { } + + /// + /// 主键 + /// + public virtual int Id { get; set; } + + /// + /// 所属租户 + /// + public override Guid TenantId { get; set; } + + /// + /// 用户Id + /// + public virtual int UserId { get; set; } + + /// + /// 手机号 + /// + public virtual string PhoneNum { get; set; } = null!; + + /// + /// 验证码 + /// + public virtual string VerificationCode { get; set; } = null!; + + /// + /// 最后一次登录时间 + /// + public virtual DateTime LastLoginAt { get; set; } + + /// + /// 修改时间 + /// + public virtual DateTime CreatedAt { get; set; } + + /// + /// 创建时间 + /// + public virtual DateTime UpdatedAt { get; set; } + + /// + /// 用户昵称 + /// + public virtual string? NikeName { get; set; } + + /// + /// 是否注销 + /// + public virtual bool IsLogout { get; set; } +} diff --git a/src/CloudGaming/CloudGaming.Model/DbSqlServer/Db_User/T_User_Token.cs b/src/CloudGaming/CloudGaming.Model/DbSqlServer/Db_User/T_User_Token.cs new file mode 100644 index 0000000..35160af --- /dev/null +++ b/src/CloudGaming/CloudGaming.Model/DbSqlServer/Db_User/T_User_Token.cs @@ -0,0 +1,43 @@ +using System; + +namespace CloudGaming.Model.DbSqlServer.Db_User; + +/// +/// 用户单点登录表 +/// +public partial class T_User_Token: MultiTenantEntity +{ + public T_User_Token() { } + + public virtual int Id { get; set; } + + /// + /// 用户Id + /// + public virtual int UserId { get; set; } + + /// + /// 所属租户 + /// + public override Guid TenantId { get; set; } + + /// + /// 登录token + /// + public virtual string? Token { get; set; } + + /// + /// 过期时间 + /// + public virtual DateTime? ExpiresAt { get; set; } + + /// + /// 创建时间 + /// + public virtual DateTime? CreateAt { get; set; } + + /// + /// 修改时间 + /// + public virtual DateTime? UpdateAt { get; set; } +} diff --git a/src/CloudGaming/CloudGaming.Model/DbSqlServer/efcore-gen.md b/src/CloudGaming/CloudGaming.Model/DbSqlServer/efcore-gen.md new file mode 100644 index 0000000..1e97ef0 --- /dev/null +++ b/src/CloudGaming/CloudGaming.Model/DbSqlServer/efcore-gen.md @@ -0,0 +1,6 @@ + +##在API项目里面执行,使用连接字符串名称,生成代码到model项目 +```sh +--user +dotnet ef dbcontext scaffold "Server=192.168.1.17;Database=CloudGamingUser;User Id=sa;Password=Dbt@com@123;TrustServerCertificate=true;" Microsoft.EntityFrameworkCore.SqlServer -o DbSqlServer/Db_User/ --use-database-names --no-pluralize --force +``` \ No newline at end of file diff --git a/src/CloudGaming/CloudGaming.Model/GlobalUsings.cs b/src/CloudGaming/CloudGaming.Model/GlobalUsings.cs new file mode 100644 index 0000000..0a7e25b --- /dev/null +++ b/src/CloudGaming/CloudGaming.Model/GlobalUsings.cs @@ -0,0 +1,2 @@ +global using HuanMeng.DotNetCore.MultiTenant; +global using HuanMeng.DotNetCore.MultiTenant.Contract;