From e75ab989a8780807a1d60cdb1b6af46fb48162f8 Mon Sep 17 00:00:00 2001 From: zpc Date: Tue, 19 Nov 2024 19:33:57 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=8F=8D=E9=A6=88=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Api/CloudGaming.Api/.versionDescribe | 3 +- .../Controllers/FeedBackController.cs | 35 +++++++++++++++ .../Code/CloudGaming.Code/Game/GameBLL.cs | 8 ++-- .../CloudGaming.Code/Other/FeedBackBLL.cs | 45 +++++++++++++++++++ .../CloudGaming.Code/Other/RedemptionBLL.cs | 2 +- .../FeedBack/FeedBackRequest.cs | 25 +++++++++++ .../Db_Phone/CloudGamingPhoneContext.cs | 30 +++++++++++++ .../DbSqlServer/Db_Phone/T_User_FeedBack.cs | 41 +++++++++++++++++ 8 files changed, 183 insertions(+), 6 deletions(-) create mode 100644 src/CloudGaming/Api/CloudGaming.Api/Controllers/FeedBackController.cs create mode 100644 src/CloudGaming/Code/CloudGaming.Code/Other/FeedBackBLL.cs create mode 100644 src/CloudGaming/Model/CloudGaming.DtoModel/FeedBack/FeedBackRequest.cs create mode 100644 src/CloudGaming/Model/CloudGaming.Model/DbSqlServer/Db_Phone/T_User_FeedBack.cs diff --git a/src/CloudGaming/Api/CloudGaming.Api/.versionDescribe b/src/CloudGaming/Api/CloudGaming.Api/.versionDescribe index 67c47e5..7334cd5 100644 --- a/src/CloudGaming/Api/CloudGaming.Api/.versionDescribe +++ b/src/CloudGaming/Api/CloudGaming.Api/.versionDescribe @@ -2,4 +2,5 @@ 1. 增加兑换码接口(测试兑换码:test) 2. 增加首页排行榜接口 3. 增加游玩历史接口 -4. 增加游戏时长接 +4. 增加游戏时长接口 +5. 增加反馈接口(SendFeedBack) diff --git a/src/CloudGaming/Api/CloudGaming.Api/Controllers/FeedBackController.cs b/src/CloudGaming/Api/CloudGaming.Api/Controllers/FeedBackController.cs new file mode 100644 index 0000000..944c79b --- /dev/null +++ b/src/CloudGaming/Api/CloudGaming.Api/Controllers/FeedBackController.cs @@ -0,0 +1,35 @@ +using CloudGaming.Api.Base; +using CloudGaming.Code.Other; +using CloudGaming.DtoModel.FeedBack; + +using HuanMeng.DotNetCore.AttributeExtend; + +using Microsoft.AspNetCore.Mvc; + +namespace CloudGaming.Api.Controllers; + + +/// +/// 反馈 +/// +public class FeedBackController : CloudGamingControllerBase +{ + public FeedBackController(IServiceProvider _serviceProvider) : base(_serviceProvider) + { + } + + /// + /// 反馈接口 + /// + /// + /// + /// + [HttpPost] + [Message("反馈成功!")] + public async Task SendFeedBack([FromBody] FeedBackRequest feedBackRequest) + { + FeedBackBLL feedBackBLL = new FeedBackBLL(ServiceProvider); + await feedBackBLL.SendFeedBack(feedBackRequest); + return true; + } +} \ No newline at end of file diff --git a/src/CloudGaming/Code/CloudGaming.Code/Game/GameBLL.cs b/src/CloudGaming/Code/CloudGaming.Code/Game/GameBLL.cs index d0f8878..d1c9ce4 100644 --- a/src/CloudGaming/Code/CloudGaming.Code/Game/GameBLL.cs +++ b/src/CloudGaming/Code/CloudGaming.Code/Game/GameBLL.cs @@ -280,7 +280,7 @@ namespace CloudGaming.Code.Game #region 排行榜数据 var topList = list.Take(10).ToList(); var userIds = topList.Select(it => it.UserId).ToList(); - var userInfo = await Dao.DaoUser.Context.T_User.Where(it => userIds.Contains(it.Id)).Select(it => new { it.UserName, it.Id, it.UserIconUrl }).ToListAsync(); + var userInfo = await Dao.DaoUser.Context.T_User.Where(it => userIds.Contains(it.Id)).Select(it => new { it.NickName, it.Id, it.UserIconUrl }).ToListAsync(); var index = 1; topList.ForEach(it => { @@ -289,7 +289,7 @@ namespace CloudGaming.Code.Game { PlayTime = $"{(it.PlayTime / 60).ToString("0.##")}小时", UserIcon = user?.UserIconUrl ?? AppConfig.UserConfig.UserIconUrl, - UserName = user?.UserName ?? AppConfig.UserConfig.NickName, + UserName = user?.NickName ?? AppConfig.UserConfig.NickName, UserId = it.UserId, Ranking = index, }; @@ -302,7 +302,7 @@ namespace CloudGaming.Code.Game { PlayTime = $"0小时", Ranking = 0, - UserIcon = AppConfig.UserConfig.NickName, + UserIcon = AppConfig.UserConfig.UserIconUrl, UserId = 0, UserName = "" }; @@ -320,7 +320,7 @@ namespace CloudGaming.Code.Game userGamePlayTimeDto.Ranking = userIndex + 1; } } - userGamePlayTimeDto.UserName = UserInfo.UserName; + userGamePlayTimeDto.UserName = UserInfo.NickName; userGamePlayTimeDto.UserId = _UserId; } diff --git a/src/CloudGaming/Code/CloudGaming.Code/Other/FeedBackBLL.cs b/src/CloudGaming/Code/CloudGaming.Code/Other/FeedBackBLL.cs new file mode 100644 index 0000000..53e38bf --- /dev/null +++ b/src/CloudGaming/Code/CloudGaming.Code/Other/FeedBackBLL.cs @@ -0,0 +1,45 @@ +using CloudGaming.DtoModel.FeedBack; + +using Microsoft.IdentityModel.Tokens; + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace CloudGaming.Code.Other; + +/// +/// +/// +public class FeedBackBLL : CloudGamingBase +{ + public FeedBackBLL(IServiceProvider serviceProvider) : base(serviceProvider) + { + } + + /// + /// + /// + /// + /// + /// + public async Task SendFeedBack(FeedBackRequest feedBackRequest) + { + if (string.IsNullOrEmpty(feedBackRequest.Text)) + { + throw new ArgumentNullException("请输入反馈内容"); + } + T_User_FeedBack t_User_FeedBack = new T_User_FeedBack() + { + ContactUs = feedBackRequest.ContactUs, + CreateTime = DateTime.Now, + UpdateTime = DateTime.Now, + Text = feedBackRequest.Text, + UserId = _UserId + }; + await Dao.DaoPhone.Context.T_User_FeedBack.AddAsync(t_User_FeedBack); + await Dao.DaoPhone.Context.SaveChangesAsync(); + } +} \ No newline at end of file diff --git a/src/CloudGaming/Code/CloudGaming.Code/Other/RedemptionBLL.cs b/src/CloudGaming/Code/CloudGaming.Code/Other/RedemptionBLL.cs index 15d6a29..f54277a 100644 --- a/src/CloudGaming/Code/CloudGaming.Code/Other/RedemptionBLL.cs +++ b/src/CloudGaming/Code/CloudGaming.Code/Other/RedemptionBLL.cs @@ -81,7 +81,7 @@ namespace CloudGaming.Code.Other string m = await SendReward(code, red); return new BaseResponse(ResonseCode.Success, m, true) { }; } - + private async Task SendReward(string code, RedemptionCodeCache? red) { T_User_RedemptionUsage t_User_RedemptionUsage = new T_User_RedemptionUsage() diff --git a/src/CloudGaming/Model/CloudGaming.DtoModel/FeedBack/FeedBackRequest.cs b/src/CloudGaming/Model/CloudGaming.DtoModel/FeedBack/FeedBackRequest.cs new file mode 100644 index 0000000..1d9a7fc --- /dev/null +++ b/src/CloudGaming/Model/CloudGaming.DtoModel/FeedBack/FeedBackRequest.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace CloudGaming.DtoModel.FeedBack +{ + /// + /// + /// + public class FeedBackRequest + { + + /// + /// 内容 + /// + public virtual string? Text { get; set; } + + /// + /// 联系方式 + /// + public virtual string? ContactUs { get; set; } + } +} 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 73938bd..f721b60 100644 --- a/src/CloudGaming/Model/CloudGaming.Model/DbSqlServer/Db_Phone/CloudGamingPhoneContext.cs +++ b/src/CloudGaming/Model/CloudGaming.Model/DbSqlServer/Db_Phone/CloudGamingPhoneContext.cs @@ -158,6 +158,11 @@ public partial class CloudGamingPhoneContext : MultiTenantDbContext//DbContext /// public virtual DbSet T_UIs { get; set; } + /// + /// 用户反馈表 + /// + public virtual DbSet T_User_FeedBack { get; set; } + /// /// 用户游玩记录表。玩一次游戏记录一条数据 /// @@ -1038,6 +1043,31 @@ public partial class CloudGamingPhoneContext : MultiTenantDbContext//DbContext } }); + modelBuilder.Entity(entity => + { + entity.HasKey(e => e.Id).HasName("PK__T_User_F__3214EC07C9D16DC0"); + + entity.ToTable(tb => tb.HasComment("用户反馈表")); + + entity.Property(e => e.Id).HasComment("主键"); + entity.Property(e => e.ContactUs) + .HasMaxLength(100) + .HasComment("联系方式"); + entity.Property(e => e.CreateTime) + .HasComment("创建时间") + .HasColumnType("datetime"); + entity.Property(e => e.Text).HasComment("内容"); + entity.Property(e => e.UpdateTime) + .HasComment("修改时间") + .HasColumnType("datetime"); + entity.Property(e => e.UserId).HasComment("用户"); + //添加全局筛选器 + if (this.TenantInfo != null) + { + entity.HasQueryFilter(it => it.TenantId == this.TenantInfo.TenantId); + } + }); + modelBuilder.Entity(entity => { entity.HasKey(e => e.Id).HasName("PK__T_User_G__3214EC072692200E"); 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 new file mode 100644 index 0000000..74f3f16 --- /dev/null +++ b/src/CloudGaming/Model/CloudGaming.Model/DbSqlServer/Db_Phone/T_User_FeedBack.cs @@ -0,0 +1,41 @@ +using System; + +namespace CloudGaming.Model.DbSqlServer.Db_Phone; + +/// +/// 用户反馈表 +/// +public partial class T_User_FeedBack: MultiTenantEntity +{ + public T_User_FeedBack() { } + + /// + /// 主键 + /// + public virtual int Id { get; set; } + + /// + /// 用户 + /// + public virtual int? UserId { get; set; } + + /// + /// 内容 + /// + public virtual string? Text { get; set; } + + /// + /// 联系方式 + /// + public virtual string? ContactUs { get; set; } + + /// + /// 创建时间 + /// + public virtual DateTime CreateTime { get; set; } + + /// + /// 修改时间 + /// + public virtual DateTime UpdateTime { get; set; } +}