Sfoglia il codice sorgente

Merge branch 'web_sannong_fr'

15313670163 3 settimane fa
parent
commit
4001c1aa0f
1 ha cambiato i file con 21 aggiunte e 12 eliminazioni
  1. 21 12
      app/JsonRpc/WebsiteService.php

+ 21 - 12
app/JsonRpc/WebsiteService.php

@@ -2088,7 +2088,7 @@ class WebsiteService implements WebsiteServiceInterface
     }
 
     /*
-     * 获取父级/子级栏目
+     * 获取父级/子级栏目------路由
      * @param array $data
      * @return array
      * */
@@ -2105,14 +2105,17 @@ class WebsiteService implements WebsiteServiceInterface
             // 因此,需要先调用 `get()` 方法获取查询结果集合,再使用 `map` 方法进行处理。
             $category['parent'] = WebsiteCategory::where('website_id', $data['website_id'])
                 ->where('pid', 0)
-                ->select('alias_pinyin', 'category_id', 'alias')
+                ->select('aLIas_pinyin', 'category_id', 'alias')
                 ->get() // 添加 get() 方法获取结果集合
                 ->map(function ($item) {
-                    return [
-                        'path' => "/{$item->alias_pinyin}/",
+                    $result = [
                         'name' => $item->alias,
                         'cid' => $item->category_id
                     ];
+                    if (!empty($item->aLIas_pinyin)) {
+                        $result['path'] = "/{$item->aLIas_pinyin}/";
+                    }
+                    return $result;
                 })
                 ->values()
                 ->all();
@@ -2130,11 +2133,14 @@ class WebsiteService implements WebsiteServiceInterface
                     ->where('category_id', $item->pid)
                     ->first();
                 $parentAlias = $parent ? $parent->aLIas_pinyin : '';
-                return [
-                    'path' => "/{$parentAlias}/{$alias_pinyin}/",
-                    'name' => $alias ? "{$alias}" : null,
-                    'cid' => $category_id ? "{$category_id}" : null
+                $result = [
+                    'name' => $alias,
+                    'cid' => $category_id
                 ];
+                if (!empty($alias_pinyin) && !empty($parentAlias)) {
+                    $result['path'] = "/{$parentAlias}/{$alias_pinyin}/";
+                }
+                return $result;
             })->values()->all();
         // }else if($data['id'] == 2){
             $foot = FooterCategory::where('website_id', $data['website_id'])
@@ -2143,11 +2149,14 @@ class WebsiteService implements WebsiteServiceInterface
                     $name = $item->name;
                     $id = $item->id;
                     $alias_pinyin = $item->name_pinyin;
-                    return [
-                        'path' => "/{$alias_pinyin}/",
-                        'name' => $name ? "{$name}" : null,
-                        'cid' => $id ? "{$id}" : null
+                    $result = [
+                        'name' => $name,
+                        'cid' => $id
                     ];
+                    if (!empty($item->name_pinyin)) {
+                        $result['path'] = "/{$item->name_pinyin}/";
+                    }
+                    return $result;
                 })->values()->all();
         // }else{
         //     return Result::error("请输入正确的id", 0);