添加商学院列表获取
This commit is contained in:
parent
a51de4c967
commit
41f3409bf1
@ -24,7 +24,7 @@ class BusinessSchool extends Api
|
|||||||
$get = $this->request->get();
|
$get = $this->request->get();
|
||||||
$get['page_no'] = $this->page_no;
|
$get['page_no'] = $this->page_no;
|
||||||
$get['page_size'] = $this->page_size;
|
$get['page_size'] = $this->page_size;
|
||||||
$lists = ArticleLogic::lists($get);
|
$lists = BusinessSchoolLogic::lists($get);
|
||||||
return JsonServer::success('获取成功', $lists);
|
return JsonServer::success('获取成功', $lists);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -20,4 +20,51 @@ class BusinessSchoolLogic extends Logic
|
|||||||
return ['error'=>$e->getMessage()];
|
return ['error'=>$e->getMessage()];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function lists($get)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$where = [
|
||||||
|
['a.del', '=', 0],
|
||||||
|
['a.is_show', '=', 1],
|
||||||
|
['c.del', '=', 0],
|
||||||
|
['c.is_show', '=', 1],
|
||||||
|
];
|
||||||
|
if(isset($get['cid']) && !empty($get['cid'])) {
|
||||||
|
$where[] = ['cid', '=', $get['cid']];
|
||||||
|
}
|
||||||
|
|
||||||
|
$order = [
|
||||||
|
'sort' => 'asc',
|
||||||
|
'id' => 'desc'
|
||||||
|
];
|
||||||
|
|
||||||
|
$model = new BusinessSchool();
|
||||||
|
|
||||||
|
$count = $model->alias('a')->join('article_category c', 'c.id = a.cid')->where($where)->count();
|
||||||
|
|
||||||
|
$list = $model->alias('a')
|
||||||
|
->join('article_category c', 'c.id = a.cid')
|
||||||
|
->field(['a.id', 'a.title', 'a.image', 'a.visit', 'a.likes','a.intro', 'a.content', 'a.create_time'])
|
||||||
|
->where($where)
|
||||||
|
->order($order)
|
||||||
|
->page($get['page_no'], $get['page_size'])
|
||||||
|
->select()
|
||||||
|
->toArray();
|
||||||
|
|
||||||
|
$more = is_more($count, $get['page_no'], $get['page_size']);
|
||||||
|
|
||||||
|
$data = [
|
||||||
|
'list' => $list,
|
||||||
|
'page_no' => $get['page_no'],
|
||||||
|
'page_size' => $get['page_size'],
|
||||||
|
'count' => $count,
|
||||||
|
'more' => $more
|
||||||
|
];
|
||||||
|
return $data;
|
||||||
|
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
return ['error'=>$e->getMessage()];
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue
Block a user