From dc33c722891da80b4c96cf9105551a8d7143829c Mon Sep 17 00:00:00 2001 From: milimoe Date: Fri, 25 Apr 2025 00:46:35 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=B8=80=E4=BA=9B=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- OshimaWebAPI/Controllers/FunGameController.cs | 6 +-- OshimaWebAPI/Services/RainBOTService.cs | 45 ++++++++++--------- 2 files changed, 26 insertions(+), 25 deletions(-) diff --git a/OshimaWebAPI/Controllers/FunGameController.cs b/OshimaWebAPI/Controllers/FunGameController.cs index 8aa9e83..d637f7d 100644 --- a/OshimaWebAPI/Controllers/FunGameController.cs +++ b/OshimaWebAPI/Controllers/FunGameController.cs @@ -150,7 +150,7 @@ namespace Oshima.FunGame.WebAPI.Controllers [AllowAnonymous] [HttpGet("winraterank")] - public string GetWinrateRank([FromQuery] bool? isteam = null) + public List 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; } } diff --git a/OshimaWebAPI/Services/RainBOTService.cs b/OshimaWebAPI/Services/RainBOTService.cs index 9f32a37..8370f67 100644 --- a/OshimaWebAPI/Services/RainBOTService.cs +++ b/OshimaWebAPI/Services/RainBOTService.cs @@ -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(Controller.GetWinrateRank(false)) ?? ""; - if (msg.Length > 0) + List 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(Controller.GetWinrateRank(true)) ?? ""; - if (msg.Length > 0) + List 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; }