添加反馈接口

This commit is contained in:
zpc 2024-11-19 19:33:57 +08:00
parent 3389c83249
commit e75ab989a8
8 changed files with 183 additions and 6 deletions

View File

@ -2,4 +2,5 @@
1. 增加兑换码接口测试兑换码test
2. 增加首页排行榜接口
3. 增加游玩历史接口
4. 增加游戏时长接
4. 增加游戏时长接口
5. 增加反馈接口SendFeedBack

View File

@ -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;
/// <summary>
/// 反馈
/// </summary>
public class FeedBackController : CloudGamingControllerBase
{
public FeedBackController(IServiceProvider _serviceProvider) : base(_serviceProvider)
{
}
/// <summary>
/// 反馈接口
/// </summary>
/// <param name="feedBackRequest"></param>
/// <returns></returns>
/// <exception cref="ArgumentNullException"></exception>
[HttpPost]
[Message("反馈成功!")]
public async Task<bool> SendFeedBack([FromBody] FeedBackRequest feedBackRequest)
{
FeedBackBLL feedBackBLL = new FeedBackBLL(ServiceProvider);
await feedBackBLL.SendFeedBack(feedBackRequest);
return true;
}
}

View File

@ -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;
}

View File

@ -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;
/// <summary>
///
/// </summary>
public class FeedBackBLL : CloudGamingBase
{
public FeedBackBLL(IServiceProvider serviceProvider) : base(serviceProvider)
{
}
/// <summary>
///
/// </summary>
/// <param name="feedBackRequest"></param>
/// <returns></returns>
/// <exception cref="ArgumentNullException"></exception>
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();
}
}

View File

@ -81,7 +81,7 @@ namespace CloudGaming.Code.Other
string m = await SendReward(code, red);
return new BaseResponse<bool>(ResonseCode.Success, m, true) { };
}
private async Task<string> SendReward(string code, RedemptionCodeCache? red)
{
T_User_RedemptionUsage t_User_RedemptionUsage = new T_User_RedemptionUsage()

View File

@ -0,0 +1,25 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CloudGaming.DtoModel.FeedBack
{
/// <summary>
///
/// </summary>
public class FeedBackRequest
{
/// <summary>
/// 内容
/// </summary>
public virtual string? Text { get; set; }
/// <summary>
/// 联系方式
/// </summary>
public virtual string? ContactUs { get; set; }
}
}

View File

@ -158,6 +158,11 @@ public partial class CloudGamingPhoneContext : MultiTenantDbContext//DbContext
/// </summary>
public virtual DbSet<T_UIs> T_UIs { get; set; }
/// <summary>
/// 用户反馈表
/// </summary>
public virtual DbSet<T_User_FeedBack> T_User_FeedBack { get; set; }
/// <summary>
/// 用户游玩记录表。玩一次游戏记录一条数据
/// </summary>
@ -1038,6 +1043,31 @@ public partial class CloudGamingPhoneContext : MultiTenantDbContext//DbContext
}
});
modelBuilder.Entity<T_User_FeedBack>(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<T_User_GameList>(entity =>
{
entity.HasKey(e => e.Id).HasName("PK__T_User_G__3214EC072692200E");

View File

@ -0,0 +1,41 @@
using System;
namespace CloudGaming.Model.DbSqlServer.Db_Phone;
/// <summary>
/// 用户反馈表
/// </summary>
public partial class T_User_FeedBack: MultiTenantEntity
{
public T_User_FeedBack() { }
/// <summary>
/// 主键
/// </summary>
public virtual int Id { get; set; }
/// <summary>
/// 用户
/// </summary>
public virtual int? UserId { get; set; }
/// <summary>
/// 内容
/// </summary>
public virtual string? Text { get; set; }
/// <summary>
/// 联系方式
/// </summary>
public virtual string? ContactUs { get; set; }
/// <summary>
/// 创建时间
/// </summary>
public virtual DateTime CreateTime { get; set; }
/// <summary>
/// 修改时间
/// </summary>
public virtual DateTime UpdateTime { get; set; }
}