修复一些问题

This commit is contained in:
milimoe 2025-04-25 00:46:35 +08:00
parent 5a503f8fc6
commit dc33c72289
Signed by: milimoe
GPG Key ID: 05D280912DA6C69E
2 changed files with 26 additions and 25 deletions

View File

@ -150,7 +150,7 @@ namespace Oshima.FunGame.WebAPI.Controllers
[AllowAnonymous]
[HttpGet("winraterank")]
public string GetWinrateRank([FromQuery] bool? isteam = null)
public List<string> GetWinrateRank([FromQuery] bool? isteam = null)
{
bool team = isteam ?? false;
if (team)
@ -169,7 +169,7 @@ namespace Oshima.FunGame.WebAPI.Controllers
builder.AppendLine($"MVP次数{stats.MVPs}");
strings.Add(builder.ToString());
}
return NetworkUtility.JsonSerialize(strings);
return strings;
}
else
{
@ -189,7 +189,7 @@ namespace Oshima.FunGame.WebAPI.Controllers
builder.AppendLine($"MVP次数{stats.MVPs}");
strings.Add(builder.ToString());
}
return NetworkUtility.JsonSerialize(strings);
return strings;
}
}

View File

@ -48,32 +48,33 @@ namespace Oshima.FunGame.WebAPI.Services
bool result = true;
try
{
string openid = "";
long uid = 0;
if (e is null)
{
return false;
}
string isGroup = e.IsGroup ? "群聊" : "私聊";
string openid = e.AuthorOpenId;
long uid = 0;
openid = e.AuthorOpenId;
if (MemoryCache.TryGetValue(openid, out object? value) && value is long uidTemp)
if (openid != "")
{
uid = uidTemp;
}
else
{
using SQLHelper? sql = Factory.OpenFactory.GetSQLHelper();
if (sql != null)
if (MemoryCache.TryGetValue(openid, out object? value) && value is long uidTemp)
{
sql.ExecuteDataSet(FunGameService.Select_CheckAutoKey(sql, openid));
if (sql.Success)
uid = uidTemp;
}
else
{
using SQLHelper? sql = Factory.OpenFactory.GetSQLHelper();
if (sql != null)
{
User user = Factory.GetUser(sql.DataSet);
uid = user.Id;
MemoryCache.Set(openid, uid, TimeSpan.FromMinutes(10));
sql.ExecuteDataSet(FunGameService.Select_CheckAutoKey(sql, openid));
if (sql.Success)
{
User user = Factory.GetUser(sql.DataSet);
uid = user.Id;
MemoryCache.Set(openid, uid, TimeSpan.FromMinutes(10));
}
}
}
}
@ -345,20 +346,20 @@ namespace Oshima.FunGame.WebAPI.Services
if (e.Detail.StartsWith("查个人胜率", StringComparison.CurrentCultureIgnoreCase))
{
string msg = NetworkUtility.JsonDeserialize<string>(Controller.GetWinrateRank(false)) ?? "";
if (msg.Length > 0)
List<string> msgs = Controller.GetWinrateRank();
if (msgs.Count > 0)
{
await SendAsync(e, "查个人胜率", string.Join("\r\n\r\n", msg));
await SendAsync(e, "查个人胜率", string.Join("\r\n\r\n", msgs));
}
return result;
}
if (e.Detail.StartsWith("查团队胜率", StringComparison.CurrentCultureIgnoreCase))
{
string msg = NetworkUtility.JsonDeserialize<string>(Controller.GetWinrateRank(true)) ?? "";
if (msg.Length > 0)
List<string> msgs = Controller.GetWinrateRank(true);
if (msgs.Count > 0)
{
await SendAsync(e, "查团队胜率", string.Join("\r\n\r\n", msg));
await SendAsync(e, "查团队胜率", string.Join("\r\n\r\n", msgs));
}
return result;
}