添加搜索接口

This commit is contained in:
zpc 2024-11-10 02:45:42 +08:00
parent 1fb5621af7
commit 08cd3df42b
14 changed files with 215 additions and 111 deletions

View File

@ -74,5 +74,18 @@ namespace CloudGaming.Api.Controllers
GameBLL gamebll = new GameBLL(this.ServiceProvider);
return gamebll.GameRecommendations(gameId);
}
/// <summary>
/// 游戏搜索
/// </summary>
/// <param name="gameId"></param>
/// <returns></returns>
[HttpGet]
public List<GameListDto> GameSearch([FromQuery] string? gameId)
{
GameBLL gamebll = new GameBLL(this.ServiceProvider);
return gamebll.GameSearch(gameId);
}
}
}

View File

@ -4,8 +4,7 @@
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base
USER app
WORKDIR /app
EXPOSE 8080
EXPOSE 8081
EXPOSE 80
# 此阶段用于生成服务项目

View File

@ -69,14 +69,12 @@ namespace CloudGaming.Code.Cache.Special
string chineseName = faker.Internet.UserName();
NickName = chineseName;
}
gameInfo.GameShare = $"此游戏由{NickName}分享。";
gameInfo.GameShare = $"{NickName}";
gameInfo.GameShareUserIcon = 90001;
if (gameInfo.ConsumeDiamondNumHour == 0)
{
gameInfo.ConsumeDiamondNumHour = defaultConsumeDiamondNumHour;
}
if (gameInfo.ConsumeDiamondNumHour > 0)
{
gameInfo.GameDetailsofCharges = $"游戏资费:游玩按分钟计费,{gameInfo.ConsumeDiamondNumHour}钻石/小时。";

View File

@ -51,7 +51,7 @@ namespace CloudGaming.Code.Epg
{
return;
}
var epgInfo = item.ToEpgInfo(Cache.GameEntityCache);
var epgInfo = item.ToEpgInfo(Cache.GameEntityCache,it.DefaultImageStyle);
if (epgInfo != null)
{
list.Add(epgInfo);

View File

@ -1,5 +1,6 @@
using CloudGaming.Code.Cache.Special;
using CloudGaming.DtoModel.Epg;
using CloudGaming.DtoModel.Game;
using System;
using System.Collections.Generic;
@ -20,7 +21,7 @@ namespace CloudGaming.Code.Epg
/// <param name="epgCfg"></param>
/// <param name="gameEntityCache"></param>
/// <returns></returns>
public static EpgInfo ToEpgInfo(this T_Epg_Cfg epgCfg, GameEntityCache gameEntityCache)
public static EpgInfo ToEpgInfo(this T_Epg_Cfg epgCfg, GameEntityCache gameEntityCache, int defaultImageStyle)
{
if (epgCfg.ResType == (int)EpgEnum.EpgResType. && string.IsNullOrEmpty(epgCfg.ResId))
{
@ -55,18 +56,14 @@ namespace CloudGaming.Code.Epg
{
epgInfo.SubTitle = gameInfo.Title2;
}
if (epgInfo.ImageUrl == 0 && !string.IsNullOrEmpty(epgCfg.ImageResStyle))
if (epgCfg.ImageResStyle == 0)
{
epgInfo.ImageUrl = epgCfg.ImageResStyle switch
{
var style when style == ((int)ImageResStyle.Game尊享推荐_312_420).ToString() => gameInfo.ImageId_ZXTJ,
var style when style == ((int)ImageResStyle.Game推荐位大图_984_520).ToString() => gameInfo.ImageId_TJ,
var style when style == ((int)ImageResStyle.Game游戏库_180_180).ToString() => gameInfo.GameImageId,
var style when style == ((int)ImageResStyle.Game最近推出_360_548).ToString() => gameInfo.ImageId_ZJTC,
var style when style == ((int)ImageResStyle.Game精选推荐_474_300).ToString() => gameInfo.ImageId_JXTJ,
_ => epgInfo.ImageUrl
};
epgCfg.ImageResStyle = defaultImageStyle;
}
//defaultImageStyle
if (epgInfo.ImageUrl == 0 && epgCfg.ImageResStyle != 0)
{
epgInfo.ImageUrl = ((ImageResStyle)epgCfg.ImageResStyle).GetImageResStyle(gameInfo);
}
epgInfo.Score = gameInfo.Score ?? string.Empty;
@ -74,5 +71,7 @@ namespace CloudGaming.Code.Epg
return epgInfo;
}
}
}

View File

@ -7,6 +7,8 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static CloudGaming.DtoModel.Epg.EpgEnum;
namespace CloudGaming.Code.Game
{
/// <summary>
@ -54,7 +56,7 @@ namespace CloudGaming.Code.Game
{
var gameList = Cache.GameEntityCache?.DataList ?? new List<GameInfo>();
var x = gameList.Where(it => it.GameType?.Any(item => item.Id == typeId) ?? false).Select(it => new
GameListDto(it)).ToList();
GameListDto(it, ImageResStyle.)).ToList();
return x;
});
return gameListDto;
@ -102,8 +104,47 @@ namespace CloudGaming.Code.Game
{
gameInfos = Cache.GameInfos.OrderBy(it => Guid.NewGuid()).Take(3).ToList();
}
var gameList = gameInfos?.Select(it => new GameListDto(it)).ToList();
var gameList = gameInfos?.Select(it => new GameListDto(it, ImageResStyle.)).ToList();
return gameList ?? new List<GameListDto>();
}
/// <summary>
/// 游戏搜索
/// </summary>
/// <param name="gameName"></param>
/// <returns></returns>
public List<GameListDto> GameSearch(string gameName)
{
var gameIdMatches = Cache.GameInfos
.Where(it => it.GameId.Contains(gameName))
.Select(it => new GameListDto(it, ImageResStyle.LOGO))
.ToList();
var gameNameMatches = Cache.GameInfos
.Where(it => it.GameName.Contains(gameName))
.Select(it => new GameListDto(it, ImageResStyle.LOGO))
.ToList();
var gameIntroduceMatches = Cache.GameInfos
.Where(it => it.GameIntroduce.Contains(gameName) )
.Select(it => new GameListDto(it, ImageResStyle.LOGO))
.ToList();
var otherMatches = Cache.GameInfos
.Where(it => !it.GameId.Contains(gameName) && !it.GameName.Contains(gameName) && !it.GameIntroduce.Contains(gameName) &&
(it.GameTags.Any(tag => tag.Name.Contains(gameName)) || it.GameType.Any(types => types.Name.Contains(gameName))))
.Select(it => new GameListDto(it, ImageResStyle.LOGO))
.ToList();
var list = gameIdMatches
.Concat(gameNameMatches)
.Concat(gameIntroduceMatches)
.Concat(otherMatches)
.Distinct()
.ToList();
return list;
}
}
}

View File

@ -1,9 +1,13 @@
using CloudGaming.DtoModel.Game;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static CloudGaming.DtoModel.Epg.EpgEnum;
namespace CloudGaming.DtoModel.Epg
{
/// <summary>
@ -29,6 +33,8 @@ namespace CloudGaming.DtoModel.Epg
public const string = "GameLive";
public const string = "VideoLive";
public const string = "MyHistory";
}
@ -37,28 +43,32 @@ namespace CloudGaming.DtoModel.Epg
/// </summary>
public enum ImageResStyle
{
/// <summary>
/// 游戏-尊享推荐, 竖版 Image_Shu
/// </summary>
Game尊享推荐_312_420 = 1,
/// <summary>
/// 游戏-推荐位大图 Image_Block2
/// 小LOGO适用于首页最近推出、游玩历史、游戏详情页logo。
/// </summary>
Game推荐位大图_984_520 = 2,
/// <summary>
/// 游戏-精选推荐, 豆腐块图 Image_Block
/// </summary>
Game精选推荐_474_300 = 3,
/// <summary>
/// 游戏-最近推出, 竖版2高一点的最近推出 Image_Shu2
/// </summary>
Game最近推出_360_548 = 4,
LOGO = 1,
/// <summary>
/// 游戏-游戏库, 正方形 (GameImageId)
/// 中等LOGO适用于首页体育竞技、搜索。
/// </summary>
Game游戏库_180_180 = 5,
LOGO = 2,
/// <summary>
/// 大LOGO适用于首页爆款热门。
/// </summary>
LOGO = 3,
/// <summary>
/// 竖形图,适用于首页蘑菇必玩、首页热血格斗、游戏详情页游戏推荐。
/// </summary>
= 4,
/// <summary>
/// 游戏库,适用于游戏库。
/// </summary>
= 5,
= 6,
}
@ -91,4 +101,28 @@ namespace CloudGaming.DtoModel.Epg
}
public static class EpgEnumExtend
{
/// <summary>
/// 获取对应样式的图片
/// </summary>
/// <param name="imageResStyle"></param>
/// <param name="gameInfo"></param>
/// <returns></returns>
public static int GetImageResStyle(this ImageResStyle imageResStyle, GameInfo? gameInfo)
{
return imageResStyle switch
{
var style when style == ImageResStyle.LOGO => gameInfo?.ImageIconId,
var style when style == ImageResStyle.LOGO => gameInfo?.ImageId_ShouSuo,
var style when style == ImageResStyle.LOGO => gameInfo?.ImageId_RM,
var style when style == ImageResStyle. => gameInfo?.ImageId_YXK,
var style when style == ImageResStyle. => gameInfo?.ImageId_TJ,
var style when style == ImageResStyle. => gameInfo?.ImageId_FK,
_ => 0
} ?? 0;
}
}
}

View File

@ -76,7 +76,7 @@ namespace CloudGaming.DtoModel.Game
public virtual string? GameIntroduce { get; set; }
/// <summary>
/// 游戏分享
/// 游戏分享
/// </summary>
public string GameShare { get; set; }

View File

@ -1,3 +1,5 @@
using CloudGaming.DtoModel.Epg;
using HuanMeng.DotNetCore.AttributeExtend;
using System;
@ -6,43 +8,59 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CloudGaming.DtoModel.Game
using static CloudGaming.DtoModel.Epg.EpgEnum;
namespace CloudGaming.DtoModel.Game;
/// <summary>
/// 游戏列表数据
/// </summary>
public class GameListDto
{
public GameListDto() { }
/// <summary>
/// 游戏列表数据
///
/// </summary>
public class GameListDto
/// <param name="gameInfo"></param>
public GameListDto(GameInfo gameInfo, ImageResStyle imageResStyle)
{
public GameListDto() { }
/// <summary>
///
/// </summary>
/// <param name="gameInfo"></param>
public GameListDto(GameInfo gameInfo)
if (gameInfo != null)
{
if (gameInfo != null)
{
this.GameName = gameInfo.GameName;
this.GameId = gameInfo.GameId;
this.GameIconImage = gameInfo.GameImageId;
this.GameName = gameInfo.GameName;
this.GameId = gameInfo.GameId;
this.GameIconImage = imageResStyle.GetImageResStyle(gameInfo);
}
}
/// <summary>
/// 游戏Id
/// </summary>
public string GameId { get; set; }
/// <summary>
/// 游戏名称
/// </summary>
public string GameName { get; set; }
}
/// <summary>
/// 游戏Id
/// </summary>
public string GameId { get; set; }
/// <summary>
/// 游戏名称
/// </summary>
public string GameName { get; set; }
/// <summary>
/// 游戏icon
/// </summary>
[Images]
public int GameIconImage { get; set; }
/// <summary>
/// 游戏icon
/// </summary>
[Images]
public int GameIconImage { get; set; }
public override bool Equals(object obj)
{
if (obj is GameListDto other)
{
return string.Equals(this.GameId, other.GameId, StringComparison.Ordinal);
}
return false;
}
public override int GetHashCode()
{
return this.GameId != null ? this.GameId.GetHashCode() : 0;
}
}

View File

@ -1,4 +1,4 @@
using System;
using System;
namespace CloudGaming.GameModel.Db.Db_Game;
@ -94,7 +94,7 @@ public partial class T_Game_List
/// <summary>
/// 游戏难度
/// </summary>
public virtual string GameDifficulty { get; set; } = null!;
public virtual string? GameDifficulty { get; set; }
/// <summary>
/// 游戏发行方

View File

@ -190,6 +190,7 @@ public partial class CloudGamingPhoneContext : MultiTenantDbContext//DbContext
.IsUnicode(false)
.HasComment("上线渠道,0不限制")
.UseCollation("Chinese_PRC_CI_AS");
entity.Property(e => e.DefaultImageStyle).HasComment("默认使用的资源图");
entity.Property(e => e.EpgParentCategory).HasComment("epg父组Id, 0无");
entity.Property(e => e.IdName)
.HasMaxLength(50)
@ -213,6 +214,7 @@ public partial class CloudGamingPhoneContext : MultiTenantDbContext//DbContext
entity.Property(e => e.ShowStatus)
.HasDefaultValue(1)
.HasComment("显示状态。0全部显示1审核模式下不显示2正常模式下不显示审核显示");
entity.Property(e => e.TenantId).HasComment("租户");
//添加全局筛选器
if (this.TenantInfo != null)
{
@ -229,7 +231,6 @@ public partial class CloudGamingPhoneContext : MultiTenantDbContext//DbContext
entity.Property(e => e.Id).HasComment("标识");
entity.Property(e => e.Channel)
.HasMaxLength(50)
.IsUnicode(false)
.HasComment("渠道")
.UseCollation("Chinese_PRC_CI_AS");
entity.Property(e => e.Continent)
@ -256,15 +257,11 @@ public partial class CloudGamingPhoneContext : MultiTenantDbContext//DbContext
entity.Property(e => e.ImageId).HasComment("图片");
entity.Property(e => e.ImageId2).HasComment("图片2-预留");
entity.Property(e => e.ImageId3).HasComment("图片3");
entity.Property(e => e.ImageResStyle)
.HasMaxLength(50)
.HasComment("使用原始资源图样式n_n")
.UseCollation("Chinese_PRC_CI_AS");
entity.Property(e => e.ImageResStyle).HasComment("使用原始资源图样式n_n");
entity.Property(e => e.IsOnline).HasComment("是否启用");
entity.Property(e => e.OrderId).HasComment("排序-正序");
entity.Property(e => e.Platform)
.HasMaxLength(50)
.IsUnicode(false)
.HasComment("平台安卓还是ios")
.UseCollation("Chinese_PRC_CI_AS");
entity.Property(e => e.ResId)
@ -358,19 +355,19 @@ public partial class CloudGamingPhoneContext : MultiTenantDbContext//DbContext
.HasMaxLength(100)
.HasComment("游戏Id")
.UseCollation("Chinese_PRC_CI_AS");
entity.Property(e => e.GameImageId).HasComment("游戏库Icon图");
entity.Property(e => e.GameLoadBgImageId).HasComment("游戏加载图");
entity.Property(e => e.GameLoadTime).HasComment("Loading时间");
entity.Property(e => e.GameName)
.HasMaxLength(50)
.HasComment("游戏名称")
.UseCollation("Chinese_PRC_CI_AS");
entity.Property(e => e.ImageIconId).HasComment("游戏icon");
entity.Property(e => e.ImageIconId).HasComment("游戏详情logo");
entity.Property(e => e.ImageId_Banner).HasComment("顶部图片");
entity.Property(e => e.ImageId_JXTJ).HasComment("精选推荐");
entity.Property(e => e.ImageId_TJ).HasComment("推荐大图");
entity.Property(e => e.ImageId_ZJTC).HasComment("最近推出");
entity.Property(e => e.ImageId_ZXTJ).HasComment("尊享推荐");
entity.Property(e => e.ImageId_FK).HasComment("首页GTA系列大方块");
entity.Property(e => e.ImageId_RM).HasComment("首页爆款热门");
entity.Property(e => e.ImageId_ShouSuo).HasComment("搜索icon");
entity.Property(e => e.ImageId_TJ).HasComment("推荐大图(首页蘑菇必玩 = 首页热血格斗 = 游戏详情页游戏推荐)");
entity.Property(e => e.ImageId_YXK).HasComment("游戏库Icon图");
entity.Property(e => e.IsDiscount)
.HasDefaultValue(true)
.HasComment("是否参与优惠套餐活动(比如包夜卡,周中卡之类的)");

View File

@ -78,4 +78,9 @@ public partial class T_Epg_CategoryCfg: MultiTenantEntity
/// 所属租户
/// </summary>
public override Guid TenantId { get; set; }
}
/// <summary>
/// 默认使用的资源图
/// </summary>
public virtual int DefaultImageStyle { get; set; }
}

View File

@ -1,11 +1,11 @@
using System;
using System;
namespace CloudGaming.Model.DbSqlServer.Db_Phone;
/// <summary>
/// Epg配置表
/// </summary>
public partial class T_Epg_Cfg : MultiTenantEntity
public partial class T_Epg_Cfg: MultiTenantEntity
{
public T_Epg_Cfg() { }
@ -57,7 +57,7 @@ public partial class T_Epg_Cfg : MultiTenantEntity
/// <summary>
/// 使用原始资源图样式n_n
/// </summary>
public virtual string? ImageResStyle { get; set; }
public virtual int ImageResStyle { get; set; }
/// <summary>
/// 是否启用
@ -124,8 +124,8 @@ public partial class T_Epg_Cfg : MultiTenantEntity
/// </summary>
public virtual DateTime? CreateTime { get; set; }
/// <summary>
/// <summary>
/// 所属租户
/// </summary>
public override Guid TenantId { get; set; }
}
}

View File

@ -1,11 +1,11 @@
using System;
using System;
namespace CloudGaming.Model.DbSqlServer.Db_Phone;
/// <summary>
/// 游戏配置
/// </summary>
public partial class T_GameCBT : MultiTenantEntity
public partial class T_GameCBT: MultiTenantEntity
{
public T_GameCBT() { }
@ -21,11 +21,6 @@ public partial class T_GameCBT : MultiTenantEntity
/// </summary>
public virtual int GameBgImgId { get; set; }
/// <summary>
/// 游戏库Icon图
/// </summary>
public virtual int GameImageId { get; set; }
/// <summary>
/// 是否启用
/// </summary>
@ -62,7 +57,7 @@ public partial class T_GameCBT : MultiTenantEntity
public virtual int GameLoadBgImageId { get; set; }
/// <summary>
/// 游戏icon
/// 游戏详情logo
/// </summary>
public virtual int ImageIconId { get; set; }
@ -82,17 +77,7 @@ public partial class T_GameCBT : MultiTenantEntity
public virtual int GameLoadTime { get; set; }
/// <summary>
/// 尊享推荐
/// </summary>
public virtual int ImageId_ZXTJ { get; set; }
/// <summary>
/// 精选推荐
/// </summary>
public virtual int ImageId_JXTJ { get; set; }
/// <summary>
/// 推荐大图
/// 推荐大图(首页蘑菇必玩 = 首页热血格斗 = 游戏详情页游戏推荐)
/// </summary>
public virtual int ImageId_TJ { get; set; }
@ -106,11 +91,6 @@ public partial class T_GameCBT : MultiTenantEntity
/// </summary>
public virtual string? GameName { get; set; }
/// <summary>
/// 最近推出
/// </summary>
public virtual int ImageId_ZJTC { get; set; }
/// <summary>
/// 顶部图片
/// </summary>
@ -156,8 +136,28 @@ public partial class T_GameCBT : MultiTenantEntity
/// </summary>
public virtual string? FriendlyTips { get; set; }
/// <summary>
/// <summary>
/// 所属租户
/// </summary>
public override Guid TenantId { get; set; }
/// <summary>
/// 游戏库Icon图
/// </summary>
public virtual int ImageId_YXK { get; set; }
/// <summary>
/// 搜索icon
/// </summary>
public virtual int ImageId_ShouSuo { get; set; }
/// <summary>
/// 首页爆款热门
/// </summary>
public virtual int ImageId_RM { get; set; }
/// <summary>
/// 首页GTA系列大方块
/// </summary>
public virtual int ImageId_FK { get; set; }
}