From ec45bd0e6caeb920d0668b951dc27fd8ca498732 Mon Sep 17 00:00:00 2001 From: wanghousheng Date: Sun, 4 Feb 2024 15:49:03 +0800 Subject: [PATCH] 1 --- app/api/controller/Article.php | 5 +++-- app/api/controller/Recovery.php | 2 +- app/api/model/Article.php | 8 +++++--- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/app/api/controller/Article.php b/app/api/controller/Article.php index cf511d93..9eb3d421 100644 --- a/app/api/controller/Article.php +++ b/app/api/controller/Article.php @@ -12,8 +12,8 @@ declare (strict_types=1); namespace app\api\controller; -use think\response\Json; use app\api\model\Article as ArticleModel; +use think\response\Json; /** * 文章控制器 @@ -31,7 +31,8 @@ class Article extends Controller public function list(int $categoryId = 0): Json { $model = new ArticleModel; - $list = $model->getList($categoryId); + $title = (string)$this->request->input('title'); + $list = $model->getList($categoryId, 15, $title); return $this->renderSuccess(compact('list')); } diff --git a/app/api/controller/Recovery.php b/app/api/controller/Recovery.php index 156bab7b..7303eed3 100644 --- a/app/api/controller/Recovery.php +++ b/app/api/controller/Recovery.php @@ -401,7 +401,7 @@ class Recovery extends Controller if (!$order_id) { return $this->renderError('缺少必要参数'); } - if (RecoveryOrder::detail(['order_id' => $order_id, 'order_status' => RecoveryStatusEnum::ACCEPTED])->isEmpty()) { + if (!RecoveryOrder::detail(['order_id' => $order_id, 'order_status' => RecoveryStatusEnum::ACCEPTED])) { return $this->renderError('订单信息不存在'); } $model = new RecoveryOrder(); diff --git a/app/api/model/Article.php b/app/api/model/Article.php index 22197d5b..0e29120e 100644 --- a/app/api/model/Article.php +++ b/app/api/model/Article.php @@ -12,9 +12,8 @@ declare (strict_types=1); namespace app\api\model; -use cores\exception\BaseException; -use app\common\model\Article as ArticleModel; use app\api\model\article\Category as CategoryModel; +use app\common\model\Article as ArticleModel; /** * 商品评价模型 @@ -81,11 +80,14 @@ class Article extends ArticleModel * @return \think\Paginator * @throws \think\db\exception\DbException */ - public function getList(int $categoryId = 0, int $limit = 15): \think\Paginator + public function getList(int $categoryId = 0, int $limit = 15, string $title): \think\Paginator { // 检索查询条件 $filter = []; $categoryId > 0 && $filter[] = ['category_id', '=', $categoryId]; + if ($title) { + $filter[] = ['title', 'like', "%$title%"]; + } // 获取列表数据 $list = $this->withoutField(['content']) ->where($filter)