diff --git a/AxibugEmuOnline.Client/Assets/Script/Manager/HttpAPI.cs b/AxibugEmuOnline.Client/Assets/Script/Manager/HttpAPI.cs index 284211d..b5c3877 100644 --- a/AxibugEmuOnline.Client/Assets/Script/Manager/HttpAPI.cs +++ b/AxibugEmuOnline.Client/Assets/Script/Manager/HttpAPI.cs @@ -34,6 +34,27 @@ namespace AxibugEmuOnline.Client callback.Invoke(resp); } + private IEnumerator GetNesRomInfo(int RomID, Action callback) + { + UnityWebRequest request = UnityWebRequest.Get($"{WebSiteApi}/RomInfo?PType={PlatformType.Nes}&RomID={RomID}"); + yield return request.SendWebRequest(); + + if (request.result != UnityWebRequest.Result.Success) + { + callback.Invoke(null); + yield break; + } + + var resp = JsonUtility.FromJson(request.downloadHandler.text); + callback.Invoke(resp); + } + + enum PlatformType : byte + { + All = 0, + Nes = 1, + } + enum GameType : byte { NONE = 0, diff --git a/AxibugEmuOnline.Web/Controllers/ApiController.cs b/AxibugEmuOnline.Web/Controllers/ApiController.cs index 087a2e4..0731992 100644 --- a/AxibugEmuOnline.Web/Controllers/ApiController.cs +++ b/AxibugEmuOnline.Web/Controllers/ApiController.cs @@ -28,7 +28,7 @@ namespace AxibugEmuOnline.Web.Controllers } [HttpGet] - public JsonResult NesRomList(string SearchKey,int Ptype,int GType,int Page, int PageSize) + public JsonResult NesRomList(string SearchKey, int Ptype, int GType, int Page, int PageSize) { string searchPattern = $"%{SearchKey}%"; Resp_GameList resp = new Resp_GameList(); @@ -103,6 +103,40 @@ namespace AxibugEmuOnline.Web.Controllers return new JsonResult(resp); } + + [HttpGet] + public JsonResult RomInfo(int Ptype, int RomID) + { + string searchPattern = $"%{RomInfo}%"; + Resp_RomInfo resp = new Resp_RomInfo(); + MySqlConnection conn = Haoyue_SQLPoolManager.DequeueSQLConn("NesRomList"); + { + string query = $"SELECT id,`Name`,GameType,Note,RomUrl,ImgUrl,`Hash` FROM romlist_nes where id = ?romid;"; + using (var command = new MySqlCommand(query, conn)) + { + // 设置参数值 + command.Parameters.AddWithValue("?romid", RomID); + // 执行查询并处理结果 + using (var reader = command.ExecuteReader()) + { + while (reader.Read()) + { + resp.id = reader.GetInt32(0); + resp.romName = !reader.IsDBNull(1) ? reader.GetString(1) : string.Empty; + resp.gType = !reader.IsDBNull(2) ? reader.GetString(2) : string.Empty; + resp.desc = !reader.IsDBNull(3) ? reader.GetString(3) : string.Empty; + resp.url = !reader.IsDBNull(4) ? reader.GetString(4) : string.Empty; + resp.imgUrl = !reader.IsDBNull(5) ? reader.GetString(5) : string.Empty; + resp.hash = !reader.IsDBNull(6) ? reader.GetString(6) : string.Empty; + resp.stars = 0; + } + } + } + Haoyue_SQLPoolManager.EnqueueSQLConn(conn); + } + return new JsonResult(resp); + } + enum PlatformType : byte { All = 0, @@ -153,7 +187,7 @@ namespace AxibugEmuOnline.Web.Controllers { public int orderid { get; set; } public int id { get; set; } - public string romName { get; set;} + public string romName { get; set; } public string gType { get; set; } public string desc { get; set; } public string url { get; set; } diff --git a/README_WEBAPI.md b/README_WEBAPI.md index 7b8b69b..372c259 100644 --- a/README_WEBAPI.md +++ b/README_WEBAPI.md @@ -2,6 +2,24 @@ 杩欓噷璇存槑锛學ebApi绫荤殑鎺ュ彛 + +### 鍩烘湰閫氱敤鍙傛暟 + +``` +platform 妯℃嫙鍣ㄦ墍鍦ㄥ钩鍙 +[0] 閫氱敤 +[1] PC + +PType Rom鎵灞炲钩鍙 + + enum PlatformType : byte + { + All = 0, + Nes = 1, + } + +``` + ### 鍩烘湰淇℃伅妫鏌 ``` @@ -120,33 +138,7 @@ Response: 搴忓垪鍖朇#瀹炰綋绫荤ず渚 ``` - enum PlatformType : byte - { - All = 0, - Nes, - } - - enum GameType : byte - { - NONE = 0, - ACT, - ARPG, - AVG, - ETC, - FTG, - PUZ, - RAC, - RPG, - SLG, - SPG, - SRPG, - STG, - TAB, - /// - /// 鍚堝崱 - /// - ALLINONE, - } + class Resp_GameList { @@ -168,4 +160,36 @@ Response: public string hash { get; set; } public int stars { get; set; } } -``` \ No newline at end of file +``` + + +### 鍗曚釜Rom娓告垙璇︽儏 + +``` +{WebHost}/api/RomInfo?PType=<骞冲彴鏋氫妇锛坕nt锛>&RomID= +``` + +Request: + +``` +http://emu.axibug.com/api/RomInfo?PType=1&RomID=5 +``` + +Response: + +``` +{ + "orderid": 0,//鍗曚釜鏌ヨ灏辨病鏈夋帓搴廼d浜 + "id": 5, + "romName": "1999寮烘墜妫", + "gType": "TAB", + "desc": "浠ヤ笘绾湯鍦扮悆鍗辨満涓洪鏉愮殑妗屾鍐掗櫓鑺傜洰銆傛父鎴忚呰瀛樺偍瀹囧畽鑳介噺甯姪鍦扮悆鎽嗚劚鍚勬柟闈㈠嵄鏈烘渶澶氬彲4浜哄悓鏃惰繘琛", + "url": "roms/fcrom/1999%20-%20Hore,%20Mitakotoka!%20Seikimatsu%20(J).zip", + "imgUrl": "images/fcrom/1999%20-%20Hore,%20Mitakotoka!%20Seikimatsu%20(J).JPG", + "hash": "", + "stars": 0 +} +``` + + +搴忓垪鍖朇lass 鍙傜収濡備笂 Resp_RomInfo \ No newline at end of file