Przeglądaj źródła

修改c端接口:验证网站路由的接口

15313670163 5 miesięcy temu
rodzic
commit
2bc1edc287
1 zmienionych plików z 18 dodań i 13 usunięć
  1. 18 13
      app/JsonRpc/NewsService.php

+ 18 - 13
app/JsonRpc/NewsService.php

@@ -3614,11 +3614,11 @@ class NewsService implements NewsServiceInterface
               $query->whereRaw("JSON_CONTAINS(ignore_ids, '" . intval($data['website_id']) . "') = 0")
                 ->orWhereNull("ignore_ids");
             })
-            ->first(['cat_arr_id']);
+            ->first(['catid']);
           if (empty($article)) {
             return Result::error("该文章不存在", 0);
           }
-          // return Result::success($article);
+        //   return Result::success($article);
           break;
         case 2:
           // 商品
@@ -3692,33 +3692,38 @@ class NewsService implements NewsServiceInterface
           return Result::error("该数据不存在", 0);
           break;
       }
-      $catid = 0;
-      $catidArray = json_decode($article['cat_arr_id'], true);
-      $catid = !empty($catidArray) ? end($catidArray) : null;
-      //    return Result::success($article['cat_arr_id']);
+    //   return Result::success($article);
+      $catid =0 ;
+      
+      if(!isset($article['cat_arr_id'])){
+        $catid = isset($article['catid']) ? $article['catid'] : (isset($article['category_id']) ? $article['category_id'] : null);
+      }else{
+        $catidArray = json_decode($article['cat_arr_id'], true);
+        $catid = !empty($catidArray) ? end($catidArray) : null;
+      }
+    //   return Result::success($catid);
+    //    return Result::success($article['cat_arr_id']);
       if (empty($catid)) {
         return Result::error("该数据不存在", 0);
       }
 
       $pinyin = WebsiteCategory::where('website_id', $data['website_id'])
         ->where('category_id',$catid)
-        ->first('path')
-        ->toArray();
+        ->first('path');
     }else{
         // if ($last_category['pid'] != 0) {
             $cat_arr = json_decode($last_category['category_arr_id'], true);
-            $catid = !empty($cat_arr) ? end($cat_arr) : null;
+            $catid = !empty($cat_arr) && is_array($cat_arr) ? end($cat_arr) : null;
             $pinyin = WebsiteCategory::where('website_id', $data['website_id'])
                 ->where('category_id',$catid)
                 ->where('path',$data['all_route'])
-                ->first('path')
-                ->toArray();
+                ->first('path');
         // } else {
         //     $pinyin[0] = $last_category['aLIas_pinyin'];
         // }
     }
-    // return Result::success($pinyin[0]);
-    if (empty($pinyin) || count($pinyin)>1 || $pinyin['path'] != $data['all_route']) {
+    // return Result::success($pinyin);
+    if (empty($pinyin)  || $pinyin['path'] != $data['all_route']) {
       return Result::error('非法路径!');
     } else {
       return Result::success($pinyin);