forked from sin365/AxibugEmuOnline
fixed web api
This commit is contained in:
parent
1a1e5026f8
commit
b9efbbf1d2
@ -14,14 +14,32 @@ namespace AxibugEmuOnline.Web.Controllers
|
|||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
public JsonResult NesRomList(string SearchKey,int Page, int PageSize)
|
public JsonResult NesRomList(string SearchKey,int Ptype,int GType,int Page, int PageSize)
|
||||||
{
|
{
|
||||||
string searchPattern = $"%{SearchKey}%";
|
string searchPattern = $"%{SearchKey}%";
|
||||||
Resp_GameList resp = new Resp_GameList();
|
Resp_GameList resp = new Resp_GameList();
|
||||||
resp.GameList = new List<Resp_RomInfo>();
|
resp.gameList = new List<Resp_RomInfo>();
|
||||||
using (MySqlConnection conn = Haoyue_SQLPoolManager.DequeueSQLConn("NesRomList"))
|
MySqlConnection conn = Haoyue_SQLPoolManager.DequeueSQLConn("NesRomList");
|
||||||
{
|
{
|
||||||
string query = "SELECT count(id) FROM romlist_nes where `Name` like ?searchPattern ";
|
|
||||||
|
GameType SearchGType = (GameType)GType;
|
||||||
|
|
||||||
|
string GameTypeCond = "";
|
||||||
|
switch (SearchGType)
|
||||||
|
{
|
||||||
|
case GameType.NONE:
|
||||||
|
GameTypeCond = string.Empty;
|
||||||
|
break;
|
||||||
|
case GameType.ALLINONE:
|
||||||
|
GameTypeCond = $" and GameType = 'ºÏ¿¨' ";
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
GameTypeCond = $" and GameType = '{SearchGType.ToString()}' ";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
string query = "SELECT count(id) FROM romlist_nes where `Name` like ?searchPattern " + GameTypeCond;
|
||||||
using (var command = new MySqlCommand(query, conn))
|
using (var command = new MySqlCommand(query, conn))
|
||||||
{
|
{
|
||||||
// ÉèÖòÎÊýÖµ
|
// ÉèÖòÎÊýÖµ
|
||||||
@ -31,14 +49,14 @@ namespace AxibugEmuOnline.Web.Controllers
|
|||||||
{
|
{
|
||||||
while (reader.Read())
|
while (reader.Read())
|
||||||
{
|
{
|
||||||
resp.ResultAllCount = reader.GetInt32(0);
|
resp.resultAllCount = reader.GetInt32(0);
|
||||||
resp.Page = Page;
|
resp.page = Page;
|
||||||
resp.MaxPage = resp.ResultAllCount / PageSize;
|
resp.maxPage = (int)Math.Ceiling((float)resp.resultAllCount / PageSize);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
query = "SELECT id,`Name`,RomUrl,ImgUrl FROM romlist_nes where `Name` like ?searchPattern LIMIT ?offset, ?pageSize;";
|
query = $"SELECT id,`Name`,GameType,Note,RomUrl,ImgUrl,`Hash` FROM romlist_nes where `Name` like ?searchPattern {GameTypeCond} LIMIT ?offset, ?pageSize;";
|
||||||
using (var command = new MySqlCommand(query, conn))
|
using (var command = new MySqlCommand(query, conn))
|
||||||
{
|
{
|
||||||
// ÉèÖòÎÊýÖµ
|
// ÉèÖòÎÊýÖµ
|
||||||
@ -50,12 +68,16 @@ namespace AxibugEmuOnline.Web.Controllers
|
|||||||
{
|
{
|
||||||
while (reader.Read())
|
while (reader.Read())
|
||||||
{
|
{
|
||||||
resp.GameList.Add(new Resp_RomInfo() {
|
resp.gameList.Add(new Resp_RomInfo()
|
||||||
ID = reader.GetInt32(0),
|
{
|
||||||
RomName = reader.GetString(1),
|
id = reader.GetInt32(0),
|
||||||
Hash = string.Empty,
|
romName = !reader.IsDBNull(1) ? reader.GetString(1) : string.Empty,
|
||||||
ImgUrl = reader.GetString(2),
|
gType = !reader.IsDBNull(2) ? reader.GetString(2) : string.Empty,
|
||||||
Url = reader.GetString(3),
|
desc = !reader.IsDBNull(3) ? reader.GetString(3) : string.Empty,
|
||||||
|
url = !reader.IsDBNull(4) ? reader.GetString(4) : string.Empty,
|
||||||
|
imgUrl = !reader.IsDBNull(5) ? reader.GetString(5) : string.Empty,
|
||||||
|
hash = !reader.IsDBNull(6) ? reader.GetString(6) : string.Empty,
|
||||||
|
stars = 0,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -65,22 +87,52 @@ namespace AxibugEmuOnline.Web.Controllers
|
|||||||
return new JsonResult(resp);
|
return new JsonResult(resp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
enum PlatformType : byte
|
||||||
|
{
|
||||||
|
All = 0,
|
||||||
|
Nes,
|
||||||
|
}
|
||||||
|
|
||||||
|
enum GameType : byte
|
||||||
|
{
|
||||||
|
NONE = 0,
|
||||||
|
ACT,
|
||||||
|
ARPG,
|
||||||
|
AVG,
|
||||||
|
ETC,
|
||||||
|
FTG,
|
||||||
|
PUZ,
|
||||||
|
RAC,
|
||||||
|
RPG,
|
||||||
|
SLG,
|
||||||
|
SPG,
|
||||||
|
SRPG,
|
||||||
|
STG,
|
||||||
|
TAB,
|
||||||
|
/// <summary>
|
||||||
|
/// ºÏ¿¨
|
||||||
|
/// </summary>
|
||||||
|
ALLINONE,
|
||||||
|
}
|
||||||
|
|
||||||
class Resp_GameList
|
class Resp_GameList
|
||||||
{
|
{
|
||||||
public int Page { get; set; }
|
public int page { get; set; }
|
||||||
public int MaxPage { get; set; }
|
public int maxPage { get; set; }
|
||||||
public int ResultAllCount { get; set; }
|
public int resultAllCount { get; set; }
|
||||||
public List<Resp_RomInfo> GameList { get; set; }
|
public List<Resp_RomInfo> gameList { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class Resp_RomInfo
|
public class Resp_RomInfo
|
||||||
{
|
{
|
||||||
public int ID { get; set; }
|
public int id { get; set; }
|
||||||
public string Hash { get; set; }
|
public string romName { get; set;}
|
||||||
public string RomName { get; set;}
|
public string gType { get; set; }
|
||||||
public string Url { get; set; }
|
public string desc { get; set; }
|
||||||
public string ImgUrl { get; set; }
|
public string url { get; set; }
|
||||||
|
public string imgUrl { get; set; }
|
||||||
|
public string hash { get; set; }
|
||||||
|
public int stars { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user