优化图片分类

This commit is contained in:
evoxwht 2023-06-28 09:57:14 +08:00
parent 4ab218cb24
commit 03f26e9257
2 changed files with 13 additions and 3 deletions

View File

@ -38,7 +38,11 @@ class SystemAttachmentCategory extends AuthController
/**
* 显示资源列表
* @return mixed
* @return \think\Response
* @throws \ReflectionException
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function index()
{

View File

@ -41,14 +41,20 @@ class SystemAttachmentCategoryServices 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 getAll(array $where)
{
$list = $this->dao->getList($where);
foreach ($list as &$item) {
$item['title'] = $item['name'];
$item['children'] = [];
if ($where['name'] == '' && $this->dao->count(['pid' => $item['id']])) $item['loading'] = false;
if ($where['name'] == '' && $this->dao->count(['pid' => $item['id']])) {
$item['loading'] = false;
$item['children'] = [];
}
}
return compact('list');
}