This commit is contained in:
sin365 2024-11-28 18:01:27 +08:00
parent 208653f9a9
commit de551cc3ba

View File

@ -1,6 +1,7 @@
using AxibugEmuOnline.Web.Common; using AxibugEmuOnline.Web.Common;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using MySql.Data.MySqlClient; using MySql.Data.MySqlClient;
using Mysqlx.Crud;
namespace AxibugEmuOnline.Web.Controllers namespace AxibugEmuOnline.Web.Controllers
{ {
@ -52,7 +53,6 @@ namespace AxibugEmuOnline.Web.Controllers
break; break;
} }
string query = "SELECT count(id) FROM romlist_nes where `Name` like ?searchPattern " + GameTypeCond; 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))
{ {
@ -70,7 +70,10 @@ namespace AxibugEmuOnline.Web.Controllers
} }
} }
query = $"SELECT id,`Name`,GameType,Note,RomUrl,ImgUrl,`Hash` FROM romlist_nes where `Name` like ?searchPattern {GameTypeCond} LIMIT ?offset, ?pageSize;";
string HotOrderBy = "ORDER BY playcount DESC, id ASC";
query = $"SELECT id,`Name`,GameType,Note,RomUrl,ImgUrl,`Hash`,`playcount`,`stars` FROM romlist_nes where `Name` like ?searchPattern {GameTypeCond} {HotOrderBy} LIMIT ?offset, ?pageSize;";
using (var command = new MySqlCommand(query, conn)) using (var command = new MySqlCommand(query, conn))
{ {
// ÉèÖòÎÊýÖµ // ÉèÖòÎÊýÖµ
@ -93,7 +96,8 @@ namespace AxibugEmuOnline.Web.Controllers
url = !reader.IsDBNull(4) ? reader.GetString(4) : string.Empty, url = !reader.IsDBNull(4) ? reader.GetString(4) : string.Empty,
imgUrl = !reader.IsDBNull(5) ? reader.GetString(5) : string.Empty, imgUrl = !reader.IsDBNull(5) ? reader.GetString(5) : string.Empty,
hash = !reader.IsDBNull(6) ? reader.GetString(6) : string.Empty, hash = !reader.IsDBNull(6) ? reader.GetString(6) : string.Empty,
stars = 0, playcount = reader.GetInt32(7),
stars = reader.GetInt32(8),
}); });
} }
} }
@ -194,6 +198,7 @@ namespace AxibugEmuOnline.Web.Controllers
public string imgUrl { get; set; } public string imgUrl { get; set; }
public string hash { get; set; } public string hash { get; set; }
public int stars { get; set; } public int stars { get; set; }
public int playcount { get; set; }
} }
} }
} }