Browse Source

menulist菜单列表接口优化

wufeng 2 years ago
parent
commit
7da5136b84
1 changed files with 15 additions and 8 deletions
  1. 15 8
      app/admin/controller/Menu.php

+ 15 - 8
app/admin/controller/Menu.php

@@ -206,19 +206,26 @@ class Menu extends Base
      * @throws \think\db\exception\ModelNotFoundException
      * @throws \think\exception\DbException
      */
-    public function MenuAllList()
-    {
-        $role = Db::name("role_action")->where("role_id", "=", $this->roleid)->find();
-        if ($role == false) return json_show(0, "获取成功", []);
+    public function   MenuAllList(){
+        $post  =$this->request->post();
 
         $data = Db::name("admin_menu")
-            ->where([["is_del", "=", 0], ["level", ">=", $this->level]])
-            ->field("id,menu_name,menu_img,menu_route,menu_url,pid,is_show,is_private,menu_type,level,status,weight")
+            ->where(['pid'=>0,'is_del'=>0])
             ->order("weight desc,id asc")
             ->select()
             ->toArray();
-        $l = MenuTree($data, 0);
-        return json_show(0, "获取成功", $l);
+        $l=[];
+        foreach ($data as $key=>$value){
+            $temp=[];
+            $temp =  Db::name("admin_menu")
+                ->where(['pid'=>$value['id'],'is_del'=>0])
+                ->order("weight desc,id asc")
+                ->select()
+                ->toArray();
+            $value['child']=$temp;
+            $l[]=$value;
+        }
+        return app_show(0,"获取成功",$l);
     }
 
     /**