Bläddra i källkod

Merge branch '20250522_diywebfr'

15313670163 2 dagar sedan
förälder
incheckning
968fcc5855
2 ändrade filer med 39 tillägg och 106 borttagningar
  1. 37 105
      app/JsonRpc/PublicRpcService.php
  2. 2 1
      app/JsonRpc/PublicRpcServiceInterface.php

+ 37 - 105
app/JsonRpc/PublicRpcService.php

@@ -1148,50 +1148,6 @@ class PublicRpcService implements PublicRpcServiceInterface
         // 对传入的 page_type 数组进行去重、转换为整数并重新索引
         $data['page_type'] = array_values(array_unique(array_map('intval', $data['page_type'])));
         $data['page_type'] = json_encode($data['page_type']);
-        if($data['component_num'] == 1){
-            $component_arr[0] = [
-                'size_id' => $data['size_id'],
-            ];
-        }else{
-            $size = SectorPlace::where('type',$data['place_type'])
-            ->leftJoin('size','size.id','=','sector_place.size_id')
-            ->select('sector_place.*','size.width','size.height')
-            ->orderBy('sector_place.sort_id','asc')
-            ->get()->all();
-            if(!empty($size)){
-                for ($i=0; $i < $data['component_num']; $i++) { 
-                    $component_arr[$i] = [
-                        'size_id' => $size[$i]['size_id'],
-                        'width' => $size[$i]['width'],
-                        'height' => $size[$i]['height'],
-                        'sort' => $size[$i]['sort_id'],
-                        'place_name' => $size[$i]['name'],
-                    ];
-                }
-            }
-            // $code_arr 
-            
-        }
-        if($data['sector_type'] == 2 || $data['sector_type'] == 3){
-            $sector_code = [
-                'sectorName' => $data['sector_name'],
-                'sectorId' => $data['sector_id'],
-                'sectorType' => $data['sector_type'],
-                'sectorPlace' => $data['place_type'],
-                'compnentList' => $component_arr,
-                'ad' => [],
-            ];
-        }else{
-            $sector_code = [
-                'sectorName' => $data['sector_name'],
-                'sectorId' => $data['sector_id'],
-                'sectorType' => $data['sector_type'],
-                'sectorPlace' => $data['place_type'],
-                'compnentList' => $component_arr,
-            ];
-        }
-        // return Result::success($sector_code);
-        $data['sector_code'] = json_encode($sector_code);
         $template = Template::where('template_id', $data['template_id'])
             ->first();
         if (empty($template)) {
@@ -1201,6 +1157,16 @@ class PublicRpcService implements PublicRpcServiceInterface
         if(!empty($sector_id)){
             return Result::error('通栏编号已存在!');
         }
+        
+        // 通栏分类:1:资讯类:2:通栏广告类;3:混合类;4:头条类;5:轮播图类;
+        $sector_code = [
+            'sectorName' => $data['sector_name'],
+            'sectorId' => $data['sector_id'],
+            'sectorType' => $data['sector_type'],
+            'sectorPlace' => $data['place_type'],
+        ];
+        // return Result::success($sector_code);
+         $data['sector_code'] = json_encode($sector_code);
         $result = Sector::insertGetId($data);
         if (empty($result)) {
             return Result::error('添加失败');
@@ -1243,49 +1209,12 @@ class PublicRpcService implements PublicRpcServiceInterface
                 return Result::error('通栏编号已存在!');
             }
         }
-        if($data['component_num'] == 1){
-            $component_arr[0] = [
-                'size_id' => $data['size_id'],
-            ];
-        }else{
-            $size = SectorPlace::where('type',$data['place_type'])
-            ->leftJoin('size','size.id','=','sector_place.size_id')
-            ->select('sector_place.*','size.width','size.height')
-            ->orderBy('sector_place.sort_id','asc')
-            ->get()->all();
-            if(!empty($size)){
-                for ($i=0; $i < $data['component_num']; $i++) { 
-                    $component_arr[$i] = [
-                        'size_id' => intval($size[$i]['size_id']),
-                        'width' => intval($size[$i]['width']),
-                        'height' => intval($size[$i]['height']),
-                        'sort' => intval($size[$i]['sort_id']),
-                        'place_name' => strval($size[$i]['name']),
-                    ];
-                }
-            }
-            // $code_arr 
-            
-        }
-        if($data['sector_type'] == 2 || $data['sector_type'] == 3){
-            $sector_code = [
-                'sectorName' => strval($data['sector_name']),
-                'sectorId' => intval($data['sector_id']),
-                'sectorType' => intval($data['sector_type']),
-                'sectorPlace' => intval($data['place_type']),
-                'compnentList' => $component_arr,
-                'ad' => [],
-            ];
-        }else{
-            $sector_code = [
-                'sectorName' => strval($data['sector_name']),
-
-                'sectorId' => intval($data['sector_id']),
-                'sectorType' => intval($data['sector_type']),
-                'sectorPlace' => intval($data['place_type']),
-                'compnentList' => $component_arr,
-            ];
-        }
+        $sector_code = [
+            'sectorName' => strval($data['sector_name']),
+            'sectorId' => intval($data['sector_id']),
+            'sectorType' => intval($data['sector_type']),
+            'sectorPlace' => intval($data['place_type']),
+        ];
         // return Result::success($sector_code);
         $data['sector_code'] = json_encode($sector_code);
         // 对传入的 page_type 数组进行去重、转换为整数并重新索引
@@ -1613,24 +1542,6 @@ class PublicRpcService implements PublicRpcServiceInterface
         }
         return Result::success($template);
     }
-    /**
-     * 自助建站-通栏管理-获取通栏位置
-     */
-    public function getSectorPlace(array $data): array
-    {
-        if(isset($data['sector_num']) && !empty($data['sector_num'])){
-            $where['sector_place.component_num'] = $data['sector_num'];
-            $template =  SectorPlace::where('sector_place.type_id',1)
-            ->where($where)
-            ->leftJoin('size','sector_place.size_id','=','size.id')
-            ->select('sector_place.*','size.width','size.height')
-            ->get();
-        }
-        if(empty($template)){
-            return Result::error('未查询到相关通栏版式!');
-        }
-        return Result::success($template);
-    }
 
     /**
      * 通栏版式管理-获取通栏版式列表
@@ -1851,4 +1762,25 @@ class PublicRpcService implements PublicRpcServiceInterface
         }
         return Result::success($sort);
     }
+    /**
+     * 获取所有通栏版式
+     */ 
+    public function getAllSectorPlace(array $data): array
+    {
+        $where['type_id'] = $data['type_id'];
+        if(isset($data['sector_type']) && !empty($data['sector_type'])){
+            $where['sector_type'] = $data['sector_type'];
+        }
+        if(isset($data['component_num']) && !empty($data['component_num'])){
+            $where['component_num'] = $data['component_num'];
+        }
+       $sector_place = SectorPlace::where($where)
+       ->leftJoin('size','sector_place.size_id','=','size.id') 
+       ->select('sector_place.*','size.width','size.height')
+       ->get()->all();
+       if(empty($sector_place)){
+            return Result::error('通栏版式不存在!');
+       }
+       return Result::success($sector_place);
+    }
 }

+ 2 - 1
app/JsonRpc/PublicRpcServiceInterface.php

@@ -184,7 +184,6 @@ interface PublicRpcServiceInterface
     public function getAllTemplate(array $data): array;
     public function getWebsiteTemplate(array $data): array;
     public function getAllSize(array $data): array;
-    public function getSectorPlace(array $data): array;
 
     // 通栏版式管理-获取通栏版式列表
     public function getSectorPlaceList(array $data): array;
@@ -194,4 +193,6 @@ interface PublicRpcServiceInterface
     public function getSectorPlaceInfo(array $data): array;
     // 通栏版式管理-通栏版式位置
     public function getSectorPlaceSort(array $data): array;
+    //-所有通栏版式
+    public function getAllSectorPlace(array $data): array;
 }