From de551cc3babf8697639574570612857f78bb1a26 Mon Sep 17 00:00:00 2001 From: sin365 <353374337@qq.com> Date: Thu, 28 Nov 2024 18:01:27 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BB=9F=E8=AE=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AxibugEmuOnline.Web/Controllers/ApiController.cs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/AxibugEmuOnline.Web/Controllers/ApiController.cs b/AxibugEmuOnline.Web/Controllers/ApiController.cs index 07319920..182cecc0 100644 --- a/AxibugEmuOnline.Web/Controllers/ApiController.cs +++ b/AxibugEmuOnline.Web/Controllers/ApiController.cs @@ -1,6 +1,7 @@ using AxibugEmuOnline.Web.Common; using Microsoft.AspNetCore.Mvc; using MySql.Data.MySqlClient; +using Mysqlx.Crud; namespace AxibugEmuOnline.Web.Controllers { @@ -52,7 +53,6 @@ namespace AxibugEmuOnline.Web.Controllers break; } - string query = "SELECT count(id) FROM romlist_nes where `Name` like ?searchPattern " + GameTypeCond; 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)) { // ÉèÖòÎÊýÖµ @@ -93,7 +96,8 @@ namespace AxibugEmuOnline.Web.Controllers 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, + playcount = reader.GetInt32(7), + stars = reader.GetInt32(8), }); } } @@ -194,6 +198,7 @@ namespace AxibugEmuOnline.Web.Controllers public string imgUrl { get; set; } public string hash { get; set; } public int stars { get; set; } + public int playcount { get; set; } } } }