diff --git a/src/CloudGaming/Api/CloudGaming.Api/Controllers/GameController.cs b/src/CloudGaming/Api/CloudGaming.Api/Controllers/GameController.cs index b836a77..2c21317 100644 --- a/src/CloudGaming/Api/CloudGaming.Api/Controllers/GameController.cs +++ b/src/CloudGaming/Api/CloudGaming.Api/Controllers/GameController.cs @@ -85,11 +85,23 @@ namespace CloudGaming.Api.Controllers /// /// [HttpGet] - public List GameSearch([FromQuery] string? gameId) + public async Task> GameSearch([FromQuery] string? gameId) { GameBLL gamebll = new GameBLL(this.ServiceProvider); - return gamebll.GameSearch(gameId); + return await gamebll.GameSearch(gameId); + } + + /// + /// 游戏热度搜索 + /// + /// + [HttpGet] + public async Task> GameHotSearch() + { + + GameBLL gamebll = new GameBLL(this.ServiceProvider); + return await gamebll.GameHotSearch(); } diff --git a/src/CloudGaming/Code/CloudGaming.Code/Game/GameBLL.cs b/src/CloudGaming/Code/CloudGaming.Code/Game/GameBLL.cs index 7db356b..6138e99 100644 --- a/src/CloudGaming/Code/CloudGaming.Code/Game/GameBLL.cs +++ b/src/CloudGaming/Code/CloudGaming.Code/Game/GameBLL.cs @@ -127,10 +127,24 @@ namespace CloudGaming.Code.Game /// /// /// - public List GameSearch(string gameName) + public async Task> GameSearch(string gameName) { - + try + { + T_User_Search gameSearch = new T_User_Search() + { + SearchContent = gameName, + SearchDate = DateTime.Now, + UserId = _UserId, + SearchDay = int.Parse(DateTime.Now.ToString("yyyyMMdd")) + }; + await Dao.DaoPhone.Context.T_User_Search.AddAsync(gameSearch); + await Dao.DaoPhone.Context.SaveChangesAsync(); + } + catch (Exception) + { + } var gameIdMatches = Cache.GameInfos .Where(it => it.GameId.Contains(gameName)) .Select(it => new GameListDto(it, ImageResStyle.中等LOGO)) @@ -161,6 +175,16 @@ namespace CloudGaming.Code.Game return list; } + /// + /// 热门搜索 + /// + /// + public async Task> GameHotSearch() + { + var list = await Dao.DaoPhone.Context.T_Search.Where(it => !string.IsNullOrEmpty(it.Search)).OrderBy(it => it.OrderId).Take(10).Select(it => it.Search).ToListAsync(); + return list; + } + /// /// 我的收藏 /// diff --git a/src/CloudGaming/Model/CloudGaming.Model/DbSqlServer/Db_Phone/CloudGamingPhoneContext.cs b/src/CloudGaming/Model/CloudGaming.Model/DbSqlServer/Db_Phone/CloudGamingPhoneContext.cs index f721b60..fa997c4 100644 --- a/src/CloudGaming/Model/CloudGaming.Model/DbSqlServer/Db_Phone/CloudGamingPhoneContext.cs +++ b/src/CloudGaming/Model/CloudGaming.Model/DbSqlServer/Db_Phone/CloudGamingPhoneContext.cs @@ -133,6 +133,11 @@ public partial class CloudGamingPhoneContext : MultiTenantDbContext//DbContext /// public virtual DbSet T_RewardConfig { get; set; } + /// + /// 搜索页面展示的搜索词 + /// + public virtual DbSet T_Search { get; set; } + /// /// 七日签到配置表 /// @@ -178,6 +183,11 @@ public partial class CloudGamingPhoneContext : MultiTenantDbContext//DbContext /// public virtual DbSet T_User_RedemptionUsage { get; set; } + /// + /// 用户搜索表 + /// + public virtual DbSet T_User_Search { get; set; } + /// /// 用户签到表 /// @@ -916,6 +926,28 @@ public partial class CloudGamingPhoneContext : MultiTenantDbContext//DbContext } }); + modelBuilder.Entity(entity => + { + entity.HasKey(e => e.Id).HasName("PK__T_Search__3214EC0728B995D9"); + + entity.ToTable(tb => tb.HasComment("搜索页面展示的搜索词")); + + entity.Property(e => e.Id).HasComment("主键"); + entity.Property(e => e.CreateTime) + .HasComment("创建时间") + .HasColumnType("datetime"); + entity.Property(e => e.OrderId).HasComment("排序"); + entity.Property(e => e.Search) + .HasMaxLength(255) + .HasComment("搜索词"); + entity.Property(e => e.TenantId).HasComment("租户"); + //添加全局筛选器 + if (this.TenantInfo != null) + { + entity.HasQueryFilter(it => it.TenantId == this.TenantInfo.TenantId); + } + }); + modelBuilder.Entity(entity => { entity.HasKey(e => e.Id).HasName("PK_T_SEVENDAYSIGNIN_CBT"); @@ -1056,6 +1088,7 @@ public partial class CloudGamingPhoneContext : MultiTenantDbContext//DbContext entity.Property(e => e.CreateTime) .HasComment("创建时间") .HasColumnType("datetime"); + entity.Property(e => e.TenantId).HasComment("租户"); entity.Property(e => e.Text).HasComment("内容"); entity.Property(e => e.UpdateTime) .HasComment("修改时间") @@ -1159,6 +1192,29 @@ public partial class CloudGamingPhoneContext : MultiTenantDbContext//DbContext } }); + modelBuilder.Entity(entity => + { + entity.HasKey(e => e.Id).HasName("PK__T_User_S__3214EC07010A7D09"); + + entity.ToTable(tb => tb.HasComment("用户搜索表")); + + entity.Property(e => e.Id).HasComment("主键"); + entity.Property(e => e.SearchContent) + .HasMaxLength(255) + .HasComment("搜索内容"); + entity.Property(e => e.SearchDate) + .HasComment("搜索时间") + .HasColumnType("datetime"); + entity.Property(e => e.SearchDay).HasComment("搜索时间,天"); + entity.Property(e => e.TenantId).HasComment("租户"); + entity.Property(e => e.UserId).HasComment("用户Id"); + //添加全局筛选器 + if (this.TenantInfo != null) + { + entity.HasQueryFilter(it => it.TenantId == this.TenantInfo.TenantId); + } + }); + modelBuilder.Entity(entity => { entity.HasKey(e => e.Id).HasName("PK_T_USER_SIGNDAYS"); diff --git a/src/CloudGaming/Model/CloudGaming.Model/DbSqlServer/Db_Phone/T_Search.cs b/src/CloudGaming/Model/CloudGaming.Model/DbSqlServer/Db_Phone/T_Search.cs new file mode 100644 index 0000000..c78deb5 --- /dev/null +++ b/src/CloudGaming/Model/CloudGaming.Model/DbSqlServer/Db_Phone/T_Search.cs @@ -0,0 +1,36 @@ +using System; + +namespace CloudGaming.Model.DbSqlServer.Db_Phone; + +/// +/// 搜索页面展示的搜索词 +/// +public partial class T_Search: MultiTenantEntity +{ + public T_Search() { } + + /// + /// 主键 + /// + public virtual int Id { get; set; } + + /// + /// 搜索词 + /// + public virtual string? Search { get; set; } + + /// + /// 排序 + /// + public virtual int OrderId { get; set; } + + /// + /// 所属租户 + /// + public override Guid TenantId { get; set; } + + /// + /// 创建时间 + /// + public virtual DateTime CreateTime { get; set; } +} diff --git a/src/CloudGaming/Model/CloudGaming.Model/DbSqlServer/Db_Phone/T_User_FeedBack.cs b/src/CloudGaming/Model/CloudGaming.Model/DbSqlServer/Db_Phone/T_User_FeedBack.cs index 74f3f16..9521529 100644 --- a/src/CloudGaming/Model/CloudGaming.Model/DbSqlServer/Db_Phone/T_User_FeedBack.cs +++ b/src/CloudGaming/Model/CloudGaming.Model/DbSqlServer/Db_Phone/T_User_FeedBack.cs @@ -38,4 +38,9 @@ public partial class T_User_FeedBack: MultiTenantEntity /// 修改时间 /// public virtual DateTime UpdateTime { get; set; } -} + + /// + /// 所属租户 + /// + public override Guid TenantId { get; set; } + } diff --git a/src/CloudGaming/Model/CloudGaming.Model/DbSqlServer/Db_Phone/T_User_Search.cs b/src/CloudGaming/Model/CloudGaming.Model/DbSqlServer/Db_Phone/T_User_Search.cs new file mode 100644 index 0000000..466b6cd --- /dev/null +++ b/src/CloudGaming/Model/CloudGaming.Model/DbSqlServer/Db_Phone/T_User_Search.cs @@ -0,0 +1,41 @@ +using System; + +namespace CloudGaming.Model.DbSqlServer.Db_Phone; + +/// +/// 用户搜索表 +/// +public partial class T_User_Search: MultiTenantEntity +{ + public T_User_Search() { } + + /// + /// 主键 + /// + public virtual int Id { get; set; } + + /// + /// 搜索内容 + /// + public virtual string SearchContent { get; set; } = null!; + + /// + /// 搜索时间 + /// + public virtual DateTime SearchDate { get; set; } + + /// + /// 用户Id + /// + public virtual int UserId { get; set; } + + /// + /// 搜索时间,天 + /// + public virtual int SearchDay { get; set; } + + /// + /// 所属租户 + /// + public override Guid TenantId { get; set; } + }