Parcourir la source

增加自助建站测试接口

FengR il y a 4 mois
Parent
commit
09d4cb0936
2 fichiers modifiés avec 52 ajouts et 0 suppressions
  1. 25 0
      app/JsonRpc/PublicRpcService.php
  2. 27 0
      app/Model/StyleCode.php

+ 25 - 0
app/JsonRpc/PublicRpcService.php

@@ -46,6 +46,7 @@ use App\Model\SectorComponent;
 use App\Model\ComponentImg;
 use App\Model\TemplateRule;
 use App\Model\SectorType;
+use App\Model\StyleCode;
 
 #[RpcService(name: "PublicRpcService", protocol: "jsonrpc-http", server: "jsonrpc-http")]
 class PublicRpcService implements PublicRpcServiceInterface
@@ -2925,6 +2926,30 @@ class PublicRpcService implements PublicRpcServiceInterface
         }
         return Result::success($sector);
     }
+    /**
+     * 自助建站-添加样式代码
+     */
+    public function addStyleCode(array $data): array
+    {
+        unset($data['status']);
+        $style_code = StyleCode::insertGetId($data);
+        if(empty($style_code)){
+            return Result::error('添加失败!');
+        }
+        return Result::success($style_code);
+    }
+    /**
+     * 自助建站-获取样式代码
+     */
+    public function getStyleCode(array $data): array
+    {
+        unset($data['status']);
+        $style_code = StyleCode::get()->all();
+        if(empty($style_code)){
+            return Result::error('样式代码不存在!');
+        }
+        return Result::success($style_code);
+    }
 
     
 }

+ 27 - 0
app/Model/StyleCode.php

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