liumiao
2021-01-20 f8b4c69d36741497af6a2f3c4bd15d25f0ae2b79
删除缓存
1 files modified
96 ■■■■ changed files
app/Http/Controllers/Api/v1/PersonController.php 96 ●●●● patch | view | raw | blame | history
app/Http/Controllers/Api/v1/PersonController.php
@@ -28,58 +28,58 @@
    {
        $version = $request->appVersion >= 1 ? $request->appVersion : 1;
        $deviceType = $request->deviceType;
        $teacherId = $this->uidAndParentid($request->teacherId, 'D');
        $teacherId = $this->getAndCheckTeacherId();
        $orgId = $request->post("orgId");
        $roleInfo = UserRoleModel::findRecordOneCondition(["OrgId" => $orgId, "UserId" => $teacherId, "RoleId" => 2026]);
        $this->redis->upPrefix("App");
        $redisName = $deviceType . $version;
        $_key = RedisKey::MY_PAGE_MENU . $redisName;
        $myMenuList = $this->redis->get($_key);
        if(empty($myMenuList))
//        $this->redis->upPrefix("App");
//        $redisName = $deviceType . $version;
//        $_key = RedisKey::MY_PAGE_MENU . $redisName;
//        $myMenuList = $this->redis->get($_key);
//        if(empty($myMenuList))
//        {
        //顶级分组菜单
        $whereTop['m.status'] = 1;
        $whereTop['m.appType'] = 2;
        $whereTop['m.parentid'] = 0;
        $whereTop['m.isDelete'] = 0;
        $whereTop['mm.version'] = ["<=" => $version];
        $whereTop['mm.type'] = 2;
        $whereTop['mm.deviceType'] = $deviceType;
        $selectTop = ['m.id', 'm.menuName as subTitle'];
        $orderTop['m.fsort'] = 'asc';
        $topQuery = MyMenuModel::queryMenuJoinList();
        $myMenuTop = MyMenuModel::getDataJoinList($topQuery, $whereTop, $selectTop, $orderTop)->toArray();
        $myMenuTop = array_column($myMenuTop, null, 'id');
        $myMenuParentidArr = [];
        foreach($myMenuTop as &$v)
        {
            //顶级分组菜单
            $whereTop['m.status'] = 1;
            $whereTop['m.appType'] = 2;
            $whereTop['m.parentid'] = 0;
            $whereTop['m.isDelete'] = 0;
            $whereTop['mm.version'] = ["<=" => $version];
            $whereTop['mm.type'] = 2;
            $whereTop['mm.deviceType'] = $deviceType;
            $selectTop = ['m.id', 'm.menuName as subTitle'];
            $orderTop['m.fsort'] = 'asc';
            $topQuery = MyMenuModel::queryMenuJoinList();
            $myMenuTop = MyMenuModel::getDataJoinList($topQuery, $whereTop, $selectTop, $orderTop)->toArray();
            $myMenuTop = array_column($myMenuTop, null, 'id');
            $myMenuParentidArr = [];
            foreach($myMenuTop as &$v)
            {
                $myMenuParentidArr[] = $v['id'];
                $v['menuList'] = [];
            }
            $where['m.status'] = 1;
            $where['m.isDelete'] = 0;
            $where['mm.type'] = 2;
            $where['m.appType'] = 2;
            $where['mm.deviceType'] = $deviceType;
            $where['mm.version'] = ["<=" => $version];
            $where['m.parentid'] = ['wherein' => $myMenuParentidArr];
            $select = ['m.parentid', 'm.menuName', 'm.jumpType', 'm.jumpModule', 'm.jumpUrl', 'm.jumpParam', "m.isLogin", \DB::raw("CONCAT('" . MPFILE_PATH . "', " . "m.imageUrl" . ") AS 'imageUrl'")];
            $order['m.fsort'] = 'asc';
            $query = MyMenuModel::queryMenuJoinList();
            $myMenu = MyMenuModel::getDataJoinList($query, $where, $select, $order)->toArray();
            foreach($myMenu as $key => $value)
            {
                if(empty($roleInfo) && $value["jumpModule"] == 5001)
                {
                    continue;
                }
                $myMenuTop[$value['parentid']]['menuList'][] = $value;
            }
            $myMenuList = array_values($myMenuTop);
            $this->redis->set($_key, json_encode($myMenuList, true));
            $myMenuParentidArr[] = $v['id'];
            $v['menuList'] = [];
        }
        $where['m.status'] = 1;
        $where['m.isDelete'] = 0;
        $where['mm.type'] = 2;
        $where['m.appType'] = 2;
        $where['mm.deviceType'] = $deviceType;
        $where['mm.version'] = ["<=" => $version];
        $where['m.parentid'] = ['wherein' => $myMenuParentidArr];
        $select = ['m.parentid', 'm.menuName', 'm.jumpType', 'm.jumpModule', 'm.jumpUrl', 'm.jumpParam', "m.isLogin", \DB::raw("CONCAT('" . MPFILE_PATH . "', " . "m.imageUrl" . ") AS 'imageUrl'")];
        $order['m.fsort'] = 'asc';
        $query = MyMenuModel::queryMenuJoinList();
        $myMenu = MyMenuModel::getDataJoinList($query, $where, $select, $order)->toArray();
        foreach($myMenu as $key => $value)
        {
            if(empty($roleInfo) && $value["jumpModule"] == 5001)
            {
                continue;
            }
            $myMenuTop[$value['parentid']]['menuList'][] = $value;
        }
        $myMenuList = array_values($myMenuTop);
//            $this->redis->set($_key, json_encode($myMenuList, true));
//        }
        return $this->_response($myMenuList);
    }
}