|
|
@@ -150,18 +150,19 @@ class ClientService implements ClientServiceInterface
|
|
|
// $page = $componentData['page'];
|
|
|
// $pageSize = $componentData['pageSize'];
|
|
|
// $listType = $componentData['listType'];
|
|
|
- $category_id = $componentData['category_id'] ?? $categoryIds[0];
|
|
|
+ $category_id = $componentData['category_id'] ?? 0;
|
|
|
//此处应该有值
|
|
|
$imgSize = $componentData['imgSize'];
|
|
|
$textSize = $componentData['textSize'];
|
|
|
- $level = $componentData['level'] ?? 1;
|
|
|
- $child = $componentData['child'] ?? [];
|
|
|
+ $level = $componentData['level'];
|
|
|
+ $child = $componentData['child'];
|
|
|
//获取子级
|
|
|
if ($child) {
|
|
|
+ $child_id = $componentData['category_id'] ?? 0;
|
|
|
+ $child_imgSize = $child['imgSize'] ?? 0;
|
|
|
+ $child_textSize = $child['textSize'] ?? 0;
|
|
|
}
|
|
|
- $child_id = $child['id'] ?? $categoryIds[0];
|
|
|
- $child_imgSize = $child['imgSize'] ?? 1;
|
|
|
- $child_textSize = $child['textSize'] ?? 1;
|
|
|
+
|
|
|
// 拼音就是路由----
|
|
|
// unset($listType['pinyin']);
|
|
|
//查询查询数据,返回到data字段里,根据这几个
|
|
|
@@ -200,9 +201,9 @@ class ClientService implements ClientServiceInterface
|
|
|
$imgArticles[$k]->pinyin = $catiall[$v->catid][0] ?? '=====';
|
|
|
}
|
|
|
}
|
|
|
- //取出所有的子级的imgurl 为空的数据
|
|
|
+ //取出所有的子级的imgurl 为空的数据 ->whereNull('imgurl')
|
|
|
if ($textSize > 0) {
|
|
|
- $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();
|
|
|
+ $textArticles = Db::table('article')->where('status', 1)->whereRaw('MATCH(level_text) AGAINST(? IN NATURAL LANGUAGE MODE)', [$level])->whereIn('catid', $categoryIds)->limit($textSize)->orderBy('updated_at', 'desc')->get()->toArray();
|
|
|
//拼接上拼音
|
|
|
foreach ($textArticles as $k => $v) {
|
|
|
$textArticles[$k]->pinyin = $catiall[$v->catid][0] ?? '=====';
|
|
|
@@ -216,11 +217,20 @@ class ClientService implements ClientServiceInterface
|
|
|
$componetList[$key]['componentData']['data']['textnum'] = $textArticles ?? [];
|
|
|
$componetList[$key]['componentData']['data']['imgnum'] = $imgArticles ?? [];
|
|
|
//判断child
|
|
|
+ var_dump($child_id, '--------child_id---');
|
|
|
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();
|
|
|
+ if ($child_imgSize > 0) {
|
|
|
+ $child_imgArticles = Db::table('article')->where('catid', $child_id)->whereNotNull('imgurl')->limit($child_imgSize)->orderBy('updated_at', 'desc')->get()->toArray();
|
|
|
+ } else {
|
|
|
+ $child_imgArticles = [];
|
|
|
+ }
|
|
|
//取出子级的imgurl 为空的数据
|
|
|
- $child_textArticles = Db::table('article')->where('catid', $child_id)->whereNull('imgurl')->limit($child_textSize)->orderBy('updated_at', 'desc')->get()->toArray();
|
|
|
+ if ($child_textSize > 0) {
|
|
|
+ $child_textArticles = Db::table('article')->where('catid', $child_id)->whereNull('imgurl')->limit($child_textSize)->orderBy('updated_at', 'desc')->get()->toArray();
|
|
|
+ } else {
|
|
|
+ $child_textArticles = [];
|
|
|
+ }
|
|
|
//将查询到的数据放到componentData里
|
|
|
$componetList[$key]['componentData']['data']['child']['alias'] = $websiteInfoIndexed[$child_id]->alias;
|
|
|
$componetList[$key]['componentData']['data']['child']['pinyin'] = $websiteInfoIndexed[$child_id]->pinyin;
|
|
|
@@ -232,6 +242,7 @@ class ClientService implements ClientServiceInterface
|
|
|
$processedChildCat = array_map(function ($v) use ($websiteInfoIndexed, $cat_1st_arr) {
|
|
|
// 从 $websiteInfoIndexed 中获取对应的数据
|
|
|
$info = $websiteInfoIndexed[$v];
|
|
|
+ var_dump($info, $v, '-------child循环--------');
|
|
|
// 返回一个包含所需信息的数组
|
|
|
return [
|
|
|
'pinyin' => $info->pinyin,
|