Преглед изворни кода

新增接口:政讯-获取网民留言列表

FengR пре 4 дана
родитељ
комит
5b633cdf6c
3 измењених фајлова са 61 додато и 1 уклоњено
  1. 28 1
      app/JsonRpc/WebService.php
  2. 5 0
      app/JsonRpc/WebServiceInterface.php
  3. 28 0
      app/Model/Message.php

+ 28 - 1
app/JsonRpc/WebService.php

@@ -66,7 +66,7 @@ use Hyperf\Utils\Parallel;
 use Hyperf\Coroutine\Concurrent;
 use function Hyperf\Coroutine\batch;
 use Swoole\Coroutine;
-
+use App\Model\Message;
 #[RpcService(name: "WebService", protocol: "jsonrpc-http", server: "jsonrpc-http")]
 class WebService implements WebServiceInterface
 {
@@ -3773,4 +3773,31 @@ class WebService implements WebServiceInterface
     ];
     return Result::success($result);
   }
+  /**
+   * @param array $data
+   * @return array
+   */
+  public function getWebsiteMessage(array $data): array
+  {
+    $web = Website::where('id',$data['website_id'])->first();
+    if (empty($web)) {
+      return Result::error("暂无相关网站信息", 0);
+    }
+    $column_arr = json_decode($web['website_column_arr_id'] ?? [], true);
+    $message = Message::whereIn('message.column_id', $column_arr)
+      ->where('message.status', 1)
+      ->leftJoin('user', 'message.user_id', '=', 'user.id')
+      ->select('message.title', 'message.content','message.reply',
+      'message.updated_at','user.nickname')
+      ->orderBy('message.updated_at', 'desc')
+      ->paginate($data['page_size'], ['*'], 'page', $data['page']);
+    if (empty($message->items())) {
+      return Result::error("暂无相关消息信息", 0);
+    }
+    $result = [
+      'data' => $message->items(),
+      'count' => $message->total(),
+    ];
+    return Result::success($result);
+  }
 }

+ 5 - 0
app/JsonRpc/WebServiceInterface.php

@@ -206,4 +206,9 @@ interface WebServiceInterface
      * @return array
      */
     public function getWebsiteProjectList(array $data): array;
+    /**
+     * @param array $data
+     * @return array
+     */
+    public function getWebsiteMessage(array $data): array;
 }

+ 28 - 0
app/Model/Message.php

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