ZxcZxc123 2 年之前
父節點
當前提交
44a1f9b9b8

+ 5 - 21
app/system/controller/EducationController.php

@@ -13,29 +13,13 @@ class EducationController
 {
 
     /**
-     * 获取所有分类
-     * @return \think\response\Json
+     * 获取所有分类列表
      */
-    public function getCate()
+    public function getCateList()
     {
-        $items = Db::table('table_education_cate')
-            ->where(['status' => 'Y'])
-            ->order('sort', 'asc')
-            ->column('id,pid,name,sort', 'id');
-
-        $tree = array(); //格式化好的树
-        foreach ($items as $key => $item) {
-            $items[$key]['oriName'] = $item['name'];
-            if (isset($items[$item['pid']])) {
-                $items[$item['pid']]['children'][$item['id']] = &$items[$item['id']];
-            } else {
-                $tree[$item['id']] = &$items[$item['id']];
-            }
-        }
-
-//        $data = array_values($tree);
-//        $msg = '获取分类成功';
-        return app('json') -> success($tree);
+        $educationModel = new EducationModel();
+        $cateList = $educationModel->getCate();
+        return app('json')->success($cateList);
     }
 
 

+ 1 - 9
app/system/controller/Index.php

@@ -51,13 +51,5 @@ class Index extends AuthController
         ]);
     }
 
-    /**
-     * 获取所有分类列表
-     */
-    public function getCateList()
-    {
-        $educationModel = new EducationModel();
-        $cateList = $educationModel->getCate();
-        return app('json')->success($cateList);
-    }
+
 }

+ 1 - 1
app/system/route/educationController.php

@@ -19,7 +19,7 @@ Route::group('educationController', function () {
 //    Route::rule('list', 'Member/list');
 
     //获取所有分类
-    Route::rule('getCate','EducationController/getCate');
+    Route::rule('getCateList','EducationController/getCateList');
     //获取所有文章列表
     Route::rule('gteArticleList','EducationController/gteArticleList');
     //获取顶级分类