Browse Source

前端-三农资讯网修改获取栏目的接口

15313670163 2 months ago
parent
commit
24f0761d97
2 changed files with 25 additions and 15 deletions
  1. 2 2
      .env
  2. 23 13
      app/JsonRpc/WebsiteService.php

+ 2 - 2
.env

@@ -2,11 +2,11 @@ APP_NAME=public_producer
 APP_ENV=dev
 HOST = http://101.254.114.211:13306/
 DB_DRIVER=mysql
-DB_HOST=101.254.114.211
+DB_HOST=192.168.1.123
 DB_PORT=13306
 DB_DATABASE=hyperf
 DB_USERNAME=root
-DB_PASSWORD=xKmapDpKCxMMSkbe
+DB_PASSWORD=zxt_mysql_dev
 DB_CHARSET=utf8mb4
 DB_COLLATION=utf8mb4_unicode_ci
 DB_PREFIX=

+ 23 - 13
app/JsonRpc/WebsiteService.php

@@ -615,23 +615,33 @@ class WebsiteService implements WebsiteServiceInterface
 
     public function getWebsiteModelCategory(array $data): array
     {
-        $website_id = [
-            'website_id' => $data['website_id'],
+        $website_id=[ 
+            'website_category.website_id' => $data['website_id'] 
         ];
-        $placeid = $data['placeid'] - 1;
-        $pid = [
-            'pid' => $data['pid'],
+        $placeid=$data['placeid']-1; 
+        $pid=[
+            'website_category.pid' => $data['pid'], 
         ];
+        var_dump( "=======",$pid);
         $num = $data['num'];
-        $result = WebsiteCategory::where($website_id)->where($pid)->withCount(['children' => function ($query) use ($website_id) {
+        // return Result::success($data);
+        $result=WebsiteCategory::where($website_id)
+        ->leftJoin("category",'website_category.category_id','category.id')
+        ->select('website_category.*','category.is_url','category.web_url')
+        ->where($pid)
+        ->withCount(['children' => function ($query) use ($website_id) {
             $query->where($website_id);
-        }])->orderBy('sort')->offset($placeid)->limit($num)->get();
-
-        if (!empty($result)) {
-            return Result::success($result);
-        } else {
-            return Result::error("本网站暂无栏目", 0);
-        }
+        }])
+        ->orderBy('website_category.sort')
+        
+        ->offset($placeid)
+        ->limit($num)->get();
+        return Result::success($result);
+        if(!empty($result)){ 
+            return Result::success($result);  
+        }else{ 
+            return Result::error("本网站暂无栏目",0);  
+        } 
 
     }