Browse Source

修改b端接口:添加组件样式、修改组件样式、

15313670163 16 hours ago
parent
commit
cbe95b88cd
1 changed files with 19 additions and 7 deletions
  1. 19 7
      app/JsonRpc/PublicRpcService.php

+ 19 - 7
app/JsonRpc/PublicRpcService.php

@@ -2613,9 +2613,15 @@ class PublicRpcService implements PublicRpcServiceInterface
     public function addComponentImg(array $data): array
     {
         unset($data['user_id']);
-        $img = ComponentImg::where('component_id',$data['component_id'])->where('template_id',$data['template_id'])->get()->all();
-        if(!empty($img)){
-            return Result::error('该组件已存在此皮肤的预览图!');
+        $component = Component::where('component_type',$data['component_id'])->first();
+        if(empty($component)){
+            return Result::error('组件不存在!');
+        }
+        if($component['type_id'] == 11){
+             $img = ComponentImg::where('component_id',$data['component_id'])->where('template_id',$data['template_id'])->get()->all();
+            if(!empty($img)){
+                return Result::error('该组件已存在此皮肤的预览图!');
+            }
         }
         $component = ComponentImg::where('component_id',$data['component_id'])->where('img_id',$data['img_id'])->first();
         if(!empty($component)){
@@ -2643,14 +2649,20 @@ class PublicRpcService implements PublicRpcServiceInterface
      */
     public function updateComponentImg(array $data): array
     {
+        $component = Component::where('component_type',$data['component_id'])->first();
+        if(empty($component)){
+            return Result::error('组件不存在!');
+        }
+
         $img = ComponentImg::where('id','!=',$data['id'])->where('component_id',$data['component_id'])->where('template_id',$data['template_id'])->get()->all();
         if(!empty($img)){
             return Result::error('该组件已存在此皮肤的预览图!');
         }
-        $component = ComponentImg::where('component_id',$data['component_id'])->where('id','!=',$data['id'])->where('img_id',$data['img_id'])->first();
-
-        if(!empty($component)){
-            return Result::error('组件预览图编号已存在!');
+         if($component['type_id'] == 11){
+             $img = ComponentImg::where('component_id',$data['component_id'])->where('template_id',$data['template_id'])->get()->all();
+            if(!empty($img)){
+                return Result::error('该组件已存在此皮肤的预览图!');
+            }
         }
         unset($data['user_id']);
         // unset($data['updated_at']);