Эх сурвалжийг харах

修改接口:添加、修改组件;

15313670163 1 өдөр өмнө
parent
commit
cbd9b7bcdc

+ 11 - 1
app/JsonRpc/PublicRpcService.php

@@ -1511,6 +1511,10 @@ class PublicRpcService implements PublicRpcServiceInterface
         if(empty($component)){
             return Result::error('组件不存在!');
         }
+        $ad_img = WebsiteImg::where('id',$component['ad_imgid'])->first();
+        if(!empty($ad_img)){
+            $ad_img = WebsiteImg::where('id',$component['ad_imgid'])->delete();
+        }
         $result = Component::where('id',$data['id'])->delete();
         if(empty($result)){
             return Result::error('删除失败!');
@@ -1736,7 +1740,13 @@ class PublicRpcService implements PublicRpcServiceInterface
               
             }
             if($data['type_id'] == 11 && $component['type_id'] == $data['type_id']){
-                $website_img = WebsiteImg::where('id',$component['ad_imgid'])->update($ad_imginfo);
+                $website_img = WebsiteImg::where('id',$component['ad_imgid'])->first();
+                if(empty($website_img)){
+                    $website_img = WebsiteImg::insertGetId($ad_imginfo);
+                    $add_arr['ad_imgid'] = $website_img;
+                }else{
+                    $website_img = WebsiteImg::where('id',$component['ad_imgid'])->update($ad_imginfo);
+                }
                 if(empty($website_img)){
                     Db::rollBack();
                     return Result::error('广告默认图修改失败!');