using System;
using System.Collections.Generic;
using Microsoft.EntityFrameworkCore;

namespace CloudGaming.GameModel.Db.Db_Ext;

/// <summary>
/// 云游戏实体类
/// </summary>
public partial class CloudGamingCBTContext : DbContext
{
    public CloudGamingCBTContext() : base()
    {
    }

    /// <summary>
    /// 租户信息
    /// </summary>
    public ITenantInfo? TenantInfo { get; set; }

    public CloudGamingCBTContext(DbContextOptions<CloudGamingCBTContext> options)
         : base(options)
    {
    }

    /// <summary>
    /// 
    /// </summary>
    /// <param name="tenantInfo"></param>
    public CloudGamingCBTContext(ITenantInfo tenantInfo)
    {
     this.TenantInfo= tenantInfo;
    }


    /// <summary>
    /// 
    /// </summary>
    /// <param name="tenantInfo"></param>
    /// <param name="options"></param>
    public CloudGamingCBTContext(ITenantInfo tenantInfo, DbContextOptions<CloudGamingCBTContext> options) : base(options)
    {
     this.TenantInfo= tenantInfo;
    }


    /// <summary>
    /// app渠道表
    /// </summary>
    public virtual DbSet<T_App_Channel> T_App_Channel { get; set; }

    /// <summary>
    /// App配置表
    /// </summary>
    public virtual DbSet<T_App_Config> T_App_Config { get; set; }

    /// <summary>
    /// 图片列表
    /// </summary>
    public virtual DbSet<T_App_Image> T_App_Image { get; set; }

    /// <summary>
    /// 发送短信日志表
    /// </summary>
    public virtual DbSet<T_Sms_Log> T_Sms_Log { get; set; }

    /// <summary>
    /// 游戏统计数据
    /// </summary>
    public virtual DbSet<T_Statistics_Game> T_Statistics_Game { get; set; }

    /// <summary>
    /// 游戏统计数据-每小时
    /// </summary>
    public virtual DbSet<T_Statistics_GameHour> T_Statistics_GameHour { get; set; }

    /// <summary>
    /// 订单统计表
    /// </summary>
    public virtual DbSet<T_Statistics_Order> T_Statistics_Order { get; set; }

    /// <summary>
    /// 订单统计表
    /// </summary>
    public virtual DbSet<T_Statistics_OrderHour> T_Statistics_OrderHour { get; set; }

    /// <summary>
    /// 用户统计表
    /// </summary>
    public virtual DbSet<T_Statistics_User> T_Statistics_User { get; set; }

    /// <summary>
    /// 用户统计表
    /// </summary>
    public virtual DbSet<T_Statistics_UserHour> T_Statistics_UserHour { get; set; }

    /// <summary>
    /// 用户登录日志表，每天每个用户只有一条数据
    /// </summary>
    public virtual DbSet<T_User_LoginDay_Log> T_User_LoginDay_Log { get; set; }

    /// <summary>
    /// 用户登录日志表
    /// </summary>
    public virtual DbSet<T_User_Login_Log> T_User_Login_Log { get; set; }

    /// <summary>
    /// 用户实名认证记录表
    /// </summary>
    public virtual DbSet<T_User_RealAuthentication_Log> T_User_RealAuthentication_Log { get; set; }

    protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
      {//  => optionsBuilder.UseSqlServer("Server=192.168.195.8;Database=CloudGamingCBT;User Id=sa;Password=Dbt@com@123;TrustServerCertificate=true;");
      }
    protected override void OnModelCreating(ModelBuilder modelBuilder)
    {
        modelBuilder.Entity<T_App_Channel>(entity =>
        {
            entity.HasKey(e => e.Id).HasName("PK__T_App_Ch__3214EC07E413C19A");

            entity.ToTable(tb => tb.HasComment("app渠道表"));

            entity.Property(e => e.ChannelId)
                .HasMaxLength(10)
                .HasComment("渠道号");
            entity.Property(e => e.CreateAt)
                .HasComment("创建时间")
                .HasColumnType("datetime");
            entity.Property(e => e.Desc)
                .HasMaxLength(50)
                .HasComment("备注");
            entity.Property(e => e.Name)
                .HasMaxLength(255)
                .HasComment("渠道名称");
            entity.Property(e => e.UpdateAt)
                .HasComment("修改时间")
                .HasColumnType("datetime");

        });

        modelBuilder.Entity<T_App_Config>(entity =>
        {
            entity.HasKey(e => e.Id).HasName("PK_T_APP_CONFIG");

            entity.ToTable(tb => tb.HasComment("App配置表"));

            entity.Property(e => e.ActionId).HasComment("配置值类型");
            entity.Property(e => e.AppVersion)
                .HasMaxLength(20)
                .HasComment("app版本号");
            entity.Property(e => e.ChannelId)
                .HasMaxLength(100)
                .HasComment("渠道号")
                .UseCollation("Chinese_PRC_CI_AS");
            entity.Property(e => e.ConfigId).HasComment("配置Id");
            entity.Property(e => e.ConfigType).HasComment("配置类型");
            entity.Property(e => e.ConfigValue)
                .HasComment("配置值")
                .UseCollation("Chinese_PRC_CI_AS");
            entity.Property(e => e.Continent)
                .HasMaxLength(200)
                .HasComment("州 例：亚洲")
                .UseCollation("Chinese_PRC_CI_AS");
            entity.Property(e => e.CountryName)
                .HasMaxLength(200)
                .HasComment("国家 例：中国")
                .UseCollation("Chinese_PRC_CI_AS");
            entity.Property(e => e.CreateTime)
                .HasComment("创建时间")
                .HasColumnType("datetime");
            entity.Property(e => e.Desc)
                .HasComment("备注")
                .UseCollation("Chinese_PRC_CI_AS");
            entity.Property(e => e.IsEnabled).HasComment("是否启用");
            entity.Property(e => e.Name)
                .HasMaxLength(200)
                .HasComment("配置名称")
                .UseCollation("Chinese_PRC_CI_AS");
            entity.Property(e => e.Plat)
                .HasMaxLength(10)
                .HasComment("平台。安卓还是苹果")
                .UseCollation("Chinese_PRC_CI_AS");
            entity.Property(e => e.UpdateTime)
                .HasComment("修改时间")
                .HasColumnType("datetime");

        });

        modelBuilder.Entity<T_App_Image>(entity =>
        {
            entity.HasKey(e => e.Id).HasName("PK_T_VL_UI_IMAGES");

            entity.ToTable(tb => tb.HasComment("图片列表"));

            entity.Property(e => e.CreateTime)
                .HasComment("创建时间")
                .HasColumnType("datetime");
            entity.Property(e => e.Desc)
                .HasMaxLength(100)
                .HasComment("备注")
                .UseCollation("Chinese_PRC_CI_AS");
            entity.Property(e => e.ImageId).HasComment("图片Id");
            entity.Property(e => e.Language)
                .HasMaxLength(20)
                .HasDefaultValue("zh")
                .HasComment("语言")
                .UseCollation("Chinese_PRC_CI_AS");
            entity.Property(e => e.Name)
                .HasMaxLength(50)
                .HasComment("图片名称")
                .UseCollation("Chinese_PRC_CI_AS");
            entity.Property(e => e.Type).HasComment("类型");
            entity.Property(e => e.UpdateTime)
                .HasComment("修改时间")
                .HasColumnType("datetime");
            entity.Property(e => e.Url)
                .HasMaxLength(200)
                .HasComment("图片地址")
                .UseCollation("Chinese_PRC_CI_AS");

        });

        modelBuilder.Entity<T_Sms_Log>(entity =>
        {
            entity.HasKey(e => e.Id).HasName("PK__T_Sms_Lo__3214EC07AD037B45");

            entity.ToTable(tb => tb.HasComment("发送短信日志表"));

            entity.HasIndex(e => new { e.SendTimeDay, e.PhoneNumber }, "T_Sms_Log_SendTimeDay_index_desc").IsDescending(true, false);

            entity.Property(e => e.Id).HasComment("主键");
            entity.Property(e => e.ErrorMessage)
                .HasMaxLength(255)
                .HasComment("错误信息（如果发送失败）");
            entity.Property(e => e.PhoneNumber)
                .HasMaxLength(20)
                .HasComment("手机号码");
            entity.Property(e => e.SendStatus).HasComment("发送状态（0: 失败, 1: 成功）\r\n");
            entity.Property(e => e.SendTime)
                .HasComment("发送时间")
                .HasColumnType("datetime");
            entity.Property(e => e.SendTimeDay).HasComment("发送时间,天");
            entity.Property(e => e.VerificationCode)
                .HasMaxLength(20)
                .HasComment("发送的验证码");

        });

        modelBuilder.Entity<T_Statistics_Game>(entity =>
        {
            entity.HasKey(e => e.Id).HasName("_copy_1");

            entity.ToTable(tb => tb.HasComment("游戏统计数据"));

            entity.Property(e => e.Channel)
                .HasMaxLength(10)
                .HasComment("渠道号");
            entity.Property(e => e.CreatedAt)
                .HasComment("创建时间")
                .HasColumnType("datetime");
            entity.Property(e => e.LoginDate).HasComment("日期");
            entity.Property(e => e.LoginDay).HasComment("天");
            entity.Property(e => e.PlayGameCount).HasComment("用户玩游戏人数");
            entity.Property(e => e.PlayGameTimeCount).HasComment("用户玩游戏时长");
            entity.Property(e => e.StartGameCount).HasComment("启动游戏次数");
            entity.Property(e => e.UpdatedAt)
                .HasComment("修改时间")
                .HasColumnType("datetime");

        });

        modelBuilder.Entity<T_Statistics_GameHour>(entity =>
        {
            entity.HasKey(e => e.Id).HasName("_copy_1_copy_1");

            entity.ToTable(tb => tb.HasComment("游戏统计数据-每小时"));

            entity.Property(e => e.Channel)
                .HasMaxLength(10)
                .HasComment("渠道号");
            entity.Property(e => e.CreatedAt)
                .HasComment("创建时间")
                .HasColumnType("datetime");
            entity.Property(e => e.LoginDate).HasComment("日期");
            entity.Property(e => e.LoginDay).HasComment("天");
            entity.Property(e => e.LoginHour).HasComment("精确到小时");
            entity.Property(e => e.PlayGameCount).HasComment("用户玩游戏人数");
            entity.Property(e => e.PlayGameTimeCount)
                .HasComment("用户玩游戏时长")
                .HasColumnType("decimal(18, 0)");
            entity.Property(e => e.StartGameCount).HasComment("启动游戏次数");
            entity.Property(e => e.UpdatedAt)
                .HasComment("修改时间")
                .HasColumnType("datetime");

        });

        modelBuilder.Entity<T_Statistics_Order>(entity =>
        {
            entity.HasKey(e => e.Id).HasName("_copy_3");

            entity.ToTable(tb => tb.HasComment("订单统计表"));

            entity.Property(e => e.Channel)
                .HasMaxLength(10)
                .HasComment("渠道号");
            entity.Property(e => e.CreatedAt)
                .HasComment("创建时间")
                .HasColumnType("datetime");
            entity.Property(e => e.IntendedOrderCount).HasComment("意向订单次数");
            entity.Property(e => e.LoginDate).HasComment("日期");
            entity.Property(e => e.LoginDay).HasComment("天");
            entity.Property(e => e.PaidOrders).HasComment("支付订单次数");
            entity.Property(e => e.RechargeAmount)
                .HasComment("支付订单金额")
                .HasColumnType("decimal(18, 0)");
            entity.Property(e => e.UpdatedAt)
                .HasComment("修改时间")
                .HasColumnType("datetime");

        });

        modelBuilder.Entity<T_Statistics_OrderHour>(entity =>
        {
            entity.HasKey(e => e.Id).HasName("_copy_3_copy_1");

            entity.ToTable(tb => tb.HasComment("订单统计表"));

            entity.Property(e => e.Channel)
                .HasMaxLength(10)
                .HasComment("渠道号");
            entity.Property(e => e.CreatedAt)
                .HasComment("创建时间")
                .HasColumnType("datetime");
            entity.Property(e => e.IntendedOrderCount).HasComment("意向订单次数");
            entity.Property(e => e.LoginDate).HasComment("日期");
            entity.Property(e => e.LoginDay).HasComment("天");
            entity.Property(e => e.LoginHour).HasComment("小时");
            entity.Property(e => e.PaidOrders).HasComment("支付订单次数");
            entity.Property(e => e.RechargeAmount)
                .HasComment("支付订单金额")
                .HasColumnType("decimal(18, 0)");
            entity.Property(e => e.UpdatedAt)
                .HasComment("修改时间")
                .HasColumnType("datetime");

        });

        modelBuilder.Entity<T_Statistics_User>(entity =>
        {
            entity.HasKey(e => e.Id).HasName("PK__T_Statis__3214EC07FE2CF78F");

            entity.ToTable(tb => tb.HasComment("用户统计表"));

            entity.Property(e => e.ActiveCount).HasComment("用户活跃数");
            entity.Property(e => e.Channel)
                .HasMaxLength(10)
                .HasComment("渠道号");
            entity.Property(e => e.CreatedAt)
                .HasComment("创建时间")
                .HasColumnType("datetime");
            entity.Property(e => e.LoginCount).HasComment("用户登录数");
            entity.Property(e => e.LoginDate).HasComment("日期");
            entity.Property(e => e.LoginDay).HasComment("天");
            entity.Property(e => e.RegistrCount).HasComment("用户注册数");
            entity.Property(e => e.UpdatedAt)
                .HasComment("修改时间")
                .HasColumnType("datetime");

        });

        modelBuilder.Entity<T_Statistics_UserHour>(entity =>
        {
            entity.HasKey(e => e.Id).HasName("PK__T_Statis__3214EC07FE2CF78F_copy_1");

            entity.ToTable(tb => tb.HasComment("用户统计表"));

            entity.Property(e => e.Channel)
                .HasMaxLength(10)
                .HasComment("渠道号");
            entity.Property(e => e.CreatedAt)
                .HasComment("创建时间")
                .HasColumnType("datetime");
            entity.Property(e => e.LoginCount).HasComment("用户登录数");
            entity.Property(e => e.LoginDate).HasComment("日期");
            entity.Property(e => e.LoginDay).HasComment("天");
            entity.Property(e => e.LoginHour).HasComment("小时");
            entity.Property(e => e.OnlineCount).HasComment("在线人数");
            entity.Property(e => e.RegistrCount).HasComment("用户注册数");
            entity.Property(e => e.UpdatedAt)
                .HasComment("修改时间")
                .HasColumnType("datetime");

        });

        modelBuilder.Entity<T_User_LoginDay_Log>(entity =>
        {
            entity.HasKey(e => e.Id).HasName("PK__T_User_L__3214EC0786EBC26A");

            entity.ToTable(tb => tb.HasComment("用户登录日志表，每天每个用户只有一条数据"));

            entity.HasIndex(e => new { e.UserId, e.CreateTimeDay }, "T_UserLogDay_UserId").IsDescending(false, true);

            entity.Property(e => e.Id).HasComment("主键");
            entity.Property(e => e.AppVersion)
                .HasMaxLength(10)
                .HasComment("app版本");
            entity.Property(e => e.Channel)
                .HasMaxLength(20)
                .HasComment("渠道号");
            entity.Property(e => e.CreateTime)
                .HasComment("创建时间")
                .HasColumnType("datetime");
            entity.Property(e => e.CreateTimeDay).HasComment("登录时间，天");
            entity.Property(e => e.CreateTimeHour).HasComment("登录时间，小时");
            entity.Property(e => e.Ip)
                .HasMaxLength(50)
                .HasComment("ip地址");
            entity.Property(e => e.IsNew).HasComment("是否新用户");
            entity.Property(e => e.LogInDay).HasComment("连续登录天数");
            entity.Property(e => e.PlatformType)
                .HasMaxLength(10)
                .HasComment("登录平台");
            entity.Property(e => e.UserId).HasComment("用户Id");

        });

        modelBuilder.Entity<T_User_Login_Log>(entity =>
        {
            entity.HasKey(e => e.Id).HasName("PK__T_User_L__3214EC07C2A990A7");

            entity.ToTable(tb => tb.HasComment("用户登录日志表"));

            entity.Property(e => e.Id).HasComment("主键");
            entity.Property(e => e.AppVersion)
                .HasMaxLength(10)
                .HasComment("app版本");
            entity.Property(e => e.Channel)
                .HasMaxLength(20)
                .HasComment("渠道");
            entity.Property(e => e.CreateTime)
                .HasComment("创建时间")
                .HasColumnType("datetime");
            entity.Property(e => e.CreateTimeDay).HasComment("创建时间天");
            entity.Property(e => e.CreateTimeHour).HasComment("创建时间小时");
            entity.Property(e => e.Ip)
                .HasMaxLength(50)
                .HasComment("登录IP");
            entity.Property(e => e.IsNew).HasComment("是否新增用户");
            entity.Property(e => e.LoginType).HasComment("登录方式");
            entity.Property(e => e.PlatformType)
                .HasMaxLength(10)
                .HasComment("登录平台");
            entity.Property(e => e.UserId).HasComment("用户Id");

        });

        modelBuilder.Entity<T_User_RealAuthentication_Log>(entity =>
        {
            entity.HasKey(e => e.Id).HasName("PK_T_USER_REALAUTHENTICATIONLO");

            entity.ToTable(tb => tb.HasComment("用户实名认证记录表"));

            entity.HasIndex(e => e.UserId, "UserId").IsDescending();

            entity.Property(e => e.Id).HasComment("主键Id");
            entity.Property(e => e.CreateTime)
                .HasDefaultValueSql("(getdate())")
                .HasComment("创建时间")
                .HasColumnType("datetime");
            entity.Property(e => e.DeviceNumber)
                .HasMaxLength(100)
                .HasComment("设备号");
            entity.Property(e => e.IdCard)
                .HasMaxLength(20)
                .HasDefaultValue("")
                .HasComment("身份证号")
                .UseCollation("Chinese_PRC_CI_AS");
            entity.Property(e => e.IsRewards).HasComment("是否发放奖励");
            entity.Property(e => e.Message)
                .HasMaxLength(100)
                .HasComment("扩展消息");
            entity.Property(e => e.RealResults)
                .HasMaxLength(100)
                .HasComment("认证结果");
            entity.Property(e => e.UserId)
                .HasDefaultValueSql("('')")
                .HasComment("用户id");
            entity.Property(e => e.UserName)
                .HasMaxLength(30)
                .HasDefaultValue("")
                .HasComment("姓名")
                .UseCollation("Chinese_PRC_CI_AS");

        });

        OnModelCreatingPartial(modelBuilder);
    }

    partial void OnModelCreatingPartial(ModelBuilder modelBuilder);
}
