Bladeren bron

优化图片分类

evoxwht 2 jaren geleden
bovenliggende
commit
03f26e9257

+ 5 - 1
crmeb/app/adminapi/controller/v1/file/SystemAttachmentCategory.php

@@ -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()
     public function index()
     {
     {

+ 8 - 2
crmeb/app/services/system/attachment/SystemAttachmentCategoryServices.php

@@ -41,14 +41,20 @@ class SystemAttachmentCategoryServices extends BaseServices
      * 获取分类列表
      * 获取分类列表
      * @param array $where
      * @param array $where
      * @return array
      * @return array
+     * @throws \ReflectionException
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
      */
      */
     public function getAll(array $where)
     public function getAll(array $where)
     {
     {
         $list = $this->dao->getList($where);
         $list = $this->dao->getList($where);
         foreach ($list as &$item) {
         foreach ($list as &$item) {
             $item['title'] = $item['name'];
             $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');
         return compact('list');
     }
     }