LiuJ 1 deň pred
rodič
commit
32dc02d81a
1 zmenil súbory, kde vykonal 85 pridanie a 148 odobranie
  1. 85 148
      app/JsonRpc/ClientService.php

+ 85 - 148
app/JsonRpc/ClientService.php

@@ -136,161 +136,98 @@ class ClientService implements ClientServiceInterface
         switch ($getpage) {
 
             case 'index':
-                $componetList = $data['template']['index'][0]['componentList'];
-                //计算一级的所有子级;组成一个数据,key是一级的category_id,value是所有的子级数据,加上个二级的pinyin属性,放的是catiall的数据
-                foreach ($componetList as $key => $value) {
-                    //取出componentData
-                    $componentData = $value['componentData'];
-                    // $page = $componentData['page'];
-                    // $pageSize = $componentData['pageSize'];
-                    // $listType = $componentData['listType'];
-
-                    $category_id = $componentData['category_id'] ?? $categoryIds[0]; //此处应该有值
-                    $imgSize = $componentData['imgSize'] ?? 1;
-                    $textSize = $componentData['textSize'] ?? 1;
-                    $level = $componentData['level'] ?? 1;
-                    $child = $componentData['child'] ?? [];
-                    //获取子级
-                    if ($child) {
-                    }
-                    $child_id = $child['id'] ?? $categoryIds[0];
-                    $child_imgSize = $child['imgSize'] ?? 1;
-                    $child_textSize = $child['textSize'] ?? 1;
-
-                    // 拼音就是路由----
-                    // unset($listType['pinyin']);
-                    //查询查询数据,返回到data字段里,根据这几个
-                    if ($category_id > 0) {
-                        var_dump($category_id, '------------------category_id');
-                        var_dump($cat_1st_arr, '-----------1-------2');
-                        // 第一次查询:imgurl 不为空的数据
-                        $imgArticles = Db::table('article')
-                            ->leftJoin('article_ignore', function ($join) use ($website_id) {
-                                $join->on('article.id', '=', 'article_ignore.article_id')
-                                    ->where('article_ignore.website_id', '=', $website_id);
-                            })
-                            ->whereNull('article_ignore.article_id')
-                            // ->whereIn('catid', [$category_id])
-                            ->whereIn('catid', $temp_arr = array_merge([$category_id], $cat_1st_arr[$category_id]))
-                            ->where('status', 1)
-                            ->whereNotNull('imgurl')
-
-                            // ignore_ids  是空 或者[],或者不存在website_id的数据  json
-                            // ->where('ignore_ids', 'not like', '%' . $website_id . '%')
-                            ->where('imgurl', '!=', '')
-                            ->limit($imgSize)
-                            ->orderBy('updated_at', 'desc')
-                            ->get()
-                            ->toArray();
-                        //拼接上拼音
-                        foreach ($imgArticles as $k => $v) {
-                            $imgArticles[$k]->pinyin = $catiall[$v->catid][0];
-                        }
-
-                        // 第二次查询:imgurl 为空的数据
-                        $textArticles = Db::table('article')
-                            // ->whereIn('catid', [$category_id])
-                            ->whereIn('catid', $temp_arr = array_merge([$category_id], $cat_1st_arr[$category_id]))
-                            ->where('status', 1)
-                            // ->where('ignore_ids', 'not like', '%' . $website_id . '%')
-                            // ->whereNull('imgurl')
-                            ->limit($textSize)
-                            ->orderBy('updated_at', 'desc')
-                            ->get()
-                            ->toArray();
-                        //拼接上拼音
-                        foreach ($textArticles as $k => $v) {
-                            $textArticles[$k]->pinyin = $catiall[$v->catid][0];
+                $ceng =  $data['template']['index'];
+                var_dump($ceng, 'ceng================');
+                foreach ($ceng as $k_ceng => $v_ceng) {
+                    $componetList = $v_ceng['componentList'];
+                    //计算一级的所有子级;组成一个数据,key是一级的category_id,value是所有的子级数据,加上个二级的pinyin属性,放的是catiall的数据
+                    foreach ($componetList as $key => $value) {
+                        //取出componentData
+                        $componentData = $value['componentData'];
+                        // $page = $componentData['page'];
+                        // $pageSize = $componentData['pageSize'];
+                        // $listType = $componentData['listType'];
+                        $category_id = $componentData['category_id'] ?? $categoryIds[0];
+                        //此处应该有值
+                        $imgSize = $componentData['imgSize'] ?? 1;
+                        $textSize = $componentData['textSize'] ?? 1;
+                        $level = $componentData['level'] ?? 1;
+                        $child = $componentData['child'] ?? [];
+                        //获取子级
+                        if ($child) {
                         }
-                    }
-                    var_dump($level, 'level');
-                    if ($level > 0) {
-                        // 取出一级的所有子级
-                        //取出所有的子级的imgurl 不为空的数据
-                        $imgArticles = Db::table('article')
-                            // ->where('level', 'like', "%$level%")
-                            // ->whereJsonContains('level', [$level])
-                            ->whereRaw('MATCH(level_text) AGAINST(? IN NATURAL LANGUAGE MODE)', [$level])
-                            ->where('status', 1)
-                            ->whereIn('catid', $categoryIds)
-                            ->whereNotNull('imgurl')
-                            ->where('imgurl', '!=', '')
-                            ->limit($imgSize)
-                            ->orderBy('updated_at', 'desc')
-                            ->get()
-                            ->toArray();
-                        //拼接上拼音
-                        foreach ($imgArticles as $k => $v) {
-                            $imgArticles[$k]->pinyin = $catiall[$v->catid][0] ?? '=====';
+                        $child_id = $child['id'] ?? $categoryIds[0];
+                        $child_imgSize = $child['imgSize'] ?? 1;
+                        $child_textSize = $child['textSize'] ?? 1;
+                        // 拼音就是路由----
+                        // unset($listType['pinyin']);
+                        //查询查询数据,返回到data字段里,根据这几个
+                        if ($category_id > 0) {
+                            var_dump($category_id, '------------------category_id');
+                            var_dump($cat_1st_arr, '-----------1-------2');
+                            // 第一次查询:imgurl 不为空的数据
+                            $imgArticles = Db::table('article')->leftJoin('article_ignore', function ($join) use ($website_id) {
+                                $join->on('article.id', '=', 'article_ignore.article_id')->where('article_ignore.website_id', '=', $website_id);
+                            })->whereNull('article_ignore.article_id')->whereIn('catid', $temp_arr = array_merge([$category_id], $cat_1st_arr[$category_id]))->where('status', 1)->whereNotNull('imgurl')->where('imgurl', '!=', '')->limit($imgSize)->orderBy('updated_at', 'desc')->get()->toArray();
+                            //拼接上拼音
+                            foreach ($imgArticles as $k => $v) {
+                                $imgArticles[$k]->pinyin = $catiall[$v->catid][0];
+                            }
+                            // 第二次查询:imgurl 为空的数据
+                            $textArticles = Db::table('article')->whereIn('catid', $temp_arr = array_merge([$category_id], $cat_1st_arr[$category_id]))->where('status', 1)->limit($textSize)->orderBy('updated_at', 'desc')->get()->toArray();
+                            //拼接上拼音
+                            foreach ($textArticles as $k => $v) {
+                                $textArticles[$k]->pinyin = $catiall[$v->catid][0];
+                            }
                         }
-                        //取出所有的子级的imgurl 为空的数据
-                        $textArticles = Db::table('article')
-                            ->where('status', 1)
-                            // ->where('level', 'like', "%$level%")
-                            // ->whereJsonContains('level', [$level])
-                            ->whereRaw('MATCH(level_text) AGAINST(? IN NATURAL LANGUAGE MODE)', [$level])
-                            ->whereIn('catid', $categoryIds)
-                            ->whereNull('imgurl')
-                            ->limit($textSize)
-                            ->orderBy('updated_at', 'desc')
-                            ->get()
-                            ->toArray();
-                        //拼接上拼音
-                        foreach ($textArticles as $k => $v) {
-                            $textArticles[$k]->pinyin = $catiall[$v->catid][0] ?? '=====';
+                        var_dump($level, 'level');
+                        if ($level > 0) {
+                            // 取出一级的所有子级
+                            //取出所有的子级的imgurl 不为空的数据
+                            $imgArticles = Db::table('article')->whereRaw('MATCH(level_text) AGAINST(? IN NATURAL LANGUAGE MODE)', [$level])->where('status', 1)->whereIn('catid', $categoryIds)->whereNotNull('imgurl')->where('imgurl', '!=', '')->limit($imgSize)->orderBy('updated_at', 'desc')->get()->toArray();
+                            //拼接上拼音
+                            foreach ($imgArticles as $k => $v) {
+                                $imgArticles[$k]->pinyin = $catiall[$v->catid][0] ?? '=====';
+                            }
+                            //取出所有的子级的imgurl 为空的数据
+                            $textArticles = Db::table('article')->where('status', 1)->whereRaw('MATCH(level_text) AGAINST(? IN NATURAL LANGUAGE MODE)', [$level])->whereIn('catid', $categoryIds)->whereNull('imgurl')->limit($textSize)->orderBy('updated_at', 'desc')->get()->toArray();
+                            //拼接上拼音
+                            foreach ($textArticles as $k => $v) {
+                                $textArticles[$k]->pinyin = $catiall[$v->catid][0] ?? '=====';
+                            }
                         }
-                    }
-                    //将查询到的数据放到componentData里
-                    $componetList[$key]['componentData']['data']['alias'] = $websiteInfoIndexed[$category_id]->alias ?? 'aliasnull' . $category_id;
-                    $componetList[$key]['componentData']['data']['pinyin'] = $websiteInfoIndexed[$category_id]->pinyin ?? 'aliasnull' . $category_id;
-                    $componetList[$key]['componentData']['data']['category_id'] = $category_id;
-                    $componetList[$key]['componentData']['data']['textnum'] = $textArticles;
-                    $componetList[$key]['componentData']['data']['imgnum'] = $imgArticles;
-                    //判断child 
-                    if ($child_id > 0) {
-                        //取出子级的imgurl 不为空的数据
-                        $child_imgArticles = Db::table('article')
-                            ->where('catid', $child_id)
-                            ->whereNotNull('imgurl')
-                            ->limit($child_imgSize)
-                            ->orderBy('updated_at', 'desc')
-                            ->get()
-                            ->toArray();
-                        //取出子级的imgurl 为空的数据
-                        $child_textArticles = Db::table('article')
-                            ->where('catid', $child_id)
-                            ->whereNull('imgurl')
-                            ->limit($child_textSize)
-                            ->orderBy('updated_at', 'desc')
-                            ->get()
-                            ->toArray();
                         //将查询到的数据放到componentData里
-                        $componetList[$key]['componentData']['data']['child']['alias'] = $websiteInfoIndexed[$child_id]->alias;
-                        $componetList[$key]['componentData']['data']['child']['pinyin'] = $websiteInfoIndexed[$child_id]->pinyin;
-                        $componetList[$key]['componentData']['data']['child']['category_id'] = $child_id;
-                        $componetList[$key]['componentData']['data']['child']['textnum'] = $child_textArticles;
-                        $componetList[$key]['componentData']['data']['child']['imgnum'] = $child_imgArticles;
-                        //取出自己
-                        $all_childcat = $cat_1st_arr[$category_id];
-                        $processedChildCat = array_map(function ($v) use ($websiteInfoIndexed) {
-                            // 从 $websiteInfoIndexed 中获取对应的数据
-                            $info = $websiteInfoIndexed[$v];
-                            // 返回一个包含所需信息的数组
-                            return [
-                                'pinyin' => $info->pinyin,
-                                'alias' => $info->alias,
-                                'category_id' => $info->category_id,
-                                'aLIas_pinyin' => $info->aLIas_pinyin,
-                                'pid' => $info->pid,
-                                'cat_arr_id' => $info->category_arr_id ?? ['出错'],
-                            ];
-                        }, $all_childcat);
-
-                        $componetList[$key]['componentData']['data']['child']['all_childcat'] = $processedChildCat ?? [];
+                        $componetList[$key]['componentData']['data']['alias'] = $websiteInfoIndexed[$category_id]->alias ?? 'aliasnull' . $category_id;
+                        $componetList[$key]['componentData']['data']['pinyin'] = $websiteInfoIndexed[$category_id]->pinyin ?? 'aliasnull' . $category_id;
+                        $componetList[$key]['componentData']['data']['category_id'] = $category_id;
+                        $componetList[$key]['componentData']['data']['textnum'] = $textArticles;
+                        $componetList[$key]['componentData']['data']['imgnum'] = $imgArticles;
+                        //判断child
+                        if ($child_id > 0) {
+                            //取出子级的imgurl 不为空的数据
+                            $child_imgArticles = Db::table('article')->where('catid', $child_id)->whereNotNull('imgurl')->limit($child_imgSize)->orderBy('updated_at', 'desc')->get()->toArray();
+                            //取出子级的imgurl 为空的数据
+                            $child_textArticles = Db::table('article')->where('catid', $child_id)->whereNull('imgurl')->limit($child_textSize)->orderBy('updated_at', 'desc')->get()->toArray();
+                            //将查询到的数据放到componentData里
+                            $componetList[$key]['componentData']['data']['child']['alias'] = $websiteInfoIndexed[$child_id]->alias;
+                            $componetList[$key]['componentData']['data']['child']['pinyin'] = $websiteInfoIndexed[$child_id]->pinyin;
+                            $componetList[$key]['componentData']['data']['child']['category_id'] = $child_id;
+                            $componetList[$key]['componentData']['data']['child']['textnum'] = $child_textArticles;
+                            $componetList[$key]['componentData']['data']['child']['imgnum'] = $child_imgArticles;
+                            //取出自己
+                            $all_childcat = $cat_1st_arr[$category_id];
+                            $processedChildCat = array_map(function ($v) use ($websiteInfoIndexed) {
+                                // 从 $websiteInfoIndexed 中获取对应的数据
+                                $info = $websiteInfoIndexed[$v];
+                                // 返回一个包含所需信息的数组
+                                return ['pinyin' => $info->pinyin, 'alias' => $info->alias, 'category_id' => $info->category_id, 'aLIas_pinyin' => $info->aLIas_pinyin, 'pid' => $info->pid, 'cat_arr_id' => $info->category_arr_id ?? ['出错']];
+                            }, $all_childcat);
+                            $componetList[$key]['componentData']['data']['child']['all_childcat'] = $processedChildCat ?? [];
+                        }
                     }
+                    $data['template']['index'][$k_ceng]['componentList'] = $componetList;
                 }
                 //将修改后的数据放到template里
-                $data['template']['index'][0]['componentList'] = $componetList;
                 break;
             case 'class':
                 $componetList = $data['template']['class']['data'][0]['componentList'];