优化后端

This commit is contained in:
2025-05-16 13:04:17 +08:00
parent 4f8f621c2c
commit 9df71d0faf
19 changed files with 1835 additions and 694 deletions
+14 -1
View File
@@ -16,12 +16,15 @@ class Article extends Base
if (Request::isPost()) {
$category = input('post.category');
$page = input('post.page', 1);
$limit = input('post.limit', 20);
$limit = input('post.limit', 10);
$title = input('post.title');
$author = input('post.author');
$query = Db::table('yz_article')
->where('delete_time', null)
->where('status', '<>', 3);
// 分类筛选
if (!empty($category)) {
// 先获取分类ID
$cateInfo = Db::table('yz_article_category')
@@ -34,6 +37,16 @@ class Article extends Base
$query = $query->where('cate', $cateInfo['id']);
}
}
// 标题搜索
if (!empty($title)) {
$query = $query->where('title', 'like', '%'.$title.'%');
}
// 作者搜索
if (!empty($author)) {
$query = $query->where('author', 'like', '%'.$author.'%');
}
// 获取总记录数
$count = $query->count();