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

namespace CloudGaming.GameModel.Db.Db_Game;

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

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

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

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


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


    /// <summary>
    /// 游戏多选保存
    /// </summary>
    public virtual DbSet<T_Game_ChildList> T_Game_ChildList { get; set; }

    /// <summary>
    /// 游戏列表
    /// </summary>
    public virtual DbSet<T_Game_List> T_Game_List { get; set; }

    /// <summary>
    ///  游戏标签
    /// </summary>
    public virtual DbSet<T_Game_Tags> T_Game_Tags { get; set; }

    /// <summary>
    /// 游戏类型
    /// </summary>
    public virtual DbSet<T_Game_Types> T_Game_Types { get; set; }

    /// <summary>
    /// 用户分享游戏
    /// </summary>
    public virtual DbSet<T_Game_UserShare> T_Game_UserShare { get; set; }

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

            entity.ToTable(tb => tb.HasComment("游戏多选保存"));

            entity.Property(e => e.ChildId).HasComment("配置表Id");
            entity.Property(e => e.ChildType).HasComment("1 游戏类型  2 游戏标签");
            entity.Property(e => e.Desc)
                .HasMaxLength(100)
                .HasComment("描述")
                .UseCollation("Chinese_PRC_CI_AS");
            entity.Property(e => e.GameId)
                .HasMaxLength(100)
                .HasComment("游戏Id")
                .UseCollation("Chinese_PRC_CI_AS");
            entity.Property(e => e.OrderId).HasComment("排序Id");

        });

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

            entity.ToTable(tb => tb.HasComment("游戏列表"));

            entity.Property(e => e.DCompany)
                .HasMaxLength(50)
                .HasComment("云开发公司");
            entity.Property(e => e.Desc)
                .HasMaxLength(100)
                .HasComment("备注")
                .UseCollation("Chinese_PRC_CI_AS");
            entity.Property(e => e.GameCloudId)
                .HasMaxLength(50)
                .HasComment("云游戏Id")
                .UseCollation("Chinese_PRC_CI_AS");
            entity.Property(e => e.GameDifficulty)
                .HasMaxLength(10)
                .HasComment("游戏难度");
            entity.Property(e => e.GameId)
                .HasMaxLength(100)
                .HasComment("我们自己的游戏Id")
                .UseCollation("Chinese_PRC_CI_AS");
            entity.Property(e => e.GameIntroduce)
                .HasComment("游戏介绍")
                .UseCollation("Chinese_PRC_CI_AS");
            entity.Property(e => e.GameIsAdapter).HasComment("游戏是否适配");
            entity.Property(e => e.GameIsCrack).HasComment("游戏是否破解");
            entity.Property(e => e.GameIsEditionMouse).HasComment("是否隐藏鼠标");
            entity.Property(e => e.GameIsEditionNumber).HasComment("是否有版号");
            entity.Property(e => e.GameIsSaveFile).HasComment("是否存档");
            entity.Property(e => e.GameIsVersion).HasComment("游戏是否有版权");
            entity.Property(e => e.GameIssuer)
                .HasMaxLength(100)
                .HasComment("游戏发行方")
                .UseCollation("Chinese_PRC_CI_AS");
            entity.Property(e => e.GameName)
                .HasMaxLength(100)
                .HasComment("游戏名称")
                .UseCollation("Chinese_PRC_CI_AS");
            entity.Property(e => e.GameOperationModel)
                .HasMaxLength(255)
                .HasComment("游戏操作类型");
            entity.Property(e => e.GamePeopleNum)
                .HasDefaultValue(1)
                .HasComment("游戏人数");
            entity.Property(e => e.OrderId).HasComment("游戏排序");
            entity.Property(e => e.ScreenOrientation).HasComment("屏幕方向：0-横屏 1-竖屏");
            entity.Property(e => e.SteamId)
                .HasMaxLength(30)
                .HasComment("steam")
                .UseCollation("Chinese_PRC_CI_AS");
            entity.Property(e => e.UpdateTime)
                .HasComment("修改时间")
                .HasColumnType("datetime");

        });

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

            entity.ToTable(tb => tb.HasComment(" 游戏标签"));

            entity.Property(e => e.CreatTime).HasColumnType("datetime");
            entity.Property(e => e.Desc)
                .HasMaxLength(100)
                .HasComment("描述")
                .UseCollation("Chinese_PRC_CI_AS");
            entity.Property(e => e.IsOnline).HasComment("是否启用");
            entity.Property(e => e.OrderId).HasComment("排序Id");
            entity.Property(e => e.TagId).HasComment("标签Id");
            entity.Property(e => e.TagName)
                .HasMaxLength(50)
                .HasComment("标签名称")
                .UseCollation("Chinese_PRC_CI_AS");
            entity.Property(e => e.UpdateTime).HasColumnType("datetime");

        });

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

            entity.ToTable(tb => tb.HasComment("游戏类型"));

            entity.Property(e => e.CreatTime)
                .HasComment("创建时间")
                .HasColumnType("datetime");
            entity.Property(e => e.IsOnline).HasComment("是否启用");
            entity.Property(e => e.OrderId).HasComment("排序");
            entity.Property(e => e.TypeDetails)
                .HasMaxLength(100)
                .HasComment("描述")
                .UseCollation("Chinese_PRC_CI_AS");
            entity.Property(e => e.TypeId).HasComment("类型Id");
            entity.Property(e => e.TypeName)
                .HasMaxLength(50)
                .HasComment("类型名称")
                .UseCollation("Chinese_PRC_CI_AS");
            entity.Property(e => e.UpdateTime)
                .HasComment("修改时间")
                .HasColumnType("datetime");

        });

        modelBuilder.Entity<T_Game_UserShare>(entity =>
        {
            entity.ToTable(tb => tb.HasComment("用户分享游戏"));

            entity.Property(e => e.Id).HasComment("自增");
            entity.Property(e => e.CreateTime)
                .HasDefaultValueSql("(getdate())")
                .HasComment("创建时间")
                .HasColumnType("datetime");
            entity.Property(e => e.Explain)
                .HasMaxLength(500)
                .HasDefaultValue("")
                .HasComment("说明")
                .UseCollation("Chinese_PRC_CI_AS");
            entity.Property(e => e.GameId)
                .HasMaxLength(50)
                .HasDefaultValue("")
                .HasComment("游戏Id")
                .UseCollation("Chinese_PRC_CI_AS");
            entity.Property(e => e.GameName)
                .HasMaxLength(50)
                .HasDefaultValue("‘’")
                .HasComment("游戏名称")
                .UseCollation("Chinese_PRC_CI_AS");
            entity.Property(e => e.NickName)
                .HasMaxLength(50)
                .HasDefaultValue("")
                .HasComment("用户昵称")
                .UseCollation("Chinese_PRC_CI_AS");
            entity.Property(e => e.UserHeadPortrait).HasComment("用户头像");
            entity.Property(e => e.UserHeadPortraitFrame).HasComment("用户头像框");

        });

        OnModelCreatingPartial(modelBuilder);
    }

    partial void OnModelCreatingPartial(ModelBuilder modelBuilder);
}
