Bladeren bron

Merge branch '20250210_lj_zhanqun' into dev

AI 4 maanden geleden
bovenliggende
commit
57efa7d603
2 gewijzigde bestanden met toevoegingen van 182 en 79 verwijderingen
  1. 173 75
      app/JsonRpc/WebsiteService.php
  2. 9 4
      app/JsonRpc/WebsiteServiceInterface.php

+ 173 - 75
app/JsonRpc/WebsiteService.php

@@ -1269,36 +1269,34 @@ class WebsiteService implements WebsiteServiceInterface
         }
         return Result::success($websiteInfo->toArray());
     }
-    
 
-
-     /**
+    /**
      * 获取网站底部基础信息
      * @param array $data
      * @return array
      */
     public function getWebsiteFootInfo(array $data): array
     {
-        if(isset($data['website_id']) && !empty($data['website_id'])){
-            $website = Website::where('id',$data['website_id'])->where('status',1)->first();
+        if (isset($data['website_id']) && !empty($data['website_id'])) {
+            $website = Website::where('id', $data['website_id'])->where('status', 1)->first();
             if (empty($website)) {
-                return Result::error("找不到网站",0); 
+                return Result::error("找不到网站", 0);
             }
-        }else{
-            return Result::error("参数错误",0);
+        } else {
+            return Result::error("参数错误", 0);
         }
-        $website_foot = WebsiteTemplateInfo::where('website_id',$data['website_id'])->where('status',2)->first();
-        $website_head = Website::where('id',$data['website_id'])
-        ->select('id','website_name','logo','title','keywords','description')->first();
+        $website_foot = WebsiteTemplateInfo::where('website_id', $data['website_id'])->where('status', 2)->first();
+        $website_head = Website::where('id', $data['website_id'])
+            ->select('id', 'website_name', 'logo', 'title', 'keywords', 'description')->first();
         if (empty($website_foot)) {
-            return Result::error("暂无底部基础信息",0);
+            return Result::error("暂无底部基础信息", 0);
         }
         if (empty($website_head)) {
-            return Result::error("暂无头部基础信息",0);
+            return Result::error("暂无头部基础信息", 0);
         }
         $result = [
-            'website_foot'=>$website_foot,
-            'website_head'=>$website_head
+            'website_foot' => $website_foot,
+            'website_head' => $website_head,
         ];
         return Result::success($result);
     }
@@ -1309,17 +1307,17 @@ class WebsiteService implements WebsiteServiceInterface
      */
     public function getWebsiteFooterCategory(array $data): array
     {
-        if(isset($data['website_id']) && !empty($data['website_id'])){
-            $website = Website::where('id',$data['website_id'])->where('status',1)->first();
+        if (isset($data['website_id']) && !empty($data['website_id'])) {
+            $website = Website::where('id', $data['website_id'])->where('status', 1)->first();
             if (empty($website)) {
-                return Result::error("找不到网站",0); 
+                return Result::error("找不到网站", 0);
             }
-        }else{
-            return Result::error("参数错误",0);
+        } else {
+            return Result::error("参数错误", 0);
         }
-        $result = FooterCategory::where('website_id',$data['website_id'])->get();
+        $result = FooterCategory::where('website_id', $data['website_id'])->get();
         if (empty($result)) {
-            return Result::error("暂无底部导航",0);
+            return Result::error("暂无底部导航", 0);
         }
         return Result::success($result->toArray());
     }
@@ -1330,25 +1328,25 @@ class WebsiteService implements WebsiteServiceInterface
      */
     public function getWebsiteFooterCategoryList(array $data): array
     {
-        if(isset($data['website_id']) && !empty($data['website_id'])){
-            $website = Website::where('id',$data['website_id'])->where('status',1)->first();
+        if (isset($data['website_id']) && !empty($data['website_id'])) {
+            $website = Website::where('id', $data['website_id'])->where('status', 1)->first();
             if (empty($website)) {
-                return Result::error("找不到网站",0); 
+                return Result::error("找不到网站", 0);
             }
-        }else{
-            return Result::error("参数错误",0);
+        } else {
+            return Result::error("参数错误", 0);
         }
-        $footercategory = FooterCategory::where('website_id',$data['website_id'])->where('id',$data['fcat_id'])->first();
+        $footercategory = FooterCategory::where('website_id', $data['website_id'])->where('id', $data['fcat_id'])->first();
         // '底部导航类型   0:内容型;1:列表型;',
         if (!isset($footercategory['type']) || $footercategory['type'] == 0) {
-            return Result::error("底部导航id错误",0);
-        }else{
-            $query = FooterContent::where('fcat_id',$data['fcat_id']);
-            if($query->count() == 0){
-                return Result::error("暂无底部导航列表",0); 
-            }elseif($query->count() == 1){
+            return Result::error("底部导航id错误", 0);
+        } else {
+            $query = FooterContent::where('fcat_id', $data['fcat_id']);
+            if ($query->count() == 0) {
+                return Result::error("暂无底部导航列表", 0);
+            } elseif ($query->count() == 1) {
                 $result = $query->first();
-            }else{
+            } else {
                 $result = $query->get();
             }
         }
@@ -1361,25 +1359,25 @@ class WebsiteService implements WebsiteServiceInterface
      */
     public function getWebsiteFooterCategoryInfo(array $data): array
     {
-        if(isset($data['website_id']) && !empty($data['website_id'])){
-            $website = Website::where('id',$data['website_id'])->where('status',1)->first();
+        if (isset($data['website_id']) && !empty($data['website_id'])) {
+            $website = Website::where('id', $data['website_id'])->where('status', 1)->first();
             if (empty($website)) {
-                return Result::error("找不到网站",0); 
+                return Result::error("找不到网站", 0);
             }
-        }else{
-            return Result::error("参数错误",0);
+        } else {
+            return Result::error("参数错误", 0);
         }
         if (isset($data['type']) && $data['type'] == 0) {
-            $fcatid = FooterCategory::where('website_id',$data['website_id'])->where('id',$data['fcat_id'])->first();
+            $fcatid = FooterCategory::where('website_id', $data['website_id'])->where('id', $data['fcat_id'])->first();
             if (empty($fcatid)) {
-                return Result::error("底部导航id错误",0);
+                return Result::error("底部导航id错误", 0);
             }
-            $result = FooterContent::where('fcat_id',$data['fcat_id'])->first();
-        }else{
-            $result = FooterContent::where('id',$data['fcat_id'])->first();
+            $result = FooterContent::where('fcat_id', $data['fcat_id'])->first();
+        } else {
+            $result = FooterContent::where('id', $data['fcat_id'])->first();
         }
         if (empty($result)) {
-            return Result::error("暂无底部导航内容",0);
+            return Result::error("暂无底部导航内容", 0);
         }
         return Result::success($result);
     }
@@ -1390,15 +1388,15 @@ class WebsiteService implements WebsiteServiceInterface
      * */
     public function selectWebsiteCategory(array $data): array
     {
-        if(isset($data['website_id']) &&!empty($data['website_id'])){
-            $website = Website::where('id',$data['website_id'])->where('status',1)->first(); 
+        if (isset($data['website_id']) && !empty($data['website_id'])) {
+            $website = Website::where('id', $data['website_id'])->where('status', 1)->first();
             if (empty($website)) {
-                return Result::error("暂无该网站",0); 
+                return Result::error("暂无该网站", 0);
             }
-            $category = WebsiteCategory::where('website_id',$data['website_id'])->where('pid',$data['pid'])->pluck('category_id')->all();
+            $category = WebsiteCategory::where('website_id', $data['website_id'])->where('pid', $data['pid'])->pluck('category_id')->all();
             // return Result::success($category);
             if (empty($category)) {
-                return Result::error("暂无二级导航",0); 
+                return Result::error("暂无二级导航", 0);
             }
             $query = Category::whereIn('id', $category);
             if (isset($data['cityid']) && !empty($data['cityid'])) {
@@ -1409,7 +1407,7 @@ class WebsiteService implements WebsiteServiceInterface
                     $result = $query->whereRaw('JSON_CONTAINS(city_arr_id,?)', [$data['cityid']])->get();
                     // $where[] = ['JSON_CONTAINS(city_arr_id, ?)', $data['cityid']];
                     if (empty($result)) {
-                        return Result::error("暂无此城市下的二级导航", 0); 
+                        return Result::error("暂无此城市下的二级导航", 0);
                     }
                     $city = 1;
                     // var_dump("城市====================",$result);
@@ -1428,19 +1426,19 @@ class WebsiteService implements WebsiteServiceInterface
                     $department = 1;
                 }
             }
-           if(!empty($city) && !empty($department)){
-            // var_dump("城市和职能部门----------------------",$result);
+            if (!empty($city) && !empty($department)) {
+                // var_dump("城市和职能部门----------------------",$result);
                 $result = $query->whereRaw('JSON_CONTAINS(city_arr_id,?)', [$data['cityid']])->whereRaw('JSON_CONTAINS(department_arr_id,?)', [$data['department_id']])->get();
-           }else{
+            } else {
                 $result = $query->get();
-           }
+            }
             if (empty($result)) {
-                return Result::error("暂无二级导航",0);
-            }  
-            
+                return Result::error("暂无二级导航", 0);
+            }
+
             // department_id
-        }else{
-            return Result::error("参数错误",0);
+        } else {
+            return Result::error("参数错误", 0);
         }
         return Result::success($result);
     }
@@ -1456,38 +1454,138 @@ class WebsiteService implements WebsiteServiceInterface
             array_push($where, ['website_id', '=', $data['website_id']]);
         }
         if (isset($data['catid']) && !empty($data['catid'])) {
-            $fcatid = WebsiteCategory::where('website_id',$data['website_id'])->where('category_id',$data['catid'])->first();
+            $fcatid = WebsiteCategory::where('website_id', $data['website_id'])->where('category_id', $data['catid'])->first();
             if (empty($fcatid)) {
-                return Result::error("导航id错误",0);
+                return Result::error("导航id错误", 0);
             }
-            $result = Category::where('id',$data['catid'])->first();
+            $result = Category::where('id', $data['catid'])->first();
         }
         if (empty($result)) {
-            return Result::error("暂无导航",0);
+            return Result::error("暂无导航", 0);
         }
         return Result::success($result);
     }
-     /*
+    /*
      * 获取某个导航
      * @param array $data
      * @return array
      * */
     public function getOneWebsiteCategory(array $data): array
     {
-        if(isset($data['website_id']) &&!empty($data['website_id'])){
-            $website = Website::where('id',$data['website_id'])->where('status',1)->first(); 
+        if (isset($data['website_id']) && !empty($data['website_id'])) {
+            $website = Website::where('id', $data['website_id'])->where('status', 1)->first();
             if (empty($website)) {
-                return Result::error("暂无该网站",0); 
+                return Result::error("暂无该网站", 0);
             }
-            $result = WebsiteCategory::where('website_id',$data['website_id'])->where('category_id',$data['category_id'])->select('category_id','name')->first();
+            $result = WebsiteCategory::where('website_id', $data['website_id'])->where('category_id', $data['category_id'])->select('category_id', 'name')->first();
             // return Result::success($category);
             if (empty($result)) {
-                return Result::error("暂无此导航",0); 
-            }            
+                return Result::error("暂无此导航", 0);
+            }
             // department_id
-        }else{
-            return Result::error("参数错误",0);
+        } else {
+            return Result::error("参数错误", 0);
         }
         return Result::success($result);
     }
-}
+
+    //20250212  网站标识
+    public function addWebsiteGroup(array $data): array
+    {
+        //添加信息
+        $result = WebsiteGroup::insertGetId($data);
+        var_dump($result);
+        if (empty($result)) {
+            return Result::error("创建失败", 0);
+        } else {
+            return Result::success($result);
+        }
+    }
+    public function getWebsiteGroupList(array $data): array
+    {
+        $where = [];
+        if (isset($data['name']) && !empty($data['name'])) {
+            array_push($where, ['website_group.name', 'like', '%' . $data['name'] . '%']);
+        }
+        $result = WebsiteGroup::where($where)
+            ->limit($data['pageSize'])->orderBy("id", "desc")->offset(($data['page'] - 1) * $data['pageSize'])
+            ->get();
+
+        foreach ($result as $websiteGroup) {
+            $webIds = json_decode($websiteGroup->web_ids, true);
+            $websites = Website::whereIn('id', $webIds)->get();
+            $websiteNames = $websites->pluck('website_name', 'id')->toArray();
+            $websiteGroup->website_names = $websiteNames;
+            $websiteGroup->website_names1 = implode(',', array_values($websiteNames));
+        }
+        $count = WebsiteGroup::where($where)->count();
+        if (empty($result)) {
+            return Result::error("没有数据", 0);
+        }
+        return Result::success(['list' => $result->toArray(), 'count' => $count]);
+    }
+    public function getWebsiteGroupInfo(array $data): array
+    {
+        $websiteInfo = WebsiteGroup::query()->where('id', $data['id'])->first();
+        $webIds = json_decode($websiteInfo->web_ids, true);
+        $websites = Website::whereIn('id', $webIds)->get();
+        $websiteNames = $websites->pluck('website_name', 'id')->toArray();
+        $websiteInfo->website_names = $websiteNames;
+        $websiteInfo->website_names1 = implode(',', array_values($websiteNames));
+        if (empty($websiteInfo)) {
+            return Result::error("找不到URL", 0);
+        }
+        return Result::success($websiteInfo->toArray());
+    }
+    public function updateWebsiteGroup(array $data): array
+    {
+        $where = [
+            'id' => $data['id'],
+        ];
+        $insertData = [
+            'name' => $data['name'],
+            'web_ids' => $data['web_ids'],
+        ];
+        $result = WebsiteGroup::where($where)->update($insertData);
+        var_dump($result, '------更新');
+        if (empty($result)) {
+            return Result::error("更新失败", 0);
+        } else {
+            return Result::success();
+        }
+    }
+    public function deleteWebsiteGroup(array $data): array
+    {
+        $where = [
+            'id' => $data['id'],
+        ];
+        //看看user表是不是有这个id
+        $userGroup = User::query()->where('sszq', $data['id'])->first();
+        if (!empty($userGroup)) {
+            return Result::error("有用户在使用该网站标识,不能删除", 0);
+        }
+        $result = WebsiteGroup::where($where)->delete();
+        if (empty($result)) {
+            return Result::error("删除失败", 0);
+        } else {
+            return Result::success();
+        }
+    }
+    public function getWebsiteNavList(array $data): array
+    {
+        $where = [];
+        if (isset($data['website_id']) && !empty($data['website_id'])) {
+            array_push($where, ['website_id', '=', $data['website_id']]);
+        }
+        if (isset($data['pid']) && !empty($data['pid'])) {
+            array_push($where, ['pid', '=', $data['pid']]);
+        }
+        $list = WebsiteCategory::query()->where($where)->get();
+        if (empty($list)) {
+            return Result::error("获取失败", 0);
+        } else {
+            return Result::success($list);
+        }
+    }
+    //20250212  网站标识
+}

+ 9 - 4
app/JsonRpc/WebsiteServiceInterface.php

@@ -64,21 +64,17 @@ interface WebsiteServiceInterface
     public function upWebsiteCategory(array $data): array;
     public function getWebsiteCategoryList(array $data): array;
 
-
     public function delWebsiteAllCategory(array $data): array;
     public function getWebsiteCategoryOnes(array $data): array;
     public function upWebsiteCategoryones(array $data): array;
     public function getWebsiteAllCategory(array $data): array;
 
-
     public function getWebsiteAdvertisement(array $data): array;
     public function selectWebsiteDepartment(array $data): array;
     public function selectWebsiteArea(array $data): array; //
     public function getWebsiteModelCategory(array $data): array;
     public function selectWebsiteLinks(array $data): array;
 
-
-
     public function getWebsiteFootInfo(array $data): array;
     public function getWebsiteFooterCategory(array $data): array;
     public function getWebsiteFooterCategoryList(array $data): array;
@@ -87,4 +83,13 @@ interface WebsiteServiceInterface
     public function getWebsiteCategoryHead(array $data): array;
 
     public function getOneWebsiteCategory(array $data): array;
+    //20250212  网站标识
+    public function addWebsiteGroup(array $data): array;
+    public function getWebsiteGroupList(array $data): array;
+    public function deleteWebsiteGroup(array $data): array;
+    public function getWebsiteGroupInfo(array $data): array;
+    public function updateWebsiteGroup(array $data): array;
+    public function getWebsiteNavList(array $data): array;
+    //20250212  网站标识
+
 }