Răsfoiți Sursa

Merge branch '20250522_diywebfr'

15313670163 17 ore în urmă
părinte
comite
3db113e6f7

+ 73 - 0
app/JsonRpc/PublicRpcService.php

@@ -42,6 +42,8 @@ use App\Model\WebsiteCategory;
 use App\Model\AdPlace;
 use App\Model\WebsiteImg;
 use App\Model\SectorComponent;
+use App\Model\ComponentImg;
+
 #[RpcService(name: "PublicRpcService", protocol: "jsonrpc-http", server: "jsonrpc-http")]
 class PublicRpcService implements PublicRpcServiceInterface
 {
@@ -2567,4 +2569,75 @@ class PublicRpcService implements PublicRpcServiceInterface
         }
         return Result::success($sector);
     }
+    /**
+     * 自助建站-组件管理-获取组件预览图列表
+     */
+    public function getComponentImgList(array $data): array
+    {
+        
+        $where['component_img.component_id'] = $data['component_id'];
+        if(isset($data['template_id']) && !empty($data['template_id'])){
+            $where['component_img.template_id'] = $data['template_id'];
+        }
+        $component_img = ComponentImg::where($where)
+        ->leftJoin('template','component_img.template_id','=','template.template_id')
+        ->leftJoin('component','component_img.component_id','=','component.component_type')
+        ->select('component_img.*','template.template_name','component.component_name')
+        ->paginate($data['page_size'], ['*'], 'page', $data['page']);
+        if(empty($component_img)){
+            return Result::error('组件预览图不存在!');
+        }
+        return Result::success($component_img);
+    }
+    /**
+     * 自助建站-组件管理-添加组件预览图
+     */
+    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_img = ComponentImg::insertGetId($data);
+        if(empty($component_img)){
+            return Result::error('添加失败!');
+        }
+        return Result::success($component_img);
+    }
+    /**
+     * 自助建站-组件管理-删除组件预览图
+     */
+    public function delComponentImg(array $data): array
+    {
+        $component_img = ComponentImg::where('id',$data['id'])->delete();
+        if(empty($component_img)){
+            return Result::error('删除失败!');
+        }
+        return Result::success($component_img);
+    }
+    /**
+     * 自助建站-组件管理-更新组件预览图
+     */
+    public function updateComponentImg(array $data): array
+    {
+        $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('该组件已存在此皮肤的预览图!');
+        }
+        unset($data['user_id']);
+        // unset($data['updated_at']);
+        $id = $data['id'];
+        unset($data['id']);
+        // return Result::success($data);
+
+        $component_img = ComponentImg::where('id',$id)->update($data);
+        if(empty($component_img)){
+            return Result::error('更新失败!');
+        }
+        return Result::success($component_img);
+    }
+
+
+
 }

+ 11 - 0
app/JsonRpc/PublicRpcServiceInterface.php

@@ -201,5 +201,16 @@ interface PublicRpcServiceInterface
     public function getAllSector(array $data): array;
     //组件管理-获取所有组件
     public function getAllComponent(array $data): array;
+    //组件管理-获取组件预览图列表
+    public function getComponentImgList(array $data): array;
+    //组件管理-添加组件预览图
+    public function addComponentImg(array $data): array;
+    //组件管理-删除组件预览图
+    public function delComponentImg(array $data): array;
+    //组件管理-更新组件预览图
+    public function updateComponentImg(array $data): array;
+
+
+
 
 }

+ 29 - 0
app/Model/ComponentImg.php

@@ -0,0 +1,29 @@
+<?php
+
+declare(strict_types=1);
+
+namespace App\Model;
+
+use Hyperf\DbConnection\Model\Model;
+
+/**
+ */
+class ComponentImg extends Model
+{
+    /**
+     * The table associated with the model.
+     */
+    protected ?string $table = 'component_img';
+
+    /**
+     * The attributes that are mass assignable.
+     */
+    // protected array $fillable = [];
+
+    /**
+     * The attributes that should be cast to native types.
+     */
+    protected array $casts = [];
+
+    protected array $guarded = [];
+}