using System;
using System.Collections.Generic;
using System.Text;

namespace CloudGaming.AppConfigModel
{

    /// <summary>
    /// 项目配置
    /// </summary>
    public class AppConfig
    {
        public AppConfig() { }
        /// <summary>
        /// 用户数据库连接字符串
        /// </summary>
        public string UserConnectionString { get; set; }
        /// <summary>
        /// 游戏
        /// </summary>
        public string GameConnectionString { get; set; }
        /// <summary>
        /// 扩展
        /// </summary>
        public string ExtConnectionString { get; set; }

        /// <summary>
        /// 手机app配置
        /// </summary>
        public string PhoneConnectionString { get; set; }

        /// <summary>
        /// redis连接字符串
        /// </summary>
        public string RedisConnectionString { get; set; }

        /// <summary>
        /// 域名
        /// </summary>
        public string DomainName { get; set; }
        /// <summary>
        /// 标识
        /// </summary>
        public string Identifier { get; set; }
        /// <summary>
        /// 名称
        /// </summary>
        public string Name { get; set; }

        /// <summary>
        /// 默认语言
        /// </summary>
        public string DefaultLanguage { get; set; }
        /// <summary>
        /// 租户
        /// </summary>
        public Guid TenantId { get; set; }
        /// <summary>
        /// 项目支付数据
        /// </summary>
        public PaymentModel? Payment { get; set; }

        /// <summary>
        /// oss阿里云配置
        /// </summary>
        public AliyunConfig AliyunConfig { get; set; }

        /// <summary>
        /// 用户默认配置
        /// </summary>
        public UserConfig UserConfig { get; set; }

        /// <summary>
        /// 游戏配置
        /// </summary>
        public GameConfig GameConfig { get; set; }

        /// <summary>
        /// 用户协议地址  
        /// </summary>
        public string UserAgreement { get; set; }

        /// <summary>
        /// 隐私协议地址
        /// </summary>
        public string PrivacyAgreement { get; set; }

        /// <summary>
        /// 多语言列表请求地址
        /// </summary>
        public string LanguageRequestUrl { get; set; }

        /// <summary>
        /// 清除缓存接口
        /// </summary>
        public List<string> CacheRequestUrls { get; set; }
        /// <summary>
        /// 获取数据库连接字符串
        /// </summary>
        /// <param name="key">user，game，ext，phone</param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        public string GetConnectionString(AppDataBaseType appDataBaseType)
        {
            switch (appDataBaseType)
            {
                case AppDataBaseType.User:
                    return UserConnectionString;
                case AppDataBaseType.Game:
                    return GameConnectionString;
                case AppDataBaseType.Ext:
                    return ExtConnectionString;
                case AppDataBaseType.App:
                    return PhoneConnectionString;
                default:
                    throw new NotImplementedException("数据库连接字符串不存在");
            }
        }
    }

    /// <summary>
    /// 数据库选项
    /// </summary>

    public enum AppDataBaseType
    {
        /// <summary>
        /// 用户数据库
        /// </summary>
        User,
        /// <summary>
        /// 游戏数据库
        /// </summary>
        Game,
        /// <summary>
        /// 扩展数据库
        /// </summary>
        Ext,
        /// <summary>
        /// app数据库
        /// </summary>
        App
    }

}
