修改接口类
This commit is contained in:
@@ -18,6 +18,12 @@ use app\model\Attribute;
|
||||
*/
|
||||
class Content extends Base {
|
||||
|
||||
public $middleware = [
|
||||
'\app\http\middleware\Validate',
|
||||
'\app\http\middleware\ApiAuth' => ['except' => ['lists', 'detail', 'category']],
|
||||
'\app\http\middleware\Api',
|
||||
];
|
||||
|
||||
public $modelInfo = [];
|
||||
public $model = null;
|
||||
|
||||
@@ -41,8 +47,16 @@ class Content extends Base {
|
||||
if (isset($param['keyword']) && $param['keyword'] != '') {
|
||||
$map[] = ['title', 'LIKE', '%'.$param['keyword'].'%'];
|
||||
}
|
||||
if (isset($param['category_id']) && $param['category_id']) {
|
||||
$map[] = ['category_id', '=', $param['category_id']];
|
||||
}
|
||||
|
||||
$list = $this->model->where($map)->order($order)->paginate($this->request->pageConfig);
|
||||
$list = $this->model->where($map)->order($order)->paginate($this->request->pageConfig)->each(function($item) {
|
||||
if(isset($item['cover_id'])){
|
||||
$item['cover'] = get_attach($item['cover_id'], 'url');
|
||||
return $item;
|
||||
}
|
||||
});
|
||||
$this->data['code'] = 1;
|
||||
$this->data['data'] = $list;
|
||||
return $this->data;
|
||||
@@ -64,6 +78,27 @@ class Content extends Base {
|
||||
return $this->data;
|
||||
}
|
||||
|
||||
/**
|
||||
* @title 栏目列表
|
||||
* @method GET
|
||||
* @return [json]
|
||||
*/
|
||||
public function category(){
|
||||
$param = $this->request->param();
|
||||
$map = [];
|
||||
|
||||
$map[] = ['model_id', '=', $this->modelInfo['id']];
|
||||
if(isset($param['pid']) && $param['pid']){
|
||||
$map[] = ['pid', '=', $param['pid']];
|
||||
}
|
||||
|
||||
$list = Category::where($map)->select();
|
||||
|
||||
$this->data['code'] = 1;
|
||||
$this->data['data'] = $list;
|
||||
return $this->data;
|
||||
}
|
||||
|
||||
/**
|
||||
* @title 添加内容
|
||||
* @method POST
|
||||
|
||||
Reference in New Issue
Block a user