From 46d1d64e1c3c8a8027b1710309200c2ee8522d44 Mon Sep 17 00:00:00 2001 From: milimoe Date: Mon, 14 Oct 2024 00:37:49 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=20UserDaily=20API?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- OshimaCore/Controllers/FunGameController.cs | 8 +++++ OshimaCore/Controllers/TestController.cs | 19 ++++++++++++ OshimaCore/Controllers/UserDailyController.cs | 8 ++--- OshimaCore/OshimaWebAPI.cs | 29 ++++--------------- 4 files changed, 36 insertions(+), 28 deletions(-) create mode 100644 OshimaCore/Controllers/TestController.cs diff --git a/OshimaCore/Controllers/FunGameController.cs b/OshimaCore/Controllers/FunGameController.cs index 1027cda..7f1e444 100644 --- a/OshimaCore/Controllers/FunGameController.cs +++ b/OshimaCore/Controllers/FunGameController.cs @@ -3,6 +3,8 @@ using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Logging; using Milimoe.FunGame.Core.Api.Utility; using Milimoe.FunGame.Core.Entity; +using Oshima.Core.Configs; +using Oshima.Core.Models; using Oshima.Core.Utils; namespace Oshima.Core.Controllers @@ -74,5 +76,11 @@ namespace Oshima.Core.Controllers { return NetworkUtility.JsonSerialize($"Your Name received successfully: {name}."); } + + [HttpPost("bind")] + public string Post([FromBody] BindQQ b) + { + return NetworkUtility.JsonSerialize("绑定失败,请稍后再试。"); + } } } diff --git a/OshimaCore/Controllers/TestController.cs b/OshimaCore/Controllers/TestController.cs new file mode 100644 index 0000000..a3c31e4 --- /dev/null +++ b/OshimaCore/Controllers/TestController.cs @@ -0,0 +1,19 @@ +锘縰sing Microsoft.AspNetCore.Mvc; +using Microsoft.Extensions.Logging; +using Milimoe.FunGame.Core.Api.Utility; + +namespace Oshima.Core.Controllers +{ + [ApiController] + [Route("[controller]")] + public class TestController(ILogger logger) : ControllerBase + { + private readonly ILogger _logger = logger; + + [HttpGet("gethmacsha512")] + public string UseHMACSHA512(string msg, string key) + { + return msg.Encrypt(key); + } + } +} diff --git a/OshimaCore/Controllers/UserDailyController.cs b/OshimaCore/Controllers/UserDailyController.cs index 74d18c7..5c8088e 100644 --- a/OshimaCore/Controllers/UserDailyController.cs +++ b/OshimaCore/Controllers/UserDailyController.cs @@ -13,19 +13,19 @@ namespace Oshima.Core.Controllers { private readonly ILogger _logger = logger; - [HttpGet("{user_id}", Name = "GetUserDaily")] + [HttpPost("get/{user_id}", Name = "GetUserDaily")] public UserDaily Get(long user_id) { return UserDailyUtil.GetUserDaily(user_id); } - [HttpGet("v/{user_id}", Name = "ViewUserDaily")] + [HttpGet("view/{user_id}", Name = "ViewUserDaily")] public UserDaily View(long user_id) { return UserDailyUtil.ViewUserDaily(user_id); } - [HttpGet("open/{open_id}", Name = "GetOpenUserDaily")] + [HttpPost("open/{open_id}", Name = "GetOpenUserDaily")] public UserDaily Open(string open_id) { if (QQOpenID.QQAndOpenID.TryGetValue(open_id, out long qq) && qq != 0) @@ -35,7 +35,7 @@ namespace Oshima.Core.Controllers return new(0, 0, "你似乎没有绑定QQ呢,请先发送【绑定+QQ号】(如:绑定123456789)再使用哦!"); } - [HttpGet("r/{user_id}", Name = "RemoveUserDaily")] + [HttpPost("remove/{user_id}", Name = "RemoveUserDaily")] public string Remove(long user_id) { return UserDailyUtil.RemoveDaily(user_id); diff --git a/OshimaCore/OshimaWebAPI.cs b/OshimaCore/OshimaWebAPI.cs index 208cb59..0963d3c 100644 --- a/OshimaCore/OshimaWebAPI.cs +++ b/OshimaCore/OshimaWebAPI.cs @@ -1,5 +1,4 @@ 锘縰sing Milimoe.FunGame.Core.Library.Common.Addon; -using Milimoe.FunGame.Core.Library.Exception; using Oshima.Core.Configs; using Oshima.Core.Utils; using Oshima.FunGame.OshimaModules; @@ -22,7 +21,7 @@ namespace Oshima.Core.WebAPI if (input.Length >= 4 && input[..4].Equals(".osm", StringComparison.CurrentCultureIgnoreCase)) { //MasterCommand.Execute(read, GeneralSettings.Master, false, GeneralSettings.Master, false); - WriteLine("璇曞浘浣跨敤 .osm 鎸囦护锛" + input); + Controller.WriteLine("璇曞浘浣跨敤 .osm 鎸囦护锛" + input); } } @@ -59,8 +58,9 @@ namespace Oshima.Core.WebAPI // 娓呯┖杩愬娍 Daily.ClearDaily(); Console.ForegroundColor = ConsoleColor.Magenta; - Console.WriteLine("宸查噸缃墍鏈変汉鐨勪粖鏃ヨ繍鍔裤"); + Console.WriteLine("\r宸查噸缃墍鏈変汉鐨勪粖鏃ヨ繍鍔裤"); Console.ForegroundColor = ConsoleColor.Gray; + Console.Write("\r> "); } if (now.Hour == 0 && now.Minute == 1) { @@ -71,31 +71,12 @@ namespace Oshima.Core.WebAPI catch (Exception e) { Console.ForegroundColor = ConsoleColor.Red; - Console.WriteLine(e); + Console.WriteLine("\r" + e); Console.ForegroundColor = ConsoleColor.Gray; + Console.Write("\r> "); } } }); - } - - protected override bool BeforeLoad(params object[] objs) - { - if (objs.Length > 0 && objs[0] is Dictionary delegates) - { - if (delegates.TryGetValue("WriteLine", out object? value) && value is Action a) - { - WriteLine = a; - } - if (delegates.TryGetValue("Error", out value) && value is Action e) - { - Error = e; - } - } - return true; - } - - public Action WriteLine { get; set; } = new Action(Console.WriteLine); - public Action Error { get; set; } = new Action(e => Console.WriteLine(e.GetErrorInfo())); } }