文章分类搜索

This commit is contained in:
evoxwht 2023-03-24 15:17:20 +08:00
parent dccfdfbe5e
commit 5364f2d229
2 changed files with 9 additions and 14 deletions

View File

@ -32,11 +32,15 @@ class ArticleCategoryDao extends BaseDao
}
/**
* 获取文章列表
* 获取文章分类列表
* @param array $where
* @param int $page
* @param int $limit
* @return mixed
* @throws \ReflectionException
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function getList(array $where, int $page = 0, int $limit = 0)
{

View File

@ -39,23 +39,14 @@ class ArticleCategoryServices extends BaseServices
* 获取文章分类列表
* @param array $where
* @return array
* @throws \ReflectionException
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function getList(array $where)
{
[$page, $limit] = $this->getPageValue();
$list = $this->dao->getList($where);
if (!empty($list) && $where['title'] !== '') {
$pids = Arr::getUniqueKey($list, 'pid');
$parentList = $this->dao->getList(['id' => $pids]);
$list = array_merge($list, $parentList);
foreach ($list as $key => $item) {
$arr = $item;
unset($list[$key]);
if (!in_array($arr, $list)) {
$list[] = $arr;
}
}
}
$list = get_tree_children($list);
$count = $this->dao->count($where);
return compact('list', 'count');