提交代码
This commit is contained in:
parent
32d30a2746
commit
08d451e061
|
|
@ -1,5 +1,6 @@
|
|||
using AutoMapper;
|
||||
|
||||
using CloudGaming.Code.Cache;
|
||||
using CloudGaming.Code.DataAccess;
|
||||
|
||||
using HuanMeng.DotNetCore.JwtInfrastructure.Interface;
|
||||
|
|
@ -13,7 +14,7 @@ using StackExchange.Redis;
|
|||
namespace CloudGaming.Code.AppExtend
|
||||
{
|
||||
/// <summary>
|
||||
/// bll基础类
|
||||
/// BLL 基础类
|
||||
/// </summary>
|
||||
public class CloudGamingBase : BLLBase<DAO>
|
||||
{
|
||||
|
|
@ -24,7 +25,7 @@ namespace CloudGaming.Code.AppExtend
|
|||
#region 数据库
|
||||
private DAO _dao;
|
||||
/// <summary>
|
||||
/// dao 数据库
|
||||
/// DAO 数据库
|
||||
/// </summary>
|
||||
public override DAO Dao
|
||||
{
|
||||
|
|
@ -41,11 +42,9 @@ namespace CloudGaming.Code.AppExtend
|
|||
|
||||
#region 映射
|
||||
private IMapper _mapper;
|
||||
|
||||
/// <summary>
|
||||
/// dto映射
|
||||
/// DTO 映射
|
||||
/// </summary>
|
||||
//[FromServices]
|
||||
public virtual IMapper Mapper
|
||||
{
|
||||
get
|
||||
|
|
@ -56,14 +55,15 @@ namespace CloudGaming.Code.AppExtend
|
|||
}
|
||||
return _mapper;
|
||||
}
|
||||
set { _mapper = value; }
|
||||
set
|
||||
{
|
||||
_mapper = value;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
#region AppConfig
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
private AppConfig? appConfig;
|
||||
|
||||
#region AppConfig 配置
|
||||
private AppConfig _appConfig;
|
||||
/// <summary>
|
||||
/// AppConfig 配置
|
||||
/// </summary>
|
||||
|
|
@ -71,17 +71,17 @@ namespace CloudGaming.Code.AppExtend
|
|||
{
|
||||
get
|
||||
{
|
||||
if (appConfig == null)
|
||||
if (_appConfig == null)
|
||||
{
|
||||
appConfig = _serviceProvider.GetService<AppConfig>();
|
||||
_appConfig = _serviceProvider.GetService<AppConfig>();
|
||||
}
|
||||
return appConfig;
|
||||
return _appConfig;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 请求信息
|
||||
private IHttpContextAccessor _HttpContextAccessor;
|
||||
#region 请求信息
|
||||
private IHttpContextAccessor _httpContextAccessor;
|
||||
/// <summary>
|
||||
/// HttpContextAccessor
|
||||
/// </summary>
|
||||
|
|
@ -89,20 +89,19 @@ namespace CloudGaming.Code.AppExtend
|
|||
{
|
||||
get
|
||||
{
|
||||
if (_HttpContextAccessor == null)
|
||||
if (_httpContextAccessor == null)
|
||||
{
|
||||
_HttpContextAccessor = _serviceProvider.GetRequiredService<IHttpContextAccessor>();
|
||||
_httpContextAccessor = _serviceProvider.GetRequiredService<IHttpContextAccessor>();
|
||||
}
|
||||
return _HttpContextAccessor;
|
||||
return _httpContextAccessor;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region http请求
|
||||
private IHttpClientFactory? _httpClientFactory;
|
||||
|
||||
#region HTTP 请求
|
||||
private IHttpClientFactory _httpClientFactory;
|
||||
/// <summary>
|
||||
/// http请求
|
||||
/// HttpClientFactory
|
||||
/// </summary>
|
||||
public IHttpClientFactory HttpClientFactory
|
||||
{
|
||||
|
|
@ -117,11 +116,10 @@ namespace CloudGaming.Code.AppExtend
|
|||
}
|
||||
#endregion
|
||||
|
||||
#region JWT管理
|
||||
|
||||
#region JWT 管理
|
||||
private IJwtAuthManager _jwtAuthManager;
|
||||
/// <summary>
|
||||
/// jwt管理
|
||||
/// JWT 管理
|
||||
/// </summary>
|
||||
public IJwtAuthManager JwtAuthManager
|
||||
{
|
||||
|
|
@ -136,12 +134,13 @@ namespace CloudGaming.Code.AppExtend
|
|||
}
|
||||
#endregion
|
||||
|
||||
|
||||
#region 日志
|
||||
private ILogger<CloudGamingBase>? _logger;
|
||||
public ILogger<CloudGamingBase> _Logger
|
||||
private ILogger<CloudGamingBase> _logger;
|
||||
/// <summary>
|
||||
/// 日志
|
||||
/// </summary>
|
||||
public ILogger<CloudGamingBase> Logger
|
||||
{
|
||||
|
||||
get
|
||||
{
|
||||
if (_logger == null)
|
||||
|
|
@ -154,9 +153,9 @@ namespace CloudGaming.Code.AppExtend
|
|||
#endregion
|
||||
|
||||
#region Redis
|
||||
private IDatabase? _redis;
|
||||
private IDatabase _redis;
|
||||
/// <summary>
|
||||
/// 妙语实现类
|
||||
/// Redis 缓存
|
||||
/// </summary>
|
||||
public IDatabase RedisCache
|
||||
{
|
||||
|
|
@ -170,5 +169,23 @@ namespace CloudGaming.Code.AppExtend
|
|||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 缓存
|
||||
private CloudGamingCache _cache;
|
||||
/// <summary>
|
||||
/// 缓存
|
||||
/// </summary>
|
||||
public CloudGamingCache Cache
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_cache == null)
|
||||
{
|
||||
_cache = new CloudGamingCache(this);
|
||||
}
|
||||
return _cache;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,63 +8,59 @@ namespace CloudGaming.Code.Cache
|
|||
/// <summary>
|
||||
/// 缓存数据表
|
||||
/// </summary>
|
||||
/// <param name="gamingBase"></param>
|
||||
public class CloudGamingCache(CloudGamingBase gamingBase)
|
||||
public class CloudGamingCache
|
||||
{
|
||||
#region 图片缓存表
|
||||
private readonly CloudGamingBase _gamingBase;
|
||||
|
||||
public CloudGamingCache(CloudGamingBase gamingBase)
|
||||
{
|
||||
_gamingBase = gamingBase;
|
||||
}
|
||||
|
||||
#region 通用缓存获取方法
|
||||
|
||||
/// <summary>
|
||||
/// 图片缓存表
|
||||
/// 通用缓存获取方法,适用于所有类型
|
||||
/// </summary>
|
||||
public CommonDataEntityCache<T_Image_Config>? ImageConfigCache { get; set; }
|
||||
/// <summary>
|
||||
/// 图片
|
||||
/// </summary>
|
||||
public List<T_Image_Config> ImageConfigList
|
||||
private List<T> GetCacheList<T>(ref CommonDataEntityCache<T>? cache, Expression<Func<T, bool>>? expWhere = null) where T : class
|
||||
{
|
||||
get
|
||||
if (cache == null)
|
||||
{
|
||||
if (ImageConfigCache == null)
|
||||
{
|
||||
ImageConfigCache = CloudGamingCacheExtend.GetDataEntityCache<T_Image_Config>(gamingBase);
|
||||
}
|
||||
return ImageConfigCache.DataList ?? new List<T_Image_Config>();
|
||||
cache = CloudGamingCacheExtend.GetDataEntityCache(_gamingBase, expWhere);
|
||||
}
|
||||
return cache.DataList ?? new List<T>();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 图片缓存表
|
||||
|
||||
private CommonDataEntityCache<T_App_Image>? _appImageCache;
|
||||
|
||||
/// <summary>
|
||||
/// 图片缓存列表
|
||||
/// </summary>
|
||||
public List<T_App_Image> AppImageList => GetCacheList(ref _appImageCache);
|
||||
|
||||
#endregion
|
||||
|
||||
#region 配置缓存表
|
||||
|
||||
/// <summary>
|
||||
/// 配置缓存表
|
||||
/// </summary>
|
||||
public CommonDataEntityCache<T_App_Config>? AppConfigCache { get; set; }
|
||||
private CommonDataEntityCache<T_App_Config>? _appConfigCache;
|
||||
|
||||
/// <summary>
|
||||
/// 配置
|
||||
/// 配置缓存列表
|
||||
/// </summary>
|
||||
public List<T_App_Config> AppConfigList
|
||||
{
|
||||
get
|
||||
{
|
||||
if (AppConfigCache == null)
|
||||
{
|
||||
AppConfigCache = CloudGamingCacheExtend.GetDataEntityCache<T_App_Config>(gamingBase);
|
||||
}
|
||||
return AppConfigCache.DataList ?? new List<T_App_Config>();
|
||||
}
|
||||
}
|
||||
public List<T_App_Config> AppConfigList => GetCacheList(ref _appConfigCache);
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 游戏
|
||||
/// 游戏缓存扩展
|
||||
/// </summary>
|
||||
public static class CloudGamingCacheExtend
|
||||
{
|
||||
/// <summary>
|
||||
/// 缓存锁字典
|
||||
/// </summary>
|
||||
private static readonly ConcurrentDictionary<Type, object> ExtCacheLockList = new ConcurrentDictionary<Type, object>();
|
||||
private static readonly ConcurrentDictionary<Type, object> GameCacheLockList = new ConcurrentDictionary<Type, object>();
|
||||
private static readonly ConcurrentDictionary<Type, object> AppCacheLockList = new ConcurrentDictionary<Type, object>();
|
||||
|
|
@ -78,12 +74,12 @@ namespace CloudGaming.Code.Cache
|
|||
static CloudGamingCacheExtend()
|
||||
{
|
||||
NamespaceMapping = new Dictionary<string, (ConcurrentDictionary<Type, object> cacheList, AppDataBaseType dbType)>
|
||||
{
|
||||
{ "CloudGaming.GameModel.Db.Db_Ext", (ExtCacheLockList, AppDataBaseType.Ext) },
|
||||
{ "CloudGaming.GameModel.Db.Db_Game", (GameCacheLockList, AppDataBaseType.Game) },
|
||||
{ "CloudGaming.Model.DbSqlServer.Db_Phone", (AppCacheLockList, AppDataBaseType.App) },
|
||||
{ "CloudGaming.Model.DbSqlServer.Db_User", (UserCacheLockList, AppDataBaseType.User) }
|
||||
};
|
||||
{
|
||||
{ "CloudGaming.GameModel.Db.Db_Ext", (ExtCacheLockList, AppDataBaseType.Ext) },
|
||||
{ "CloudGaming.GameModel.Db.Db_Game", (GameCacheLockList, AppDataBaseType.Game) },
|
||||
{ "CloudGaming.Model.DbSqlServer.Db_Phone", (AppCacheLockList, AppDataBaseType.App) },
|
||||
{ "CloudGaming.Model.DbSqlServer.Db_User", (UserCacheLockList, AppDataBaseType.User) }
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -113,7 +109,7 @@ namespace CloudGaming.Code.Cache
|
|||
{
|
||||
return cacheList.GetOrAdd(typeLock, _ =>
|
||||
{
|
||||
Log("没有找到锁对象==>" + typeLock.Name);
|
||||
Log($"没有找到锁对象 ==> {typeLock.Name}");
|
||||
return new object();
|
||||
});
|
||||
}
|
||||
|
|
@ -138,9 +134,8 @@ namespace CloudGaming.Code.Cache
|
|||
/// </summary>
|
||||
private static void Log(string message)
|
||||
{
|
||||
// 这里可以替换为更好的日志记录系统,例如 NLog, Serilog 等
|
||||
// 替换为其他日志记录系统,例如 NLog, Serilog 等
|
||||
Console.WriteLine(message);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ public partial class CloudGamingCBTContext : DbContext
|
|||
/// <summary>
|
||||
/// 图片列表
|
||||
/// </summary>
|
||||
public virtual DbSet<T_Image_Config> T_Image_Config { get; set; }
|
||||
public virtual DbSet<T_App_Image> T_App_Image { get; set; }
|
||||
|
||||
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
||||
=> optionsBuilder.UseSqlServer("Server=192.168.1.17;Database=CloudGamingCBT;User Id=sa;Password=Dbt@com@123;TrustServerCertificate=true;");
|
||||
|
|
@ -94,7 +94,7 @@ public partial class CloudGamingCBTContext : DbContext
|
|||
|
||||
});
|
||||
|
||||
modelBuilder.Entity<T_Image_Config>(entity =>
|
||||
modelBuilder.Entity<T_App_Image>(entity =>
|
||||
{
|
||||
entity.HasKey(e => e.Id).HasName("PK_T_VL_UI_IMAGES");
|
||||
|
||||
|
|
|
|||
|
|
@ -5,9 +5,9 @@ namespace CloudGaming.GameModel.Db.Db_Ext;
|
|||
/// <summary>
|
||||
/// 图片列表
|
||||
/// </summary>
|
||||
public partial class T_Image_Config
|
||||
public partial class T_App_Image
|
||||
{
|
||||
public T_Image_Config() { }
|
||||
public T_App_Image() { }
|
||||
|
||||
public virtual int Id { get; set; }
|
||||
|
||||
|
|
@ -1,47 +0,0 @@
|
|||
using System;
|
||||
|
||||
namespace CloudGaming.GameModel.Db.Db_Ext;
|
||||
|
||||
/// <summary>
|
||||
/// App配置
|
||||
/// </summary>
|
||||
public partial class T_Config
|
||||
{
|
||||
public T_Config() { }
|
||||
|
||||
public virtual int Id { get; set; }
|
||||
|
||||
public virtual int? ConfigType { get; set; }
|
||||
|
||||
public virtual int? ConfigId { get; set; }
|
||||
|
||||
public virtual bool? IsShow { get; set; }
|
||||
|
||||
public virtual string? ShowName { get; set; }
|
||||
|
||||
public virtual string? Desc { get; set; }
|
||||
|
||||
public virtual DateTime? UpdateTime { get; set; }
|
||||
|
||||
public virtual DateTime? CreatTime { get; set; }
|
||||
|
||||
public virtual int? ConfigNum { get; set; }
|
||||
|
||||
public virtual int? ConfigNum2 { get; set; }
|
||||
|
||||
public virtual string? ConfigStr { get; set; }
|
||||
|
||||
public virtual string? BossId { get; set; }
|
||||
|
||||
public virtual string? Plat { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 州 例:亚洲
|
||||
/// </summary>
|
||||
public virtual string? Continent { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 国家 例:中国
|
||||
/// </summary>
|
||||
public virtual string? CountryName { get; set; }
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user