|
@@ -296,7 +296,7 @@ namespace GxPress.Repository.Implement
|
|
|
connection.Dispose();
|
|
|
return result;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public async Task<PagedList<TopicListPageResult>> GetTopicByGroupAsync(TopicPageSearchRequest request)
|
|
|
{
|
|
|
var sql = $@"SELECT
|
|
@@ -374,9 +374,11 @@ namespace GxPress.Repository.Implement
|
|
|
OR a.Title LIKE '%{request.Keyword}%'
|
|
|
OR a.HtmlContent LIKE '%{request.Keyword}%')";
|
|
|
}
|
|
|
- sql += $@" ORDER BY a.CreatedDate DESC
|
|
|
- LIMIT {(request.Page - 1) * request.PerPage} , {request.PerPage}";
|
|
|
-
|
|
|
+ if (!string.IsNullOrEmpty(request.Sort))
|
|
|
+ sql += $@" ORDER BY a.ReadCount DESC";
|
|
|
+ else
|
|
|
+ sql += $@" ORDER BY a.CreatedDate DESC";
|
|
|
+ sql += $@" LIMIT {(request.Page - 1) * request.PerPage} , {request.PerPage}";
|
|
|
var result = new PagedList<TopicListPageResult>();
|
|
|
var databaseType = StringUtils.ToEnum<DatabaseType>(_databaseTypeStr, DatabaseType.MySql);
|
|
|
var database = new Database(databaseType, _connectionString);
|