pull/1/head
wanghousheng 10 months ago
parent 4f763ffac7
commit ec45bd0e6c
  1. 5
      app/api/controller/Article.php
  2. 2
      app/api/controller/Recovery.php
  3. 8
      app/api/model/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'));
}

@ -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();

@ -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)

Loading…
Cancel
Save