修改获取token接口
This commit is contained in:
parent
0ce8cdf92c
commit
e20cb9d557
|
|
@ -37,7 +37,7 @@ public class PlayGameController : CloudGamingControllerBase
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
[Authorize]
|
[Authorize]
|
||||||
public async Task<BaseResponse<GetTokenModel>> GetTokenAsync([FromBody] RequestBaseModel requestBaseModel)
|
public async Task<BaseResponse<GetTokenModel>> GetTokenAsync([FromBody] GetTokenRequest requestBaseModel)
|
||||||
{
|
{
|
||||||
|
|
||||||
PlayGameBLL playGameBLL = new PlayGameBLL(ServiceProvider, JYApi);
|
PlayGameBLL playGameBLL = new PlayGameBLL(ServiceProvider, JYApi);
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,26 @@
|
||||||
|
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="AlibabaCloud.SDK.Cloudauth20190307" Version="3.3.0" />
|
||||||
|
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="8.0.10" />
|
||||||
|
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.21.0" />
|
||||||
|
<PackageReference Include="Serilog.AspNetCore" Version="8.0.2" />
|
||||||
|
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.4.0" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\..\Code\CloudGaming.Code\CloudGaming.Code.csproj" />
|
||||||
|
<ProjectReference Include="..\..\Model\CloudGaming.AppConfigModel\CloudGaming.AppConfigModel.csproj" />
|
||||||
|
<ProjectReference Include="..\..\Model\CloudGaming.DtoModel\CloudGaming.DtoModel.csproj" />
|
||||||
|
<ProjectReference Include="..\..\Model\CloudGaming.GameModel\CloudGaming.GameModel.csproj" />
|
||||||
|
<ProjectReference Include="..\..\Model\CloudGaming.Model\CloudGaming.Model.csproj" />
|
||||||
|
<ProjectReference Include="..\..\Utile\HuanMeng.DotNetCore\HuanMeng.DotNetCore.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
||||||
|
|
@ -0,0 +1,6 @@
|
||||||
|
@CloudGaming.ExtApi_HostAddress = http://localhost:5183
|
||||||
|
|
||||||
|
GET {{CloudGaming.ExtApi_HostAddress}}/weatherforecast/
|
||||||
|
Accept: application/json
|
||||||
|
|
||||||
|
###
|
||||||
|
|
@ -0,0 +1,33 @@
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
|
||||||
|
namespace CloudGaming.ExtApi.Controllers
|
||||||
|
{
|
||||||
|
[ApiController]
|
||||||
|
[Route("[controller]")]
|
||||||
|
public class WeatherForecastController : ControllerBase
|
||||||
|
{
|
||||||
|
private static readonly string[] Summaries = new[]
|
||||||
|
{
|
||||||
|
"Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
|
||||||
|
};
|
||||||
|
|
||||||
|
private readonly ILogger<WeatherForecastController> _logger;
|
||||||
|
|
||||||
|
public WeatherForecastController(ILogger<WeatherForecastController> logger)
|
||||||
|
{
|
||||||
|
_logger = logger;
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpGet(Name = "GetWeatherForecast")]
|
||||||
|
public IEnumerable<WeatherForecast> Get()
|
||||||
|
{
|
||||||
|
return Enumerable.Range(1, 5).Select(index => new WeatherForecast
|
||||||
|
{
|
||||||
|
Date = DateOnly.FromDateTime(DateTime.Now.AddDays(index)),
|
||||||
|
TemperatureC = Random.Shared.Next(-20, 55),
|
||||||
|
Summary = Summaries[Random.Shared.Next(Summaries.Length)]
|
||||||
|
})
|
||||||
|
.ToArray();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
139
src/CloudGaming/Api/CloudGaming.ExtApi/Program.cs
Normal file
139
src/CloudGaming/Api/CloudGaming.ExtApi/Program.cs
Normal file
|
|
@ -0,0 +1,139 @@
|
||||||
|
using CloudGaming.Code.AppExtend;
|
||||||
|
using CloudGaming.Code.DataAccess.MultiTenantUtil;
|
||||||
|
using CloudGaming.Code.Filter;
|
||||||
|
|
||||||
|
using HuanMeng.DotNetCore.MiddlewareExtend;
|
||||||
|
using HuanMeng.DotNetCore.SwaggerUtile;
|
||||||
|
|
||||||
|
using Microsoft.AspNetCore.Authentication.JwtBearer;
|
||||||
|
|
||||||
|
using Microsoft.OpenApi.Models;
|
||||||
|
|
||||||
|
using Newtonsoft.Json.Serialization;
|
||||||
|
|
||||||
|
using Serilog;
|
||||||
|
|
||||||
|
using System.Diagnostics;
|
||||||
|
using System.Reflection;
|
||||||
|
|
||||||
|
var builder = WebApplication.CreateBuilder(args);
|
||||||
|
|
||||||
|
#region 日志
|
||||||
|
// Add services to the container.
|
||||||
|
builder.Host.UseSerilog((context, services, configuration) => configuration
|
||||||
|
.ReadFrom.Configuration(context.Configuration)
|
||||||
|
.ReadFrom.Services(services)
|
||||||
|
.Enrich.FromLogContext());
|
||||||
|
|
||||||
|
builder.Services.AddSingleton(typeof(ILogger<CloudGamingBase>), serviceProvider =>
|
||||||
|
{
|
||||||
|
var loggerFactory = serviceProvider.GetRequiredService<ILoggerFactory>();
|
||||||
|
return loggerFactory.CreateLogger<CloudGamingBase>();
|
||||||
|
});
|
||||||
|
//
|
||||||
|
builder.Services.AddSingleton(typeof(ILogger<ExceptionMiddleware>), serviceProvider =>
|
||||||
|
{
|
||||||
|
var loggerFactory = serviceProvider.GetRequiredService<ILoggerFactory>();
|
||||||
|
return loggerFactory.CreateLogger<ExceptionMiddleware>();
|
||||||
|
});
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
builder.Services.AddHttpContextAccessor(); //添加httpContext注入访问
|
||||||
|
#region 返回数据解析
|
||||||
|
//builder.Services.AddControllers();
|
||||||
|
builder.Services.AddControllers(options =>
|
||||||
|
{
|
||||||
|
})
|
||||||
|
.AddNewtonsoftJson(options =>
|
||||||
|
{
|
||||||
|
// 配置 Newtonsoft.Json 选项
|
||||||
|
options.SerializerSettings.ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore; // 忽略循环引用
|
||||||
|
options.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver();// 首字母小写(驼峰样式)
|
||||||
|
//options.SerializerSettings.ContractResolver = new LanguageContractResolver(builder.Services);
|
||||||
|
options.SerializerSettings.DateFormatString = "yyyy-MM-dd HH:mm:ss";// 时间格式化
|
||||||
|
options.SerializerSettings.Formatting = Newtonsoft.Json.Formatting.None;
|
||||||
|
});
|
||||||
|
//CustomResultFilter
|
||||||
|
//builder.Services.AddSingleton<ObjectResultExecutor, CustomObjectResultExecutor>();
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
|
||||||
|
builder.Services.AddEndpointsApiExplorer();
|
||||||
|
builder.Services.AddSwaggerGen(c =>
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
string description = "";
|
||||||
|
var filePath = Path.GetFullPath(".versionDescribe");
|
||||||
|
if (File.Exists(filePath))
|
||||||
|
{
|
||||||
|
description = File.ReadAllText(filePath);
|
||||||
|
}
|
||||||
|
c.SwaggerDoc("v1", new OpenApiInfo { Title = "蒸汽云游戏扩展付", Version = "0.0.1", Description = description });
|
||||||
|
foreach (var assemblies in AppDomain.CurrentDomain.GetAssemblies())
|
||||||
|
{
|
||||||
|
// 添加 XML 注释文件路径
|
||||||
|
var xmlFile = $"{assemblies.GetName().Name}.xml";
|
||||||
|
var xmlPath = Path.Combine(AppContext.BaseDirectory, xmlFile);
|
||||||
|
if (File.Exists(xmlPath))
|
||||||
|
{
|
||||||
|
c.IncludeXmlComments(xmlPath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
c.ParameterFilter<LowercaseParameterFilter>();
|
||||||
|
c.RequestBodyFilter<LowercaseRequestFilter>();
|
||||||
|
});
|
||||||
|
builder.AddAppConfigClient();
|
||||||
|
|
||||||
|
var app = builder.Build();
|
||||||
|
|
||||||
|
// Configure the HTTP request pipeline.
|
||||||
|
//if (app.Environment.IsDevelopment())
|
||||||
|
//{
|
||||||
|
app.UseSwagger();
|
||||||
|
app.UseSwaggerUI(c =>
|
||||||
|
{
|
||||||
|
|
||||||
|
c.EnableDeepLinking();
|
||||||
|
c.DefaultModelsExpandDepth(3);
|
||||||
|
c.DefaultModelExpandDepth(3);
|
||||||
|
c.EnableFilter("true");
|
||||||
|
//c.RoutePrefix = string.Empty;
|
||||||
|
c.SwaggerEndpoint("/swagger/v1/swagger.json", "蒸汽云游戏扩展 API V1");
|
||||||
|
// 使用自定义CSS
|
||||||
|
c.InjectStylesheet("/custom.css");
|
||||||
|
});
|
||||||
|
//}
|
||||||
|
|
||||||
|
app.UseAuthorization();
|
||||||
|
//数据库中间件
|
||||||
|
app.UseMultiTenant();
|
||||||
|
app.MapControllers();
|
||||||
|
app.UseMiddlewareAll();
|
||||||
|
#region 默认请求
|
||||||
|
app.MapGet("/", () => "请求成功").WithName("默认请求");
|
||||||
|
|
||||||
|
var startDateTime = DateTime.Now;
|
||||||
|
var InformationalVersion = Assembly.GetEntryAssembly().GetCustomAttribute<AssemblyInformationalVersionAttribute>().InformationalVersion;
|
||||||
|
Console.WriteLine($"version:{InformationalVersion}");
|
||||||
|
app.MapGet("/system", () =>
|
||||||
|
{
|
||||||
|
|
||||||
|
using Process currentProcess = Process.GetCurrentProcess();
|
||||||
|
// CPU使用率 (一般是一个0-100之间的值,但实际是时间占比,需要转换)
|
||||||
|
double cpuUsage = currentProcess.TotalProcessorTime.TotalMilliseconds / Environment.TickCount * 100;
|
||||||
|
// 已用内存 (字节)
|
||||||
|
long memoryUsage = currentProcess.WorkingSet64;
|
||||||
|
return new
|
||||||
|
{
|
||||||
|
msg = $"系统信息:启动时间:{startDateTime.ToString("yyyy-MM-dd HH:mm:ss")},已安全运行时间:{DateTime.Now.Subtract(startDateTime).TotalMinutes.ToString("0.##")}分钟",
|
||||||
|
|
||||||
|
startDateTime,
|
||||||
|
MemoryUsage = $"{memoryUsage / (1024.0 * 1024.0):F2}MB",
|
||||||
|
CPUUsage = $"{cpuUsage:F2}%"
|
||||||
|
|
||||||
|
};
|
||||||
|
}).WithName("获取系统数据");
|
||||||
|
#endregion
|
||||||
|
app.Run();
|
||||||
|
|
@ -0,0 +1,31 @@
|
||||||
|
{
|
||||||
|
"$schema": "http://json.schemastore.org/launchsettings.json",
|
||||||
|
"iisSettings": {
|
||||||
|
"windowsAuthentication": false,
|
||||||
|
"anonymousAuthentication": true,
|
||||||
|
"iisExpress": {
|
||||||
|
"applicationUrl": "http://localhost:4142",
|
||||||
|
"sslPort": 0
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"profiles": {
|
||||||
|
"http": {
|
||||||
|
"commandName": "Project",
|
||||||
|
"dotnetRunMessages": true,
|
||||||
|
"launchBrowser": true,
|
||||||
|
"launchUrl": "swagger",
|
||||||
|
"applicationUrl": "http://localhost:5183",
|
||||||
|
"environmentVariables": {
|
||||||
|
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"IIS Express": {
|
||||||
|
"commandName": "IISExpress",
|
||||||
|
"launchBrowser": true,
|
||||||
|
"launchUrl": "swagger",
|
||||||
|
"environmentVariables": {
|
||||||
|
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
13
src/CloudGaming/Api/CloudGaming.ExtApi/WeatherForecast.cs
Normal file
13
src/CloudGaming/Api/CloudGaming.ExtApi/WeatherForecast.cs
Normal file
|
|
@ -0,0 +1,13 @@
|
||||||
|
namespace CloudGaming.ExtApi
|
||||||
|
{
|
||||||
|
public class WeatherForecast
|
||||||
|
{
|
||||||
|
public DateOnly Date { get; set; }
|
||||||
|
|
||||||
|
public int TemperatureC { get; set; }
|
||||||
|
|
||||||
|
public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
|
||||||
|
|
||||||
|
public string? Summary { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,26 @@
|
||||||
|
{
|
||||||
|
"Logging": {
|
||||||
|
"LogLevel": {
|
||||||
|
"Default": "Information",
|
||||||
|
"Microsoft.AspNetCore": "Warning"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"AgileConfig": {
|
||||||
|
"appId": "CloudGaming",
|
||||||
|
"secret": "95BB717C61D1ECB0E9FB82C932CC77FF",
|
||||||
|
"nodes": "http://124.220.55.158:94", //多个节点使用逗号分隔
|
||||||
|
"url": "http://124.220.55.158:94",
|
||||||
|
"env": "DEV",
|
||||||
|
"name": "payClient",
|
||||||
|
"UserName": "admin",
|
||||||
|
"Password": "dbt@com@1234"
|
||||||
|
},
|
||||||
|
//服务器配置
|
||||||
|
"Kestrel": {
|
||||||
|
"Endpoints": {
|
||||||
|
"Http": {
|
||||||
|
"Url": "http://*:804"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
72
src/CloudGaming/Api/CloudGaming.ExtApi/appsettings.json
Normal file
72
src/CloudGaming/Api/CloudGaming.ExtApi/appsettings.json
Normal file
|
|
@ -0,0 +1,72 @@
|
||||||
|
{
|
||||||
|
"Logging": {
|
||||||
|
"LogLevel": {
|
||||||
|
"Default": "Information",
|
||||||
|
"Microsoft.AspNetCore": "Warning"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"AllowedHosts": "*",
|
||||||
|
"Serilog": {
|
||||||
|
"Using": [ "Serilog.Sinks.Console", "Serilog.Sinks.File" ],
|
||||||
|
"MinimumLevel": {
|
||||||
|
"Default": "Information",
|
||||||
|
"Override": {
|
||||||
|
"Microsoft": "Warning",
|
||||||
|
"System": "Warning"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"WriteTo": [
|
||||||
|
{ "Name": "Console" },
|
||||||
|
{
|
||||||
|
"Name": "File",
|
||||||
|
"Args": {
|
||||||
|
"path": "../output/extlogs/info/log-.txt",
|
||||||
|
"rollingInterval": "Day",
|
||||||
|
"restrictedToMinimumLevel": "Information", //写入日志的级别
|
||||||
|
"shared": true
|
||||||
|
//"outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [{Level}] {Message}{NewLine}{Exception}"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Name": "File",
|
||||||
|
"Args": {
|
||||||
|
"path": "../output/extlogs/error/log-.txt",
|
||||||
|
"rollingInterval": "Day", //日志文件按天滚动生成。
|
||||||
|
"restrictedToMinimumLevel": "Error", //写入日志的级别 //包括 Verbose、Debug、Information、Warning、Error 和 Fatal
|
||||||
|
"shared": true //不占用文件
|
||||||
|
// "outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [{Level}] {Message}{NewLine}{Exception}"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Name": "File",
|
||||||
|
"Args": {
|
||||||
|
"path": "../output/extlogs/debug/log-.txt",
|
||||||
|
"rollingInterval": "Day", //日志文件按天滚动生成。
|
||||||
|
"restrictedToMinimumLevel": "Debug", //写入日志的级别 //包括 Verbose、Debug、Information、Warning、Error 和 Fatal
|
||||||
|
"shared": true //不占用文件
|
||||||
|
// "outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [{Level}] {Message}{NewLine}{Exception}"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"Enrich": [ "FromLogContext", "WithMachineName", "WithThreadId" ]
|
||||||
|
},
|
||||||
|
"AgileConfig": {
|
||||||
|
"appId": "CloudGaming",
|
||||||
|
"secret": "95BB717C61D1ECB0E9FB82C932CC77FF",
|
||||||
|
"nodes": "http://124.220.55.158:94", //多个节点使用逗号分隔
|
||||||
|
"url": "http://124.220.55.158:94",
|
||||||
|
"env": "TEST",
|
||||||
|
"name": "payClient",
|
||||||
|
"UserName": "admin",
|
||||||
|
"Password": "dbt@com@1234"
|
||||||
|
},
|
||||||
|
//服务器配置
|
||||||
|
"Kestrel": {
|
||||||
|
"Endpoints": {
|
||||||
|
"Http": {
|
||||||
|
"Url": "http://*:80"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -19,7 +19,7 @@
|
||||||
"Kestrel": {
|
"Kestrel": {
|
||||||
"Endpoints": {
|
"Endpoints": {
|
||||||
"Http": {
|
"Http": {
|
||||||
"Url": "http://*:802"
|
"Url": "http://*:803"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -40,6 +40,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CloudGaming.PayApi", "Api\C
|
||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CloudGaming.AppConfigModel", "Model\CloudGaming.AppConfigModel\CloudGaming.AppConfigModel.csproj", "{58FD9A2F-E1FC-494C-9484-D5BCA8511EBE}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CloudGaming.AppConfigModel", "Model\CloudGaming.AppConfigModel\CloudGaming.AppConfigModel.csproj", "{58FD9A2F-E1FC-494C-9484-D5BCA8511EBE}"
|
||||||
EndProject
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CloudGaming.ExtApi", "Api\CloudGaming.ExtApi\CloudGaming.ExtApi.csproj", "{64997DCB-487F-4617-A43C-10AD78B91B29}"
|
||||||
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Any CPU = Debug|Any CPU
|
Debug|Any CPU = Debug|Any CPU
|
||||||
|
|
@ -86,6 +88,10 @@ Global
|
||||||
{58FD9A2F-E1FC-494C-9484-D5BCA8511EBE}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{58FD9A2F-E1FC-494C-9484-D5BCA8511EBE}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{58FD9A2F-E1FC-494C-9484-D5BCA8511EBE}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{58FD9A2F-E1FC-494C-9484-D5BCA8511EBE}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{58FD9A2F-E1FC-494C-9484-D5BCA8511EBE}.Release|Any CPU.Build.0 = Release|Any CPU
|
{58FD9A2F-E1FC-494C-9484-D5BCA8511EBE}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{64997DCB-487F-4617-A43C-10AD78B91B29}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{64997DCB-487F-4617-A43C-10AD78B91B29}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{64997DCB-487F-4617-A43C-10AD78B91B29}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{64997DCB-487F-4617-A43C-10AD78B91B29}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
|
|
@ -101,6 +107,7 @@ Global
|
||||||
{830841B9-E013-4FD5-8D31-D85545870C1C} = {9F7EF36C-17BB-4F93-927E-F462FE3C9337}
|
{830841B9-E013-4FD5-8D31-D85545870C1C} = {9F7EF36C-17BB-4F93-927E-F462FE3C9337}
|
||||||
{452D87B5-A7E0-4EBD-9CF2-1AFF5941065B} = {51CB40D2-99F5-43E8-95B4-3A75C91736A6}
|
{452D87B5-A7E0-4EBD-9CF2-1AFF5941065B} = {51CB40D2-99F5-43E8-95B4-3A75C91736A6}
|
||||||
{58FD9A2F-E1FC-494C-9484-D5BCA8511EBE} = {A3F00FB0-49D6-48B1-99D9-4619634DF8D9}
|
{58FD9A2F-E1FC-494C-9484-D5BCA8511EBE} = {A3F00FB0-49D6-48B1-99D9-4619634DF8D9}
|
||||||
|
{64997DCB-487F-4617-A43C-10AD78B91B29} = {51CB40D2-99F5-43E8-95B4-3A75C91736A6}
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||||
SolutionGuid = {1D299D92-FA27-47A0-8D78-43D1FAFE7628}
|
SolutionGuid = {1D299D92-FA27-47A0-8D78-43D1FAFE7628}
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ public class PlayGameBLL : CloudGamingBase
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="requestBaseModel"></param>
|
/// <param name="requestBaseModel"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public async Task<BaseResponse<GetTokenModel>> GetTokenAsync(RequestBaseModel requestBaseModel)
|
public async Task<BaseResponse<GetTokenModel>> GetTokenAsync(GetTokenRequest requestBaseModel)
|
||||||
{
|
{
|
||||||
if (_UserId == 0)
|
if (_UserId == 0)
|
||||||
{
|
{
|
||||||
|
|
@ -38,10 +38,29 @@ public class PlayGameBLL : CloudGamingBase
|
||||||
}
|
}
|
||||||
//requestBaseModel.Sn = Guid.NewGuid().ToString();
|
//requestBaseModel.Sn = Guid.NewGuid().ToString();
|
||||||
JYRequestParameter requestParameter = new JYRequestParameter(requestBaseModel.Sn, _UserId);
|
JYRequestParameter requestParameter = new JYRequestParameter(requestBaseModel.Sn, _UserId);
|
||||||
|
// 检查游戏是否存在
|
||||||
|
var gameCache = Cache.GameEntityCache;
|
||||||
|
var gameInfo = gameCache[requestBaseModel.GameId];
|
||||||
|
if (gameInfo == null)
|
||||||
|
{
|
||||||
|
throw MessageBox.ErrorShow("游戏不存在");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 检查用户钻石是否足够
|
||||||
|
if (UserInfo.Diamond <= 0)
|
||||||
|
{
|
||||||
|
throw MessageBox.Show(ResponseCode.NotMoney, "钻石不足");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
var data = await JYApi.GetToken(requestParameter);
|
var data = await JYApi.GetToken(requestParameter);
|
||||||
|
|
||||||
//Console.WriteLine(jyResponseData.TotalMilliseconds);
|
//Console.WriteLine(jyResponseData.TotalMilliseconds);
|
||||||
if (data.IsSuccess)
|
if (data.IsSuccess)
|
||||||
{
|
{
|
||||||
|
// 获取用户和游戏信息
|
||||||
|
var userInfo = UserInfo;
|
||||||
|
PlayGameUserInfo gameInfoCache = await PlayGameExtend.GetPlayGameUserInfoCacheAsync(this, userInfo, gameInfo);
|
||||||
return new BaseResponse<GetTokenModel>(ResponseCode.Success, "", data?.Data ?? new GetTokenModel());
|
return new BaseResponse<GetTokenModel>(ResponseCode.Success, "", data?.Data ?? new GetTokenModel());
|
||||||
}
|
}
|
||||||
throw data.ToMessageBox();
|
throw data.ToMessageBox();
|
||||||
|
|
@ -101,8 +120,12 @@ public class PlayGameBLL : CloudGamingBase
|
||||||
HangUpTimer = 300, // 挂机时间 5 分钟
|
HangUpTimer = 300, // 挂机时间 5 分钟
|
||||||
ModelName = playGameRequest.ModelName,
|
ModelName = playGameRequest.ModelName,
|
||||||
StartResolution = "1080P",
|
StartResolution = "1080P",
|
||||||
Cpu = playGameRequest.Cpu,
|
|
||||||
};
|
};
|
||||||
|
if (!string.IsNullOrEmpty(playGameRequest.Cpu))
|
||||||
|
{
|
||||||
|
playGameSettings.Cpu = playGameRequest.Cpu;
|
||||||
|
}
|
||||||
//设置开始游戏数据
|
//设置开始游戏数据
|
||||||
gameInfoCache.InitStartPlayGame(playGameSettings);
|
gameInfoCache.InitStartPlayGame(playGameSettings);
|
||||||
// 调用鲸云游戏启动接口
|
// 调用鲸云游戏启动接口
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@ namespace CloudGaming.Code.Game
|
||||||
/// <param name="userInfo"></param>
|
/// <param name="userInfo"></param>
|
||||||
/// <param name="gameInfo"></param>
|
/// <param name="gameInfo"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static async Task<PlayGameUserInfo> GetPlayGameUserInfoCacheAsync(CloudGamingBase cloudGamingBase, UserInfo userInfo, GameInfo gameInfo)
|
public static async Task<PlayGameUserInfo> GetPlayGameUserInfoCacheAsync(CloudGamingBase cloudGamingBase, UserInfo userInfo, GameInfo gameInfo, IJYApiRespnse? jYApiRespnse = null)
|
||||||
{
|
{
|
||||||
var redisGameKey = GetPlayGameKey(gameInfo.GameId, userInfo.UserId);
|
var redisGameKey = GetPlayGameKey(gameInfo.GameId, userInfo.UserId);
|
||||||
var gameInfoCache = await cloudGamingBase.RedisCache.StringGetAsync<PlayGameUserInfo>(redisGameKey);
|
var gameInfoCache = await cloudGamingBase.RedisCache.StringGetAsync<PlayGameUserInfo>(redisGameKey);
|
||||||
|
|
@ -40,6 +40,18 @@ namespace CloudGaming.Code.Game
|
||||||
SessionId = Guid.NewGuid().ToString("N"),
|
SessionId = Guid.NewGuid().ToString("N"),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
if (jYApiRespnse != null)
|
||||||
|
{
|
||||||
|
if (gameInfoCache.GameUserOperation == null)
|
||||||
|
{
|
||||||
|
gameInfoCache.GameUserOperation = new List<PlayGameUserOperation>();
|
||||||
|
}
|
||||||
|
gameInfoCache.GameUserOperation.Add(new PlayGameUserOperation(jYApiRespnse)
|
||||||
|
{
|
||||||
|
Content = "获取token",
|
||||||
|
OperationDateTime = DateTime.Now,
|
||||||
|
});
|
||||||
|
}
|
||||||
return gameInfoCache;
|
return gameInfoCache;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,21 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace CloudGaming.Code.Game;
|
||||||
|
|
||||||
|
public class PlayGameService(IServiceProvider serviceProvider) : IHostedService
|
||||||
|
{
|
||||||
|
public Task StartAsync(CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
//AppConfigurationExtend.AppConfigs.Select(it => it.Value).Where(it => it.DomainName != "default").ToList();
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Task StopAsync(CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,19 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace CloudGaming.DtoModel.PlayGame
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 获取token
|
||||||
|
/// </summary>
|
||||||
|
public class GetTokenRequest : RequestBaseModel
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 游戏Id
|
||||||
|
/// </summary>
|
||||||
|
public string GameId { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -18,7 +18,7 @@ namespace CloudGaming.DtoModel.PlayGame
|
||||||
}
|
}
|
||||||
public PlayGameUserOperation(IJYApiRespnse? jYApiRespnse)
|
public PlayGameUserOperation(IJYApiRespnse? jYApiRespnse)
|
||||||
{
|
{
|
||||||
RequestContent = jYApiRespnse?.ResponseStr;
|
RequestContent = jYApiRespnse?.RequestStr;
|
||||||
ResponseContent = jYApiRespnse?.ResponseContent;
|
ResponseContent = jYApiRespnse?.ResponseContent;
|
||||||
TotalMilliseconds = jYApiRespnse?.TotalMilliseconds;
|
TotalMilliseconds = jYApiRespnse?.TotalMilliseconds;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user