diff --git a/src/CloudGaming/Api/CloudGaming.Api/Controllers/GameController.cs b/src/CloudGaming/Api/CloudGaming.Api/Controllers/GameController.cs
index a8ca024..798b456 100644
--- a/src/CloudGaming/Api/CloudGaming.Api/Controllers/GameController.cs
+++ b/src/CloudGaming/Api/CloudGaming.Api/Controllers/GameController.cs
@@ -48,5 +48,31 @@ namespace CloudGaming.Api.Controllers
GameBLL gamebll = new GameBLL(this.ServiceProvider);
return await gamebll.GetGameListAsync(typeId);
}
+
+ ///
+ /// 获取游戏详情
+ ///
+ ///
+ ///
+ [HttpGet]
+ [RedisCache(2, 2, 0)]
+ public GameInfoDto GetGameInfo([FromQuery] string gameId)
+ {
+ GameBLL gamebll = new GameBLL(this.ServiceProvider);
+ return gamebll.GetGameInfo(gameId);
+ }
+ ///
+ /// 根据游戏类型Id 获取游戏列表
+ ///
+ ///
+ ///
+ [HttpGet]
+ [RedisCache(0, 5, 0)]
+ public List GameRecommendations([FromQuery] string? gameId)
+ {
+
+ GameBLL gamebll = new GameBLL(this.ServiceProvider);
+ return gamebll.GameRecommendations(gameId);
+ }
}
}
diff --git a/src/CloudGaming/Code/CloudGaming.Code/Cache/Special/GameEntityCache.cs b/src/CloudGaming/Code/CloudGaming.Code/Cache/Special/GameEntityCache.cs
index c90abf1..53cbd72 100644
--- a/src/CloudGaming/Code/CloudGaming.Code/Cache/Special/GameEntityCache.cs
+++ b/src/CloudGaming/Code/CloudGaming.Code/Cache/Special/GameEntityCache.cs
@@ -1,5 +1,8 @@
using AutoMapper;
+using Bogus;
+
+using CloudGaming.Code.Config;
using CloudGaming.Code.DataAccess;
using CloudGaming.DtoModel.Game;
using CloudGaming.GameModel.Db.Db_Game;
@@ -38,7 +41,20 @@ namespace CloudGaming.Code.Cache.Special
var gameTypesDict = dao.DaoGame.Context.T_Game_Types.AsNoTracking().ToDictionary(type => type.TypeId);
var gameTagsDict = dao.DaoGame.Context.T_Game_Tags.AsNoTracking().ToDictionary(tag => tag.TagId);
+ //游戏分享头像
+ var gameUserShare = dao.DaoGame.Context.T_Game_UserShare.AsNoTracking().GroupBy(it => it.GameId).ToDictionary(it => it.Key, it => it.Last().NickName);
+ var appConfig = dao.DaoExt.Context.T_App_Config.AsNoTracking().Where(it => it.ConfigType == 3).ToList();
+ var config = appConfig.GetAppConfig(3, 1, null);
+ var defaultConsumeDiamondNumHour = 0;
+ if (!string.IsNullOrEmpty(config?.ConfigValue))
+ {
+ int.TryParse(config?.ConfigValue, out defaultConsumeDiamondNumHour);
+ }
+ //var lorem = new Bogus.DataSets.Lorem(locale: "zh_CN");
+ var faker = new Faker("zh_CN");
+ //f.r
+ //lorem.
var gameInfos = gameCbtList
.Where(gameCbt => gameListDict.ContainsKey(gameCbt.GameId))
.Select(gameCbt =>
@@ -48,6 +64,27 @@ namespace CloudGaming.Code.Cache.Special
game.ToGameInfo(gameInfo);
gameInfo.GameType = GetGameExtendedAttributes(gameChildList, gameCbt.GameId, 1, gameTypesDict);
gameInfo.GameTags = GetGameExtendedAttributes(gameChildList, gameCbt.GameId, 2, gameTagsDict);
+ if (!gameUserShare.TryGetValue(gameCbt.GameId, out string NickName))
+ {
+ string chineseName = faker.Internet.UserName();
+ NickName = chineseName;
+ }
+ gameInfo.GameShare = $"此游戏由{NickName}分享。";
+ gameInfo.GameShareUserIcon = 90001;
+ if (gameInfo.ConsumeDiamondNumHour == 0)
+ {
+ gameInfo.ConsumeDiamondNumHour = defaultConsumeDiamondNumHour;
+ }
+
+
+ if (gameInfo.ConsumeDiamondNumHour > 0)
+ {
+ gameInfo.GameDetailsofCharges = $"游戏资费:游玩按分钟计费,{gameInfo.ConsumeDiamondNumHour}钻石/小时。";
+ }
+ else
+ {
+ gameInfo.GameDetailsofCharges = $"游戏免费";
+ }
return gameInfo;
})
.ToList();
@@ -104,6 +141,14 @@ namespace CloudGaming.Code.Cache.Special
}
}
+ //public Task> DataListAsync
+ //{
+ // get
+ // {
+
+ // return new List();
+ // }
+ //}
private Dictionary gameInfoDic;
///
/// 游戏详情
diff --git a/src/CloudGaming/Code/CloudGaming.Code/CloudGaming.Code.csproj b/src/CloudGaming/Code/CloudGaming.Code/CloudGaming.Code.csproj
index adf1556..7ccf7ec 100644
--- a/src/CloudGaming/Code/CloudGaming.Code/CloudGaming.Code.csproj
+++ b/src/CloudGaming/Code/CloudGaming.Code/CloudGaming.Code.csproj
@@ -11,6 +11,7 @@
+
diff --git a/src/CloudGaming/Code/CloudGaming.Code/Config/AppConfigBLLExtend.cs b/src/CloudGaming/Code/CloudGaming.Code/Config/AppConfigBLLExtend.cs
index f3dcaf3..986c724 100644
--- a/src/CloudGaming/Code/CloudGaming.Code/Config/AppConfigBLLExtend.cs
+++ b/src/CloudGaming/Code/CloudGaming.Code/Config/AppConfigBLLExtend.cs
@@ -46,9 +46,9 @@ public static class AppConfigBLLExtend
///
///
///
- public static T_App_Config GetAppConfig(this List app_Configs, int cfgType, int cfgId, AppRequestConfig appRequestInfo)
+ public static T_App_Config GetAppConfig(this List app_Configs, int cfgType, int cfgId, AppRequestConfig? appRequestInfo)
{
- var list = GetAppCfgList(app_Configs, cfgType, cfgId, appRequestInfo.Channel, appRequestInfo.Platform, appRequestInfo.Continent, appRequestInfo.CountryName);
+ var list = GetAppCfgList(app_Configs, cfgType, cfgId, appRequestInfo?.Channel, appRequestInfo?.Platform, appRequestInfo?.Continent, appRequestInfo?.CountryName);
return list.FirstOrDefault();
}
diff --git a/src/CloudGaming/Code/CloudGaming.Code/Game/GameBLL.cs b/src/CloudGaming/Code/CloudGaming.Code/Game/GameBLL.cs
index b032836..4ccb75f 100644
--- a/src/CloudGaming/Code/CloudGaming.Code/Game/GameBLL.cs
+++ b/src/CloudGaming/Code/CloudGaming.Code/Game/GameBLL.cs
@@ -60,5 +60,50 @@ namespace CloudGaming.Code.Game
return gameListDto;
}
+ ///
+ /// 获取游戏详情
+ ///
+ ///
+ ///
+ public GameInfoDto GetGameInfo(string gameId)
+ {
+ if (string.IsNullOrEmpty(gameId))
+ {
+ return null;
+ }
+ var game = Cache.GameEntityCache[gameId];
+ if (game == null)
+ {
+ return null;
+ }
+ var gameInfo = Mapper.Map(game);
+ return gameInfo;
+ }
+
+ ///
+ /// 游戏推荐
+ ///
+ ///
+ ///
+ public List GameRecommendations(string gameId)
+ {
+ List? gameInfos = null;
+ if (!string.IsNullOrEmpty(gameId))
+ {
+ var game = Cache.GameEntityCache[gameId];
+ if (game != null)
+ {
+ var gameTagIds = game.GameTags.Select(it => it.Id);
+ gameInfos = Cache.GameInfos.Where(it => it.GameTags.Any(tag => gameTagIds.Contains(tag.Id))).OrderBy(it => Guid.NewGuid()).Take(3).ToList();
+ }
+ }
+
+ if (gameInfos == null || gameInfos.Count == 0)
+ {
+ gameInfos = Cache.GameInfos.OrderBy(it => Guid.NewGuid()).Take(3).ToList();
+ }
+ var gameList = gameInfos?.Select(it => new GameListDto(it)).ToList();
+ return gameList ?? new List();
+ }
}
}
diff --git a/src/CloudGaming/Model/CloudGaming.DtoModel/Game/GameInfo.cs b/src/CloudGaming/Model/CloudGaming.DtoModel/Game/GameInfo.cs
index 0fc79ed..fcb02f6 100644
--- a/src/CloudGaming/Model/CloudGaming.DtoModel/Game/GameInfo.cs
+++ b/src/CloudGaming/Model/CloudGaming.DtoModel/Game/GameInfo.cs
@@ -42,6 +42,10 @@ namespace CloudGaming.DtoModel.Game
#endregion
+ ///
+ /// 游戏资费明细
+ ///
+ public string GameDetailsofCharges { get; set; }
///
/// 游戏标签
///
@@ -53,6 +57,15 @@ namespace CloudGaming.DtoModel.Game
public List GameType { get; set; }
#region 游戏列表数据
+
+ ///
+ /// 游戏分享
+ ///
+ public string GameShare { get; set; }
+ ///
+ /// 游戏分享人员的Id
+ ///
+ public int GameShareUserIcon { get; set; }
///
/// 游戏人数
///
diff --git a/src/CloudGaming/Model/CloudGaming.DtoModel/Game/GameInfoDto.cs b/src/CloudGaming/Model/CloudGaming.DtoModel/Game/GameInfoDto.cs
index 524b1de..04076e8 100644
--- a/src/CloudGaming/Model/CloudGaming.DtoModel/Game/GameInfoDto.cs
+++ b/src/CloudGaming/Model/CloudGaming.DtoModel/Game/GameInfoDto.cs
@@ -1,3 +1,6 @@
+using AutoMapper;
+using AutoMapper.Configuration.Annotations;
+
using HuanMeng.DotNetCore.AttributeExtend;
using System;
@@ -8,25 +11,45 @@ using System.Threading.Tasks;
namespace CloudGaming.DtoModel.Game
{
+ ///
+ /// 游戏详情
+ ///
+ [AutoMap(typeof(GameInfo))]
public class GameInfoDto
{
+ public GameInfoDto() { }
///
/// 游戏Id
///
- public virtual string GameId { get; set; } = null!;
+ public string GameId { get; set; }
+ ///
+ /// 游戏名称
+ ///
+ public virtual string? GameName { get; set; }
+ ///
+ /// 副标题
+ ///
+ [SourceMember(nameof(GameInfo.Title2))]
+ public virtual string? Subtitle { get; set; }
+ ///
+ /// 游戏资费明细
+ ///
+ public string GameDetailsofCharges { get; set; }
///
/// 游戏icon
///
- [Images("ImageIcon")]
- public virtual int ImageIcon { get; set; }
+ [Images]
+ [SourceMember(nameof(GameInfo.ImageIconId))]
+ public int GameIcon { get; set; }
///
- ///
+ /// 游戏背景图
///
- [Images("GameBgImage")]
- public virtual int GameBgImage { get; set; }
+ [Images]
+ [SourceMember(nameof(GameInfo.GameBgImgId))]
+ public int GameBg { get; set; }
///
/// 游戏标签
///
@@ -36,5 +59,31 @@ namespace CloudGaming.DtoModel.Game
/// 游戏列表
///
public List GameType { get; set; }
+
+ ///
+ /// 评分
+ ///
+ public string? Score { get; set; }
+
+ ///
+ /// Loading时间
+ ///
+ public int GameLoadTime { get; set; }
+
+ ///
+ /// 游戏介绍
+ ///
+ public virtual string? GameIntroduce { get; set; }
+
+ ///
+ /// 游戏分享
+ ///
+ public string GameShare { get; set; }
+
+ ///
+ /// 游戏分享人员头像
+ ///
+ [Images]
+ public int GameShareUserIcon { get; set; }
}
}
diff --git a/src/CloudGaming/Model/CloudGaming.DtoModel/Game/GameInfoExtend.cs b/src/CloudGaming/Model/CloudGaming.DtoModel/Game/GameInfoExtend.cs
index 719e110..3351349 100644
--- a/src/CloudGaming/Model/CloudGaming.DtoModel/Game/GameInfoExtend.cs
+++ b/src/CloudGaming/Model/CloudGaming.DtoModel/Game/GameInfoExtend.cs
@@ -41,6 +41,7 @@ namespace CloudGaming.DtoModel.Game
gameInfo.SteamId = gameList.SteamId;
gameInfo.GameDifficulty = gameList.GameDifficulty;
gameInfo.GameOperationModel = gameList.GameOperationModel;
+
return gameInfo;
}
diff --git a/src/CloudGaming/Utile/HuanMeng.DotNetCore/Utility/ObjectExtensions1.cs b/src/CloudGaming/Utile/HuanMeng.DotNetCore/Utility/ObjectExtensions1.cs
index 636d4cc..32a5b95 100644
--- a/src/CloudGaming/Utile/HuanMeng.DotNetCore/Utility/ObjectExtensions1.cs
+++ b/src/CloudGaming/Utile/HuanMeng.DotNetCore/Utility/ObjectExtensions1.cs
@@ -24,7 +24,7 @@ public static class ObjectExtensions
///
/// 缓存每个属性是否具有 ImagesAttribute 特性。
///
- public static readonly ConcurrentDictionary _PropertyCache = new();
+ public static readonly ConcurrentDictionary _PropertyCache = new();
///
/// 判断对象是否为原始类型或字符串类型。
@@ -112,7 +112,7 @@ public static class ObjectExtensions
// 否则,如果是集合类型,则递归转换
keyValuePairs[accessor.PropertyName] = accessor.HasImagesAttribute
? imageFunc?.Invoke((int)propertyValue) ?? ""
- : IsCollectionType(propertyValue) ? ToDictionaryOrList(propertyValue, propertyPath, imageFunc) : propertyValue;
+ : ToDictionaryOrList(propertyValue, propertyPath, imageFunc); // IsCollectionType(propertyValue) ?: propertyValue;
}
return keyValuePairs;
@@ -131,16 +131,8 @@ public static class ObjectExtensions
// 创建用于访问属性值的委托
var getter = CreatePropertyGetter(type, property);
// 检查属性是否具有 ImagesAttribute,并将结果存储在缓存中
- var imagesAttribute = _PropertyCache.GetOrAdd(property, p => p.GetCustomAttribute());
- if (imagesAttribute != null)
- {
- if (!string.IsNullOrEmpty(imagesAttribute.FieldName))
- {
- return new PropertyAccessor(imagesAttribute.FieldName, getter, true);
- }
- return new PropertyAccessor(property.Name, getter, true);
- }
- return new PropertyAccessor(property.Name, getter, false);
+ var isImagesAttribute = _PropertyCache.GetOrAdd(property, p => p.GetCustomAttribute() != null);
+ return new PropertyAccessor(property.Name, getter, isImagesAttribute);
}).ToArray();
}